Applies to VAST Cluster 5.5.
Functions › Numeric and math functions › Hyperbolic functions. Returns the inverse hyperbolic sine of a number: the value whose sinh is that number. It takes any number. For large values it grows like a logarithm, but unlike ln it's defined for zero and negative values, so it's a common way to compress a signed quantity onto a smaller scale.
Syntax
asinh(x)
| Argument | Type | Description |
|---|---|---|
x |
Any number (DOUBLE, REAL, an integer or a DECIMAL) |
Any value, including inf and -inf. |
Returns: DOUBLE.
Set up the examples
The examples connect with the ADBC driver, as in VAST Query Engine (ADBC), and work in a schema called docs_sql_fn_numeric_asinh. Set QE_ENDPOINT, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and VASTDB_BUCKET (SQL reference), 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 six account balance changes, some negative. Row 3 has 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_asinh"'
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, "<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}.changes"
run(f"CREATE SCHEMA IF NOT EXISTS {SCHEMA}")
run(f"CREATE TABLE IF NOT EXISTS {TABLE} (id BIGINT, amount DOUBLE)")
run(f"INSERT INTO {TABLE} VALUES "
"(1, 1.0), (2, -1.0), (3, NULL), (4, 0.0), (5, 1000.0), (6, -1000000.0)")
[]
[]
[(6,)]
What it does
asinh(x) is the inverse of sinh: it returns the value y for which sinh(y) = x. It's an odd function (asinh(-x) is -asinh(x)) and it's 0 at 0. Near 0 it's close to x; for large x it grows like ln(2x), so a value as large as 1e308 gives a result of only about 710.
| Call | Result |
|---|---|
asinh(0) |
0.0 |
asinh(1) |
0.881373587019543 |
asinh(-1) |
-0.881373587019543 |
asinh(1e308) |
709.889355822726 |
asinh(-1e308) |
-709.889355822726 |
The result is a DOUBLE for every numeric argument type: an integer, a REAL, a DECIMAL or a DOUBLE.
run("SELECT asinh(0), asinh(1), asinh(-1), asinh(1e308), asinh(-1e308)")
run("SELECT typeof(asinh(1::INTEGER)), typeof(asinh(0.5::FLOAT)), typeof(asinh(0.5))")
[(0.0, 0.881373587019543, -0.881373587019543, 709.889355822726, -709.889355822726)]
[('DOUBLE', 'DOUBLE', 'DOUBLE')]
NULLs and edge cases
| Input | Result |
|---|---|
NULL |
NULL |
'inf'::DOUBLE |
inf |
'-inf'::DOUBLE |
-inf |
'nan'::DOUBLE |
nan |
-0.0::DOUBLE |
-0.0: the sign of zero is kept |
The smallest positive DOUBLE (5e-324) |
5e-324 |
'12' (a string literal holding a number) |
Converted to DOUBLE: 3.179785437699879 |
'abc' (a string that isn't a number) |
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 'asinh(DATE)' |
The same cases, as the cluster returns them. They use the helpers from Set up the examples:
run("SELECT asinh(NULL), asinh('inf'::DOUBLE), asinh('-inf'::DOUBLE), asinh('nan'::DOUBLE)")
run("SELECT asinh(-0.0::DOUBLE), asinh(5e-324::DOUBLE), asinh('12')")
run("SELECT asinh('abc')")
run("SELECT asinh(DATE '2026-10-16')")
[(None, inf, -inf, nan)]
[(-0.0, 5e-324, 3.179785437699879)]
OSError: Could not convert string 'abc' to DOUBLE
InternalError: Binder Error: No function matches the given name and argument types 'asinh(DATE)'. You might need to add explicit type casts.
Examples
Each change on the asinh scale. Changes from -1,000,000 to 1,000 end up within about -15 to 8, with the sign kept and zero at zero:
run(f"SELECT id, amount, asinh(amount) FROM {TABLE} ORDER BY id LIMIT 10")
[(1, 1.0, 0.881373587019543), (2, -1.0, -0.881373587019543), (3, None, None), (4, 0.0, 0.0), (5, 1000.0, 7.600902709541988), (6, -1000000.0, -14.50865773852447)]
Keep only the rows above 5 on that scale:
run(f"SELECT id, amount FROM {TABLE} WHERE asinh(amount) > 5 ORDER BY id LIMIT 10")
[(5, 1000.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 asinh() is always computed by the Query Engine:
- In the
SELECTlist, the scan reads the column and the Query Engine computesasinh()for each row it returns. - In
WHERE, the scan sends the column for every row, and aFILTERstep in the Query Engine computesasinh()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 asinh(amount) > 5")
┌───────────────────────────┐
│ PROJECTION │
│ ──────────────────── │
│ #1 │
│ │
└─────────────┬─────────────┘
┌─────────────┴─────────────┐
│ FILTER │
│ ──────────────────── │
│ (asinh(amount) > 5.0) │
│ │
└─────────────┬─────────────┘
┌─────────────┴─────────────┐
│ VAST_SCAN │
│ ──────────────────── │
│ Function: VAST_SCAN │
│ │
│ Projections: │
│ amount │
│ id │
│ │
└───────────────────────────┘
Make it faster
- Compare the raw column with the inverse of the constant.
asinh()grows as its argument grows, soasinh(amount) > 5is the same condition asamount > sinh(5). A function on constants is computed once, before the scan, so the second form is a comparison of the column with a constant, which is pushed down to VAST DataBase. Its plan has noFILTERstep:
plan(f"SELECT id FROM {TABLE} WHERE amount > sinh(5)")
run(f"SELECT id, amount FROM {TABLE} WHERE amount > sinh(5) ORDER BY id LIMIT 10")
┌───────────────────────────┐
│ VAST_SCAN │
│ ──────────────────── │
│ Function: VAST_SCAN │
│ Projections: id │
│ │
└───────────────────────────┘
[(5, 1000.0)]
- Store the result if you filter on it often. Compute it when you write the rows and keep it in its own column: a condition on that column is pushed down, a condition on
asinh()isn't.
Limitations and errors
- Numbers only. A
BLOB, a date, a boolean, a list or an interval fails withNo function matches the given name and argument types; the error lists the one formasinhhas,asinh(DOUBLE) -> DOUBLE. A string literal is converted toDOUBLEif it holds a number, and otherwise fails withCould not convert string 'abc' to DOUBLE. - One argument.
asinh(1, 2)fails withNo function matches the given name and argument types 'asinh(INTEGER_LITERAL, INTEGER_LITERAL)'.
Similar functions
| Function | Returns | For 0 and -1 |
|---|---|---|
asinh(x) |
the inverse hyperbolic sine, for any number | 0.0 and -0.881373587019543 |
| ln | the natural logarithm, for positive numbers only | Error: cannot take logarithm of zero; cannot take logarithm of a negative number |
| sinh | the hyperbolic sine: the inverse of asinh |
asinh(sinh(1)) is 1.0 |
| acosh | the inverse hyperbolic cosine, for 1 or more | |
| atanh | the inverse hyperbolic tangent, for -1 to 1 | |
| asin | the inverse sine, an angle, for -1 to 1 |
run("SELECT asinh(0), asinh(-1), asinh(sinh(1)), asinh(0.5), asin(0.5)")
run("SELECT ln(0)")
run("SELECT ln(-1)")
[(0.0, -0.881373587019543, 1.0, 0.48121182505960347, 0.5235987755982989)]
OSError: cannot take logarithm of zero
OSError: cannot take logarithm of a negative number
Clean up:
run(f"DROP TABLE IF EXISTS {TABLE}")
run(f"DROP SCHEMA IF EXISTS {SCHEMA}")
conn.close()
[]
[]
See also
- Numeric and math functions: all the numeric functions.
- Where filters run and pushdowns.
- EXPLAIN: how to read a plan.