--- title: "asin" slug: "dev-database-reference-sql-functions-numeric-asin" updated: 2026-10-30T18:18:51Z published: 2026-10-30T18:18:51Z canonical: "docs.vastdata.com/dev-database-reference-sql-functions-numeric-asin" --- > ## 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. # asin *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) › Inverse trigonometry.* Returns the arcsine of a number: the angle, in radians from -π/2 to π/2, whose sine is that number. The number must be from -1 to 1. For the angle in degrees, wrap it in [degrees](/develop/docs/dev-database-reference-sql-functions-numeric-degrees): `degrees(asin(x))`. It has no aliases. ## Syntax ``` asin(x) ``` | Argument | Type | Description | | --- | --- | --- | | `x` | `DOUBLE` (any integer, `DECIMAL` or `FLOAT` is converted) | A sine, from -1 to 1. | **Returns:** `DOUBLE`: an angle in radians, from -π/2 to π/2. **Aliases:** none. ## 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_asin`. 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 five slopes, each with the height it rises (negative for a drop) divided by its length along the slope: the sine of its angle. The last row has no values: ``` 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_asin"' 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}.slopes" run(f"CREATE SCHEMA IF NOT EXISTS {SCHEMA}") run(f"CREATE TABLE IF NOT EXISTS {TABLE} (id BIGINT, slope VARCHAR, rise_ratio DOUBLE)") run(f"INSERT INTO {TABLE} VALUES " "(1, 'ski run', 0.5), " "(2, 'cliff', 1.0), " "(3, 'meadow', 0.0), " "(4, 'descent', -0.5), " "(5, NULL, NULL)") ``` ``` [] [] [(5,)] ``` ## What it does `asin(x)` is the inverse of [sin](/develop/docs/dev-database-reference-sql-functions-numeric-sin) for angles from -π/2 to π/2: it returns the angle whose sine is `x`. `asin(0)` is `0.0`, `asin(0.5)` is `0.5235987755982989` (π/6), `asin(1)` is `1.5707963267948966` (π/2) and `asin(-1)` is `-1.5707963267948966`. The argument is converted to `DOUBLE`, and so is the result, whatever the argument's type. The result is in radians. In degrees, `degrees(asin(0.5))` is `30.000000000000004`: the result carries the rounding of floating-point numbers, so round it with [round](/develop/docs/dev-database-reference-sql-functions-numeric-round) for display. A sine is never less than -1 or more than 1, so `asin()` is only defined from -1 to 1. Anything outside that range is an error, even by a little: `asin(1.0000000001)` fails with `ASIN is undefined outside [-1,1]`. A ratio you compute yourself can land just outside the range through rounding; clamp it first with `least(greatest(x, -1), 1)`. ## NULLs and edge cases | Input | Result | | --- | --- | | `NULL` | `NULL` | | `0` | `0.0` | | `-0.0::DOUBLE` | `-0.0` | | `0.5` | `0.5235987755982989` | | `1` | `1.5707963267948966` | | `-1` | `-1.5707963267948966` | | `5e-324::DOUBLE` (the smallest `DOUBLE` above 0) | `5e-324` | | `'nan'::DOUBLE` | `nan` | | `1.0000000001`, `-1.0000000001`, `2` | Error: `ASIN is undefined outside [-1,1]` | | `'12'` (a string of digits, converted to 12) | Error: `ASIN is undefined outside [-1,1]` | | `'inf'::DOUBLE` | Error: `input value inf is out of range for numeric function` | | `'-inf'::DOUBLE` | Error: `input value -inf is out of range for numeric function` | | `'abc'` | Error: `Could not convert string 'abc' to DOUBLE` | | A `BLOB`, date, boolean, list or interval | Error: `No function matches the given name and argument types`, for example `'asin(DATE)'` | The same cases, as the cluster returns them. They use the helpers from [Set up the examples](/develop/docs/dev-database-reference-sql-functions-numeric-asin#set-up-the-examples): ``` run("SELECT asin(NULL), asin(0), asin(-0.0::DOUBLE), asin(0.5), asin(1), asin(-1)") run("SELECT asin(5e-324::DOUBLE), asin('nan'::DOUBLE)") run("SELECT asin(1.0000000001)") run("SELECT asin(-1.0000000001)") run("SELECT asin(2)") run("SELECT asin('12')") run("SELECT asin('inf'::DOUBLE)") run("SELECT asin('-inf'::DOUBLE)") run("SELECT asin('abc')") run("SELECT asin('\\xAA'::BLOB)") run("SELECT asin(DATE '2026-10-16')") run("SELECT asin(true)") run("SELECT asin([1, 2])") run("SELECT asin(INTERVAL 1 DAY)") ``` ``` [(None, 0.0, -0.0, 0.5235987755982989, 1.5707963267948966, -1.5707963267948966)] [(5e-324, nan)] OSError: ASIN is undefined outside [-1,1] OSError: ASIN is undefined outside [-1,1] OSError: ASIN is undefined outside [-1,1] OSError: ASIN is undefined outside [-1,1] OSError: input value inf is out of range for numeric function OSError: input value -inf is out of range for numeric function OSError: Could not convert string 'abc' to DOUBLE InternalError: Binder Error: No function matches the given name and argument types 'asin(BLOB)'. You might need to add explicit type casts. InternalError: Binder Error: No function matches the given name and argument types 'asin(DATE)'. You might need to add explicit type casts. InternalError: Binder Error: No function matches the given name and argument types 'asin(BOOLEAN)'. You might need to add explicit type casts. InternalError: Binder Error: No function matches the given name and argument types 'asin(INTEGER[])'. You might need to add explicit type casts. InternalError: Binder Error: No function matches the given name and argument types 'asin(INTERVAL)'. You might need to add explicit type casts. ``` ## Examples The angle of each slope, in radians and in degrees: ``` run(f"SELECT id, slope, asin(rise_ratio), degrees(asin(rise_ratio)) FROM {TABLE} ORDER BY id LIMIT 10") ``` ``` [(1, 'ski run', 0.5235987755982989, 30.000000000000004), (2, 'cliff', 1.5707963267948966, 90.0), (3, 'meadow', 0.0, 0.0), (4, 'descent', -0.5235987755982989, -30.000000000000004), (5, None, None, None)] ``` A ratio that rounding has pushed just past 1, clamped to the range before `asin()`: ``` run("SELECT asin(least(greatest(1.0000000001, -1), 1))") ``` ``` [(1.5707963267948966,)] ``` Keep only the slopes steeper than 45 degrees: ``` run(f"SELECT id, slope FROM {TABLE} WHERE degrees(asin(rise_ratio)) > 45 ORDER BY id LIMIT 10") ``` ``` [(2, 'cliff')] ``` ## 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 `asin()` is always computed by the Query Engine: - **In the `SELECT` list,** the scan reads the column and the Query Engine computes `asin()` for each row it returns. - **In `WHERE`,** the scan sends the column for every row, and a `FILTER` step in the Query Engine computes `asin()` and keeps the rows that match. No rows are skipped in storage. The plan of the `WHERE` example shows the `FILTER` step above the scan: ``` plan(f"SELECT id FROM {TABLE} WHERE degrees(asin(rise_ratio)) > 45") ``` ``` ┌───────────────────────────┐ │ PROJECTION │ │ ──────────────────── │ │ #1 │ │ │ └─────────────┬─────────────┘ ┌─────────────┴─────────────┐ │ FILTER │ │ ──────────────────── │ │ (degrees(asin(rise_ratio))│ │ > 45.0) │ │ │ └─────────────┬─────────────┘ ┌─────────────┴─────────────┐ │ VAST_SCAN │ │ ──────────────────── │ │ Function: VAST_SCAN │ │ │ │ Projections: │ │ rise_ratio │ │ id │ │ │ └───────────────────────────┘ ``` ## Make it faster - **Compare the ratio, not its angle.** `asin()` grows with its argument, so a threshold on the angle is a threshold on the ratio: steeper than 45 degrees is `rise_ratio > sin(radians(45))`. A function of constants is computed once, and the comparison of the raw column is pushed down to VAST DataBase, so rows that don't match never leave storage, and `asin()` isn't computed at all, so a value outside -1 to 1 can't fail the query. The plan has no `FILTER` step: ``` plan(f"SELECT id FROM {TABLE} WHERE rise_ratio > sin(radians(45))") ``` ``` ┌───────────────────────────┐ │ VAST_SCAN │ │ ──────────────────── │ │ Function: VAST_SCAN │ │ Projections: id │ │ │ └───────────────────────────┘ ``` - **Store the angle if you filter on it often.** Compute it when you write the rows and keep it in its own column: a comparison of that column is pushed down, `asin()` in `WHERE` isn't. - **Combine it with a pushed-down condition.** In `id > 100 AND asin(rise_ratio) > 0.5`, `id > 100` is still evaluated in VAST DataBase, so `asin()` runs only on the rows that pass it. ## Limitations and errors - **From -1 to 1 only.** Anything else fails with `ASIN is undefined outside [-1,1]`, and an infinite value with `input value inf is out of range for numeric function`. On a table, one such row fails the whole query, not just that row. Clamp computed ratios with `least(greatest(x, -1), 1)`, or compare the raw column (see [Make it faster](/develop/docs/dev-database-reference-sql-functions-numeric-asin#make-it-faster)). - **Thresholds on a rounded angle.** `degrees(asin(0.5))` is `30.000000000000004`, so `degrees(asin(x)) > 30` is true for `x = 0.5`. Compare with a margin, or compare the ratio itself. - **The result is in radians,** from -π/2 to π/2. Convert it with [degrees](/develop/docs/dev-database-reference-sql-functions-numeric-degrees). For an angle in the full circle from the two sides of a triangle or a point (x, y), use [atan2](/develop/docs/dev-database-reference-sql-functions-numeric-atan2). - **One argument, numbers only.** `asin(1, 2)`, a `BLOB`, a date, a boolean, a list or an interval fails with `No function matches the given name and argument types`. A string is converted to `DOUBLE`, so a string that isn't a number fails with `Could not convert string ... to DOUBLE`. ``` run("SELECT asin(2)") run("SELECT asin(1, 2)") ``` ``` OSError: ASIN is undefined outside [-1,1] InternalError: Binder Error: No function matches the given name and argument types 'asin(INTEGER_LITERAL, INTEGER_LITERAL)'. You might need to add explicit type casts. ``` ## Similar functions | Function | Returns the angle whose | Result for `0.5` | | --- | --- | --- | | `asin(x)` | sine is `x`, from -π/2 to π/2 | `0.5235987755982989` | | [acos](/develop/docs/dev-database-reference-sql-functions-numeric-acos) | cosine is `x`, from 0 to π | `1.0471975511965979` | | [atan](/develop/docs/dev-database-reference-sql-functions-numeric-atan) | tangent is `x`, from -π/2 to π/2 | `0.4636476090008061` | | [atan2](/develop/docs/dev-database-reference-sql-functions-numeric-atan2) `(y, x)` | tangent is `y / x`, in the right quadrant, from -π to π | `atan2(0.5, 1)` = `0.4636476090008061` | | `degrees(asin(x))` | sine is `x`, in degrees | `30.000000000000004` | | [asinh](/develop/docs/dev-database-reference-sql-functions-numeric-asinh) | hyperbolic sine is `x` | | ``` run("SELECT asin(0.5), acos(0.5), atan(0.5), atan2(0.5, 1), degrees(asin(0.5))") ``` ``` [(0.5235987755982989, 1.0471975511965979, 0.4636476090008061, 0.4636476090008061, 30.000000000000004)] ``` 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#trigonometry): all the trigonometric functions. - [sin](/develop/docs/dev-database-reference-sql-functions-numeric-sin), [acos](/develop/docs/dev-database-reference-sql-functions-numeric-acos), [atan](/develop/docs/dev-database-reference-sql-functions-numeric-atan), [atan2](/develop/docs/dev-database-reference-sql-functions-numeric-atan2) and [degrees](/develop/docs/dev-database-reference-sql-functions-numeric-degrees). - [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.