--- title: "radians" slug: "dev-database-reference-sql-functions-numeric-radians" updated: 2026-10-30T18:18:51Z published: 2026-10-30T18:18:51Z canonical: "docs.vastdata.com/dev-database-reference-sql-functions-numeric-radians" --- > ## 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. # radians *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) › Angles and constants.* Converts an angle from degrees to radians: `radians(x)` is `x * pi() / 180`. The trigonometric functions take radians, so use it before [sin](/develop/docs/dev-database-reference-sql-functions-numeric-sin), [cos](/develop/docs/dev-database-reference-sql-functions-numeric-cos) or [tan](/develop/docs/dev-database-reference-sql-functions-numeric-tan). [degrees](/develop/docs/dev-database-reference-sql-functions-numeric-degrees) does the opposite. ## Syntax ``` radians(x) ``` | Argument | Type | Description | | --- | --- | --- | | `x` | `DOUBLE` (any number) | An angle in degrees. Integers, `DECIMAL` and `FLOAT` values are converted to `DOUBLE`. | **Returns:** `DOUBLE`. ## 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_radians`. 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, as angles in degrees. Row 3 has no angle: ``` 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_radians"' 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, deg DOUBLE)") run(f"INSERT INTO {TABLE} VALUES (1, 30.0), (2, 90.0), (3, NULL), (4, 0.0), (5, -45.0)") ``` ``` [] [] [(5,)] ``` ## What it does `radians(x)` multiplies an angle in degrees by π/180. It doesn't wrap the result into a range: `radians(360)` is `6.283185307179586`, and a negative angle gives a negative result. The result is rounded to the nearest `DOUBLE`. Converting back can give the angle you started with: `radians(degrees(1))` is `1.0`. ## NULLs and edge cases | Input | Result | | --- | --- | | `NULL` | `NULL` | | `180`, `90`, `360`, `-45` | `3.141592653589793`, `1.5707963267948966`, `6.283185307179586`, `-0.7853981633974483` | | `-0.0::DOUBLE` | `-0.0` | | `5e-324::DOUBLE` (the smallest `DOUBLE` above 0) | `0.0`: the result is too small for a `DOUBLE` | | `1e308` | `1.7453292519943295e+306` | | `'inf'::DOUBLE`, `'-inf'::DOUBLE`, `'nan'::DOUBLE` | `inf`, `-inf`, `nan` | | `'12'` (a string) | Converted to `DOUBLE`: `0.20943951023931956` | | `'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 `'radians(DATE)'` | | An `INTEGER`, `FLOAT` or `DECIMAL` value | Converted; the result is `DOUBLE` | 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-radians#set-up-the-examples): ``` run("SELECT radians(NULL), radians(180), radians(90), radians(360), radians(-45)") run("SELECT radians(-0.0::DOUBLE), radians(5e-324::DOUBLE), radians(1e308)") run("SELECT radians('inf'::DOUBLE), radians('-inf'::DOUBLE), radians('nan'::DOUBLE), radians('12')") run("SELECT typeof(radians(1::INTEGER)), typeof(radians(0.5::FLOAT)), typeof(radians(0.5))") run("SELECT radians('abc')") run("SELECT radians(DATE '2026-10-16')") ``` ``` [(None, 3.141592653589793, 1.5707963267948966, 6.283185307179586, -0.7853981633974483)] [(-0.0, 0.0, 1.7453292519943295e+306)] [(inf, -inf, nan, 0.20943951023931956)] [('DOUBLE', 'DOUBLE', 'DOUBLE')] OSError: Could not convert string 'abc' to DOUBLE InternalError: Binder Error: No function matches the given name and argument types 'radians(DATE)'. You might need to add explicit type casts. ``` ## Examples Each slope in radians, with its sine and cosine: ``` run(f"SELECT id, deg, radians(deg), sin(radians(deg)), cos(radians(deg)) FROM {TABLE} ORDER BY id LIMIT 10") ``` ``` [(1, 30.0, 0.5235987755982988, 0.49999999999999994, 0.8660254037844387), (2, 90.0, 1.5707963267948966, 1.0, 6.123233995736766e-17), (3, None, None, None, None), (4, 0.0, 0.0, 0.0, 1.0), (5, -45.0, -0.7853981633974483, -0.7071067811865475, 0.7071067811865476)] ``` The rise over a 100-metre horizontal run, for the slopes from 0 up to, not including, 90 degrees: ``` run(f"SELECT id, 100 * tan(radians(deg)) FROM {TABLE} WHERE deg >= 0 AND deg < 90 ORDER BY id LIMIT 10") ``` ``` [(1, 57.735026918962575), (4, 0.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 `radians()` of a column is always computed by the Query Engine: - **In the `SELECT` list,** the scan reads the column and the Query Engine computes `radians()` for each row it returns. - **In `WHERE`,** the scan sends the column for every row, and a `FILTER` step in the Query Engine computes `radians()` and keeps the rows that match. - **On a constant,** as in `x > radians(90)`, the Query Engine computes it once, before the scan, and the condition can be pushed down. The plan of a `WHERE` condition on `radians(deg)` shows the `FILTER` step above the scan: ``` plan(f"SELECT id FROM {TABLE} WHERE radians(deg) > 1") ``` ``` ┌───────────────────────────┐ │ PROJECTION │ │ ──────────────────── │ │ #1 │ │ │ └─────────────┬─────────────┘ ┌─────────────┴─────────────┐ │ FILTER │ │ ──────────────────── │ │ (radians(deg) > 1.0) │ │ │ └─────────────┬─────────────┘ ┌─────────────┴─────────────┐ │ VAST_SCAN │ │ ──────────────────── │ │ Function: VAST_SCAN │ │ │ │ Projections: │ │ deg │ │ id │ │ │ └───────────────────────────┘ ``` ## Make it faster - **Convert the constant, not the column.** `deg > degrees(1)` keeps the same rows as `radians(deg) > 1`, and its right-hand side is a constant, so the scan in VAST DataBase can evaluate it: ``` plan(f"SELECT id FROM {TABLE} WHERE deg > degrees(1)") run(f"SELECT id FROM {TABLE} WHERE deg > degrees(1) ORDER BY id LIMIT 10") ``` ``` ┌───────────────────────────┐ │ VAST_SCAN │ │ ──────────────────── │ │ Function: VAST_SCAN │ │ Projections: id │ │ │ └───────────────────────────┘ [(2,)] ``` - **Store angles in the unit you compute with.** If most queries pass the angle to `sin()` or `cos()`, storing radians saves a conversion on every row. ## Limitations and errors - **No range check.** A result too small for a `DOUBLE` is `0.0`, with no error. Infinity and NaN pass through unchanged. - **One argument, numbers only.** A second argument, a date, a boolean, a `BLOB`, a list or an interval fails with `No function matches the given name and argument types`. A string is converted to `DOUBLE` first, and fails with `Could not convert string ... to DOUBLE` if it isn't a number. - **No degree versions of the trigonometric functions.** `sind()`, `cosd()` and `atan2d()` don't exist (`Scalar Function with name sind does not exist!` for `sind`); use `sin(radians(x))`, and `degrees()` of the inverse functions: ``` run("SELECT sind(30)") run("SELECT sin(radians(30)), degrees(atan2(1, 1))") ``` ``` InternalError: Catalog Error: Scalar Function with name sind does not exist! [(0.49999999999999994, 45.0)] ``` ## Similar functions | Function | Converts | Result | | --- | --- | --- | | `radians(x)` | degrees to radians | `radians(180)` is `3.141592653589793` | | [degrees](/develop/docs/dev-database-reference-sql-functions-numeric-degrees)`(x)` | radians to degrees | `degrees(pi())` is `180.0` | | `x * pi() / 180` | the same formula as `radians`, written out | | | [pi](/develop/docs/dev-database-reference-sql-functions-numeric-pi)`()` | the constant π | `3.141592653589793` | ``` run("SELECT radians(180), degrees(pi()), 180 * pi() / 180, pi(), radians(degrees(1))") ``` ``` [(3.141592653589793, 180.0, 3.141592653589793, 3.141592653589793, 1.0)] ``` 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#angles-and-constants): pi, degrees and radians. - [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.