--- title: "isinf" slug: "dev-database-reference-sql-functions-numeric-isinf" updated: 2026-10-30T18:18:51Z published: 2026-10-30T18:18:51Z canonical: "docs.vastdata.com/dev-database-reference-sql-functions-numeric-isinf" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.vastdata.com/llms.txt > Use this file to discover all available pages before exploring further. # isinf *Applies to VAST Cluster 5.5.* *[Functions](/develop/docs/dev-database-reference-sql-functions-index) › [Numeric and math functions](/develop/docs/dev-database-reference-sql-functions-numeric) › Floating-point values.* Returns `true` if `x` is infinite, `inf` or `-inf`, and `false` for any other number, NaN included. It also takes a date or timestamp, and is `true` for the special values `'infinity'` and `'-infinity'`. ## Syntax ``` isinf(x) ``` | Argument | Type | Description | | --- | --- | --- | | `x` | `DOUBLE`, `FLOAT`, `DATE`, `TIMESTAMP` or `TIMESTAMP WITH TIME ZONE` | The value to test. An integer or `DECIMAL` literal is accepted, and is never infinite. | **Returns:** `BOOLEAN`. ## Set up the examples The examples connect with the ADBC driver, as in [VAST Query Engine (ADBC)](/develop/docs/dev-database-integrations-adbc), and work in a schema called `docs_sql_fn_numeric_isinf`. Set `QE_ENDPOINT`, `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` and `VASTDB_BUCKET` ([SQL reference](/develop/docs/dev-database-reference-sql-index#example-connect-and-use-a-transaction)), and run the blocks in order in one Python session. Below each block is the output you should see. This block connects, defines the `run()` and `plan()` helpers, and creates a table of seven ratios: ordinary values, both infinities, NaN, negative zero and, in row 6, no value: ``` import os import re import adbc_driver_manager import adbc_driver_manager.dbapi as dbapi import adbc_driver_vastdb BUCKET = os.environ["VASTDB_BUCKET"] SCHEMA = f'"{BUCKET}/docs_sql_fn_numeric_isinf"' conn = dbapi.connect( driver=adbc_driver_vastdb.get_driver_path(), db_kwargs={ "vast.db.endpoint": os.environ["QE_ENDPOINT"], "vast.db.access_key": os.environ["AWS_ACCESS_KEY_ID"], "vast.db.secret_key": os.environ["AWS_SECRET_ACCESS_KEY"], }, autocommit=True, ) def server_message(e): """The server's message in a driver error, without the request ID or the echoed statement.""" text = re.sub(r"\[req=0x[0-9a-f]+\]: ", "", str(e)) found = (re.search(r'message: "(.*?)", request_id', text, re.S) or re.search(r"description: (.*)\)", text, re.S)) message = found.group(1) if found else text.strip().splitlines()[-1] message = re.sub(r"^Plan query: '.*?' failed with: ", "", message, flags=re.S) message = re.split(r"\\n|\n", message)[0].replace('\\"', '"') return message.replace(BUCKET, "") def run(sql): """Run one statement. Print the rows it returns, or the error.""" try: with conn.cursor() as cur: cur.execute(sql) rows = cur.fetchall() if cur.description else [] except (adbc_driver_manager.Error, OSError) as e: print(f"{type(e).__name__}: {server_message(e)}") else: print(rows) def plan(sql): """Print the plan without its ~N Rows lines: the table's row count, which can still be 0 just after an insert.""" with conn.cursor() as cur: cur.execute("EXPLAIN " + sql) steps = cur.fetchall()[0][1] print("\n".join(line for line in steps.splitlines() if "Rows" not in line)) TABLE = f"{SCHEMA}.ratios" run(f"CREATE SCHEMA IF NOT EXISTS {SCHEMA}") run(f"CREATE TABLE IF NOT EXISTS {TABLE} (id BIGINT, x DOUBLE)") run(f"INSERT INTO {TABLE} VALUES " "(1, 2.5), (2, 'inf'::DOUBLE), (3, '-inf'::DOUBLE), (4, 'nan'::DOUBLE), " "(5, '-0.0'::DOUBLE), (6, NULL), (7, 1.0)") ``` ``` [] [] [(7,)] ``` ## What it does Floating-point values include positive and negative infinity. You get them from a division by zero with `/` (`1 / 0` is `inf`), from a result too large for the type (`1e308 * 10` is `inf`), and by casting `'inf'`, `'infinity'` or `'-Infinity'` to `DOUBLE`. `isinf(x)` is `true` for both infinities and `false` for everything else, NaN included; NULL gives NULL. A `DATE` or `TIMESTAMP` can also hold `'infinity'` or `'-infinity'`, and `isinf()` is `true` for them and `false` for an ordinary date. The [date and time version](/develop/docs/dev-database-reference-sql-functions-date-time-isinf) has the details. ## NULLs and edge cases | Input | Result | | --- | --- | | `NULL`, `NULL::FLOAT` | `NULL` | | `'inf'::DOUBLE`, `'-inf'::DOUBLE`, `'inf'::FLOAT` | `true` | | `1 / 0`, `-1 / 0`, `1e308 * 10` | `true` | | `'nan'::DOUBLE`, `'nan'::FLOAT`, `0 / 0` | `false`: NaN isn't infinite | | `-0.0::DOUBLE`, `1.0::DOUBLE`, `1::FLOAT` | `false` | | `1`, `2.45`, `9223372036854775807` (integer and `DECIMAL` literals) | `false` | | `'infinity'::DATE`, `'infinity'::TIMESTAMP` | `true` | | `DATE '2026-10-16'` | `false` | | `'nan'` or any other string literal | Error: `Could not choose a best candidate function for the function call "isinf(STRING_LITERAL)"`; cast it: `'inf'::DOUBLE` | | A `BLOB`, boolean, list or interval | Error: `No function matches the given name and argument types`, for example `'isinf(BOOLEAN)'` | The same cases, as the cluster returns them. They use the table and helpers from [Set up the examples](/develop/docs/dev-database-reference-sql-functions-numeric-isinf#set-up-the-examples): ``` run("SELECT isinf(NULL), isinf(NULL::FLOAT), isinf('inf'::DOUBLE), isinf('-inf'::DOUBLE), isinf('inf'::FLOAT)") run("SELECT isinf(1 / 0), isinf(-1 / 0), isinf(1e308 * 10), isinf('nan'::DOUBLE), isinf('nan'::FLOAT), isinf(0 / 0)") run("SELECT isinf(-0.0::DOUBLE), isinf(1.0::DOUBLE), isinf(1::FLOAT), isinf(1), isinf(2.45), " "isinf(9223372036854775807), typeof(isinf(1))") run("SELECT isinf('infinity'::DATE), isinf('infinity'::TIMESTAMP), isinf(DATE '2026-10-16')") run("SELECT isinf('nan')") run("SELECT isinf(true)") ``` ``` [(None, None, True, True, True)] [(True, True, True, False, False, False)] [(False, False, False, False, False, False, 'BOOLEAN')] [(True, True, False)] InternalError: Binder Error: Could not choose a best candidate function for the function call "isinf(STRING_LITERAL)". In order to select one, please add explicit type casts. InternalError: Binder Error: No function matches the given name and argument types 'isinf(BOOLEAN)'. You might need to add explicit type casts. ``` ## Examples Test each ratio. Row 4 is NaN, so its result is `false`; row 6 has no value, so its result is NULL: ``` run(f"SELECT id, x, isinf(x) FROM {TABLE} ORDER BY id LIMIT 10") ``` ``` [(1, 2.5, False), (2, inf, True), (3, -inf, True), (4, nan, False), (5, -0.0, False), (6, None, None), (7, 1.0, False)] ``` Replace the infinite ratios with NULL before you compute with them: ``` run(f"SELECT id, CASE WHEN isinf(x) THEN NULL ELSE x END FROM {TABLE} ORDER BY id LIMIT 10") ``` ``` [(1, 2.5), (2, None), (3, None), (4, nan), (5, -0.0), (6, None), (7, 1.0)] ``` ## How it runs in VAST The Query Engine runs on the cluster's CNodes, and a query on a table starts with a scan in VAST DataBase (`VAST_SCAN`). VAST DataBase can evaluate a comparison of a column with a constant, but not a function of a column, so `isinf()` is always computed by the Query Engine: - **In the `SELECT` list,** the scan reads the column and the Query Engine computes `isinf()` for each row it returns. - **In `WHERE`,** the scan sends the column for every row, and a `FILTER` step in the Query Engine computes `isinf()` and keeps the rows that match. The plan of a `WHERE isinf(x)` query shows the `FILTER` step above the scan: ``` plan(f"SELECT id FROM {TABLE} WHERE isinf(x)") ``` ``` ┌───────────────────────────┐ │ PROJECTION │ │ ──────────────────── │ │ #1 │ │ │ └─────────────┬─────────────┘ ┌─────────────┴─────────────┐ │ FILTER │ │ ──────────────────── │ │ isinf(x) │ │ │ └─────────────┬─────────────┘ ┌─────────────┴─────────────┐ │ VAST_SCAN │ │ ──────────────────── │ │ Function: VAST_SCAN │ │ │ │ Projections: │ │ x │ │ id │ │ │ └───────────────────────────┘ ``` ## Make it faster - **Compare with the largest `DOUBLE`.** `x > 1.7976931348623157e308` compares the raw column with a constant, so it's pushed down to VAST DataBase and the plan has no `FILTER` step. It keeps `inf`, not `-inf`. NaN compares larger than every number in the Query Engine (see [isnan](/develop/docs/dev-database-reference-sql-functions-numeric-isnan#what-it-does)), so it keeps NaN rows too: the second line shows rows 2 (`inf`) and 4 (NaN) for this table: ``` plan(f"SELECT id FROM {TABLE} WHERE x > 1.7976931348623157e308") run(f"SELECT id FROM {TABLE} WHERE x > 1.7976931348623157e308 ORDER BY id LIMIT 10") ``` ``` ┌───────────────────────────┐ │ VAST_SCAN │ │ ──────────────────── │ │ Function: VAST_SCAN │ │ Projections: id │ │ │ └───────────────────────────┘ [(2,), (4,)] ``` - **Avoid writing infinities.** If an infinite value means "no answer", store NULL instead: aggregates skip NULLs, while a sum of a column that holds both `inf` and `-inf` is NaN. ## Limitations and errors - **A string literal must be cast.** `isinf('inf')` fails with `Could not choose a best candidate function for the function call "isinf(STRING_LITERAL)"`, because the literal could be a number, a date or a timestamp. Write `isinf('inf'::DOUBLE)`. - **Numbers, dates and timestamps only.** A `BLOB`, boolean, list or interval fails with `No function matches the given name and argument types`. - **Other names aren't available.** `is_infinite()` and an `infinity()` constant don't exist (`Scalar Function with name is_infinite does not exist!`); use `isinf()` and `'inf'::DOUBLE`: ``` run("SELECT is_infinite(1.0)") run("SELECT infinity()") run("SELECT 'inf'::DOUBLE, 'infinity'::DOUBLE, '-Infinity'::DOUBLE") ``` ``` InternalError: Catalog Error: Scalar Function with name is_infinite does not exist! InternalError: Catalog Error: Scalar Function with name infinity does not exist! [(inf, inf, -inf)] ``` ## Similar functions | Function | `nan` | `inf` | `-inf` | `-0.0` | `1.0` | `NULL` | | --- | --- | --- | --- | --- | --- | --- | | [isnan](/develop/docs/dev-database-reference-sql-functions-numeric-isnan)`(x)` | `true` | `false` | `false` | `false` | `false` | `NULL` | | `isinf(x)` | `false` | `true` | `true` | `false` | `false` | `NULL` | | [isfinite](/develop/docs/dev-database-reference-sql-functions-numeric-isfinite)`(x)` | `false` | `false` | `false` | `true` | `true` | `NULL` | | [signbit](/develop/docs/dev-database-reference-sql-functions-binary-hash-uuid-signbit)`(x)` | `false` | `false` | `true` | `true` | `false` | `NULL` | ``` run("SELECT x, isnan(x), isinf(x), isfinite(x), signbit(x) FROM (VALUES ('nan'::DOUBLE), ('inf'::DOUBLE), " "('-inf'::DOUBLE), (-0.0::DOUBLE), (1.0::DOUBLE), (NULL::DOUBLE)) v(x)") ``` ``` [(nan, True, False, False, False), (inf, False, True, False, False), (-inf, False, True, False, True), (-0.0, False, False, True, True), (1.0, False, False, True, False), (None, None, None, None, None)] ``` Clean up: ``` run(f"DROP TABLE IF EXISTS {TABLE}") run(f"DROP SCHEMA IF EXISTS {SCHEMA}") conn.close() ``` ``` [] [] ``` ## See also - [Numeric and math functions](/develop/docs/dev-database-reference-sql-functions-numeric#floating-point-values): isnan, isinf and isfinite. - [isinf for dates and timestamps](/develop/docs/dev-database-reference-sql-functions-date-time-isinf). - [Where filters run](/develop/docs/dev-database-reference-sql-select#where-filters-run) and [pushdowns](/develop/docs/dev-database-reference-pushdowns). - [EXPLAIN](/develop/docs/dev-database-reference-sql-explain): how to read a plan.