Skip to content
OnchainQueries

Query language

Functions & execution

OnchainQL functions have a defined execution form. Everything else passes through untouched — which is not the same as being supported.

Defined execution forms

OnchainQLExecutes asNotes
date_trunc(unit, value)dateTrunc(unit, value)Result normalized to UTC DateTime64(3)
count_if(condition)countIf(condition)Counts true values
from_base58(value)base58Decode(value)Binary value uses an opaque binary representation
to_base58(value)base58Encode(value)Encodes binary string data
json_extract(value, path)JSON_QUERY(value, path)Partial JSON compatibility
json_extract_scalar(value, path)JSON_VALUE(value, path)Returns a scalar representation
approx_percentile(value, p)quantileTDigest(p)(value)Only the simple two-argument form
CAST(value AS VARBINARY)CAST(value AS String)Representation approximation, not a native binary type
ARRAY[...][...]Array literal syntax
INTERVAL 'n' UNITINTERVAL n UNITn must be an unsigned integer literal
TIMESTAMP 'value'UTC DateTime64(6)OnchainQueries normalizes timestamps to UTC

Approximate percentiles

Only the simple two-argument form is translated.

percentile.sql
SELECT approx_percentile(sol_amount, 0.95)FROM pump_fun.trade_event;

Weighted percentiles, arrays of percentile values and complex nested arguments are not translated. Approximate results should not be expected to match another engine exactly.

Base58 and varbinary

base58.sql
SELECT  to_base58(from_base58(mint)) AS normalized_mintFROM pump_fun.trade_eventLIMIT 10;

OnchainQueries models varbinary values as opaque binary strings. Basic Base58 encoding and decoding are supported; a broader varbinary helper library is not implemented.

JSON

Use json_extract or json_extract_scalar for the translated compatibility path.

Not implemented, on purpose

These higher-order and map functions are refused because the same-named functions underneath do not provide a safe compatibility contract. Failing loudly is the point — silently returning different numbers would be worse.

  • element_at, filter, reduce, transform, zip_with
  • map, map_filter, map_transform_keys, map_transform_values
  • json_parse, json_array_length

Other array operations follow the execution layer’s behaviour and may require their underlying names rather than their OnchainQL equivalents.