SQL reference

Function catalog

Supported function names, aliases and signatures organized by family.

This page is the discovery index for VegaDB functions. Family pages explain behavior and examples; information_schema.routines returns the exact overload types enabled on the connected warehouse.

For worked SQL examples, use scalar functions, aggregates, window functions or nested data and JSON.

SELECT routine_name, data_type
FROM information_schema.routines
ORDER BY routine_name, specific_name;

An alias has the same core operation as its canonical name but can retain syntax-specific argument order. An overload remains subject to its accepted input types, dimensions and bounded-state rules.

Aggregate

FamilyNames and signatures
Countingcount(*), count(value), countif(condition), count_if(condition)
Sum and averagesum(value), fsum(value), avg(value), favg(value), weighted_avg(value, weight), product(value), geometric_mean(value)
Extremesmin(value), max(value), min(value, n), max(value, n)
Associated valuesarg_min(arg, value), arg_max(arg, value), arg_min(arg, value, n), arg_max(arg, value, n), arg_min_null, arg_max_null, min_by, max_by
Value selectionany_value, arbitrary, first, last
Collectionslist, array_agg, string_agg, group_concat
Boolean and bitbool_and, bool_or, every, bit_and, bit_or, bit_xor, bitstring_agg
Distributionhistogram, histogram_exact, histogram_values
Approximateapprox_count_distinct, approx_quantile, approx_top_k, reservoir_quantile
Exact statisticsmedian, mode, mad, quantile_cont, quantile_disc, entropy, skewness, kurtosis, kurtosis_pop, sem
Variationvar_pop, var_samp, variance, stddev_pop, stddev_samp, stddev
Covariancecorr, covar_pop, covar_samp
Regressionregr_avgx, regr_avgy, regr_count, regr_intercept, regr_r2, regr_slope, regr_sxx, regr_sxy, regr_syy

Numeric

FamilyNames
Magnitude and signabs, sign, signbit, even
Roundingceil, ceiling, floor, round, round_even, roundbankers, trunc
Roots and powerssqrt, cbrt, pow, power, exp
Logarithmsln, log, log2, log10
Trigonometrysin, cos, tan, cot, asin, acos, atan, atan2
Hyperbolicsinh, cosh, tanh, asinh, acosh, atanh
Anglesdegrees, radians, pi
Integer helpersbit_count, factorial, gcd, greatest_common_divisor, lcm, least_common_multiple
Special/boundarygamma, lgamma, isfinite, isinf, isnan, nextafter
Selectiongreatest, least
Arithmetic aliasesadd, subtract, multiply, divide, fdiv, fmod
Randomrandom

Numeric operators include addition, subtraction, multiplication, division, integer division, remainder, power, bitwise operations and shifts. See Expressions and operators.

Text

FamilyNames
Length/code pointslength, len, char_length, character_length, strlen, octet_length, bit_length, ascii, unicode, ord, chr
Case/normalizationlower, lcase, upper, ucase, casefold, nfc_normalize, strip_accents
Trim/padtrim, ltrim, rtrim, lpad, rpad
Extractsubstring, substr, substring_grapheme, left, right, left_grapheme, right_grapheme, split_part
Combine/transformconcat, concat_ws, replace, translate, reverse, repeat
Find/testcontains, starts_with, ends_with, prefix, suffix, strpos, instr, position
Splitsplit, string_split, string_to_array, str_split, string_split_regex, str_split_regex
Similaritylevenshtein, damerau_levenshtein, editdist3, hamming, mismatches, jaccard, jaro_similarity, jaro_winkler_similarity
Formattingformat, printf, bar, format_bytes, formatReadableDecimalSize
Pathsparse_filename, parse_dirname, parse_dirpath, parse_path

Pattern helpers include like_escape, ilike_escape, not_like_escape and not_ilike_escape. Pattern operators and regular-expression functions are documented below.

Regular expressions

regexp_escape, regexp_extract, regexp_extract_all, regexp_full_match, regexp_matches, regexp_replace, regexp_split_to_array and regexp_split_to_table support compatible patterns and option flags. Common flags include case-sensitive/case-insensitive, literal, newline and global replacement behavior where applicable.

Date, time and interval

FamilyNames
Current valuescurrent_date, today, current_time, current_timestamp, now, transaction_timestamp, localtime, localtimestamp
Partsdate_part, datepart, extract, plus convenience part functions such as year, month, week, day, hour, minute, second, epoch, isoyear, isodow
Arithmeticdate_add, date_diff, date_sub, age
Boundariesdate_trunc, time_bucket, last_day, days_in_month
Names/conversiondayname, monthname, julian, epoch_ms, epoch_us, epoch_ns, to_timestamp
Constructorsmake_date, make_time, make_timestamp, make_timestamp_ms, make_timestamp_ns, make_timestamptz
Parse/formatstrftime, strptime, try_strptime
Zonestimezone, AT TIME ZONE
Interval constructorsto_years, to_quarters, to_months, to_weeks, to_days, to_hours, to_minutes, to_seconds, to_milliseconds, to_microseconds
Seriesrange, generate_series with compatible temporal bounds and interval step

See Date and time formats for supported percent specifiers.

Binary, encoding and hashing

base64, to_base64, from_base64, hex, to_hex, from_hex, unhex, bin, unbin, encode, decode, to_binary, from_binary, url_encode, url_decode, md5, md5_number, md5_number_lower, md5_number_upper, sha1, sha256 and hash.

LIST and list aliases

FamilyCanonical names and common aliases
Constructlist_value, list_pack, array_value, range, generate_series, repeat
Access/slicelist_extract, list_element, list_slice, array_extract, array_slice
Length/membershiplength, list_contains, list_has, list_has_all, list_has_any, list_position, list_indexof, plus corresponding array_* aliases
Add/combinelist_append, list_prepend, list_concat, list_cat, list_resize, plus array_* aliases
Order/setlist_distinct, list_unique, list_intersect, list_sort, list_reverse, list_reverse_sort, list_grade_up, plus array_* aliases
Select/shapelist_select, list_where, list_zip, flatten, unnest, plus array_* aliases
Lambdalist_apply, list_filter, list_transform, list_reduce, apply, filter, reduce, plus array_* aliases
Aggregate a listlist_aggregate, list_aggr, list_sum, list_avg, list_min, list_max, list_count, list_product, list_first, list_last, list_any_value
List statisticslist_median, list_mode, list_mad, list_sem, list_entropy, list_skewness, list_kurtosis, list_var_pop, list_var_samp, list_stddev_pop, list_stddev_samp
Vector-like list mathlist_distance, list_cosine_distance, list_cosine_similarity, list_inner_product, list_dot_product, list_negative_inner_product, list_negative_dot_product

Fixed ARRAY and vector math

array_value, array_distance, array_cosine_distance, array_cosine_similarity, array_inner_product, array_dot_product, array_negative_inner_product, array_negative_dot_product and array_cross_product require compatible numeric element types and dimensions.

STRUCT, MAP, UNION and enum

TypeNames
STRUCTrow, struct_pack, struct_extract, struct_extract_at, struct_insert, struct_update, struct_concat, struct_contains, struct_has, struct_position, struct_indexof
MAPmap, map_from_entries, map_entries, map_keys, map_values, map_extract, map_extract_value, element_at, map_contains, map_contains_entry, map_contains_value, map_concat, cardinality
UNIONunion_value, union_tag, union_extract, member access
ENUMenum_code, enum_first, enum_last, enum_range, enum_range_boundary

JSON

json_valid, json_type, json_structure, json_extract, json_extract_string, json_value, json_exists, json_array_length, json_keys, json_contains, json_array, json_object, to_json, json_merge_patch, json_transform, json_transform_strict and from_json. The arrow operators return JSON or text according to the selected form.

Conditional, conversion and utility

coalesce, if, ifnull, nullif, constant_or_null, CAST, TRY_CAST, cast_to_type, can_cast_implicitly, typeof, pg_typeof, alias, error, current_catalog, current_database, current_schema, current_schemas, current_query, current_setting, version, stats, create_sort_key, equi_width_bins, is_histogram_other_bin, uuid, uuidv4, uuidv7, gen_random_uuid, uuid_extract_version and uuid_extract_timestamp.

Window

row_number, rank, dense_rank, percent_rank, cume_dist, ntile, lag, lead, first_value, last_value, nth_value, fill, and supported aggregates used with OVER.

See Window functions for ordering and frame behavior.

Vegalake, VegaDB and VegaFlow are trademarks or registered trademarks of Vegalake Inc.

On this page