Built-in Functions
Reference index of 415 built-in functions in DeltaForge: complete catalogue grouped by category, each linking to detailed syntax and examples.
collection
conditional
datetime
- ADD_MONTHSAdd (or subtract) a number of months to a date, clamping to the end of the month when needed.
- AGECompute a symbolic year-month-day interval between two timestamps.
- CLOCK_TIMESTAMPReturn the actual wall-clock timestamp, re-read on every call.
- CURRENT_DATEReturn the current session date with no time component.
- CURRENT_TIMEReturn the current time-of-day with time zone information.
- CURRENT_TIMESTAMPReturn the current date and time, fixed at transaction start.
- DATEDIFFReturn the number of whole days between two dates as end minus start.
- DATE_ADDAdd (or subtract) a signed number of days to a date.
- DATE_BINBin a timestamp into uniform-width intervals aligned to a chosen origin.
- DATE_DIFFReturn the difference between two dates or timestamps in a specified unit.
- DATE_FORMATFormat a date or timestamp as a string using percent-prefixed pattern tokens.
- DATE_PARTExtract a named field from a date, timestamp, or interval (functional form of EXTRACT).
- DATE_SUBSubtract a signed number of days from a date.
- DATE_TRUNCTruncate a timestamp down to the start of a specified unit (year, month, day, hour, etc.).
- DAYOFMONTHExtract the day-of-month (1 through 31) from a date.
- DAYOFWEEKExtract the day-of-week number from a date, with Sunday as 1 and Saturday as 7.
- DAYOFYEARExtract the ordinal day of the year (1 through 366) from a date.
- DAYS_BETWEENReturn the number of whole days between two dates as date1 minus date2.
- EXTRACTExtract a named field from a date, timestamp, or interval using SQL-standard syntax.
- EXTRACT_EPOCHExtract seconds since 1970-01-01 UTC from a timestamp, or total duration in seconds from an interval.
- FROM_UNIXTIMEConvert a Unix epoch seconds value into a formatted date-time string.
- HOURExtract the hour-of-day (0 through 23) from a timestamp.
- INTERVAL_MULTIPLYMultiply an INTERVAL by a numeric factor to scale its duration.
- ISFINITETest whether a date, timestamp, or interval value is finite (not positive or negative infinity).
- JUSTIFY_DAYSNormalize an INTERVAL so the days component stays below 30 by rolling excess days into months.
- JUSTIFY_HOURSNormalize an INTERVAL so the hours component stays below 24 by rolling excess hours into days.
- JUSTIFY_INTERVALNormalize an INTERVAL by rolling excess hours into days and excess days into months.
- LAST_DAYReturn the last day of the month that contains the given date.
- LOCALTIMEReturn the current time-of-day without time zone information.
- LOCALTIMESTAMPReturn the current date and time without time zone information.
- MAKE_DATEConstruct a DATE from integer year, month, and day components.
- MAKE_INTERVALConstruct an INTERVAL value from optional year, month, week, day, hour, minute, and second components.
- MAKE_TIMEConstruct a TIME value from hour, minute, and second components.
- MAKE_TIMESTAMPConstruct a TIMESTAMP WITHOUT TIME ZONE from year, month, day, hour, minute, and second components.
- MAKE_TIMESTAMPTZConstruct a TIMESTAMP WITH TIME ZONE from components with an optional zone name.
- MINUTEExtract the minute-of-hour (0 through 59) from a timestamp.
- MONTHExtract the month component (1 through 12) from a date or timestamp.
- MONTHS_BETWEENReturn the number of months between two dates, including a fractional part when days differ.
- NEXT_DAYReturn the next date strictly after the input that falls on the specified weekday.
- NOWReturn the current transaction timestamp, identical to CURRENT_TIMESTAMP.
- QUARTERExtract the calendar quarter (1 through 4) from a date or timestamp.
- SECONDExtract the whole-second component (0 through 59) from a timestamp.
- STATEMENT_TIMESTAMPReturn the timestamp captured at the start of the current statement.
- TIMEOFDAYReturn the current wall-clock date and time as a formatted text string.
- TO_CHARFormat a date, timestamp, interval, or numeric value as a string using template patterns.
- TO_DATEParse a string into a DATE using an explicit or default format pattern.
- TO_TIMESTAMPParse a string into a TIMESTAMP, or convert an epoch-seconds number into a TIMESTAMP.
- TO_UNIX_TIMESTAMPConvert a TIMESTAMP value into Unix epoch seconds.
- TRANSACTION_TIMESTAMPReturn the timestamp captured at the start of the current transaction.
- TRUNCTruncate a DATE to the start of a specified calendar unit.
- UNIX_TIMESTAMPReturn the current Unix epoch seconds, or parse a string and return its epoch seconds.
- WEEKOFYEARExtract the ISO 8601 week number (1 through 53) from a date.
- YEARExtract the four-digit year component from a date or timestamp.
- YEARS_BETWEENReturn the number of whole completed years between two dates.
encoding
geospatial
h3
hash
json
math
- ABSReturn the absolute value of a numeric expression.
- ACOSCompute the inverse cosine (arccosine) of a value, returning an angle in radians.
- ACOSHCompute the inverse hyperbolic cosine of a real number at least 1.
- ASINCompute the inverse sine (arcsine) of a value, returning an angle in radians.
- ASINHCompute the inverse hyperbolic sine of a real number.
- ATANCompute the inverse tangent (arctangent) of a value, returning an angle in radians.
- ATAN2Compute the two-argument arctangent, returning the angle of the point (x, y) in radians.
- ATANHCompute the inverse hyperbolic tangent, defined on the open interval (-1, 1).
- BROUNDRound a numeric value using banker's rounding (round half to even).
- CBRTCompute the real cube root of a numeric expression, including negative values.
- CEILRound up to the smallest integer greater than or equal to the input.
- CEILINGRound up to the smallest integer greater than or equal to the input (alias for CEIL).
- COSCompute the cosine of an angle expressed in radians.
- COSHCompute the hyperbolic cosine of a real number.
- COTCompute the cotangent of an angle expressed in radians.
- CSCCompute the cosecant (reciprocal of sine) of an angle in radians.
- DEGREESConvert an angle from radians to degrees.
- EReturn the mathematical constant e (Euler's number, approximately 2.71828).
- EXPCompute e raised to the given power.
- EXPM1Compute e^x - 1 with high precision for small x.
- FLOORRound down to the largest integer less than or equal to the input.
- HYPOTCompute sqrt(x*x + y*y) without intermediate overflow or underflow.
- LNCompute the natural logarithm (base e) of a positive number.
- LOGCompute the logarithm with a specified base (defaults to natural logarithm).
- LOG10Compute the base-10 (common) logarithm of a positive number.
- LOG1PCompute ln(1 + x) with high precision for small x.
- LOG2Compute the base-2 (binary) logarithm of a positive number.
- MODReturn the remainder of dividing one number by another (truncated division, sign follows dividend).
- NEGATIVEReturn the arithmetic negation of a numeric expression.
- PIReturn the mathematical constant pi (approximately 3.14159265358979).
- PMODReturn the non-negative remainder of dividing one number by another.
- POSITIVEReturn the input unchanged (unary plus as a function form).
- POWRaise a base to the given exponent.
- POWERRaise a base to the given exponent (alias for POW).
- PYTHON_ROUNDRound a numeric value using Python / IEEE 754 semantics (round half to even).
- RADIANSConvert an angle from degrees to radians.
- RINTRound to the nearest integer, returning a DOUBLE, using banker's rounding.
- ROUNDRound a numeric value to a specified number of decimal places using half-up (away-from-zero) rounding.
- SECCompute the secant (reciprocal of cosine) of an angle in radians.
- SIGNReturn the sign of a number as -1, 0, or 1.
- SIGNUMReturn the sign of a number as a DOUBLE: -1.0, 0.0, or 1.0 (alias for SIGN).
- SINCompute the sine of an angle expressed in radians.
- SINHCompute the hyperbolic sine of a real number.
- SQRTCompute the non-negative square root of a non-negative number.
- TANCompute the tangent of an angle expressed in radians.
- TANHCompute the hyperbolic tangent, a smooth saturating function bounded by -1 and 1.
misc
- BIT_ANDReturn the bitwise AND of two integer values.
- BIT_COUNTReturn the number of bits set to 1 in an integer (population count).
- BIT_NOTReturn the bitwise complement of an integer value.
- BIT_ORReturn the bitwise OR of two integer values.
- BIT_XORReturn the bitwise exclusive OR of two integer values.
- CLEAN_SPACESCollapse runs of whitespace into a single space and trim leading/trailing whitespace.
- CURRENT_CATALOGReturn the name of the catalog (top-level database) bound to the current session.
- CURRENT_DATABASEReturn the current database name (synonym for CURRENT_CATALOG).
- CURRENT_SCHEMAReturn the name of the schema (namespace) bound to the current session.
- CURRENT_SETTINGReturn the current value of a named configuration parameter.
- CURRENT_USERReturn the effective user name for the current session.
- EMPTYIFNULLReturn an empty string if the input is NULL, otherwise return the input unchanged.
- FORMAT_NUMBERFormat a numeric value as a thousands-separated string with a fixed number of decimal places.
- FORMAT_STRINGFormat a string using printf-style placeholders (alias for PRINTF).
- GENERATE_SERIESReturn a table of values from start to stop, incremented by step.
- GEN_RANDOM_UUIDGenerate a new random UUID (version 4).
- GET_BITReturn the value (0 or 1) of the bit at the given position in an integer or binary value.
- IBAN_CHECKReturn true if the input string is a valid International Bank Account Number.
- IFFReturn one of two values based on a boolean condition (alias for IIF).
- IIFReturn one of two values based on a boolean condition.
- INET_CLIENT_ADDRReturn the IP address of the client that opened the current session.
- INET_SERVER_ADDRReturn the IP address of the server that accepted the current session.
- INPUT_FILE_NAMEReturn the path of the underlying data file from which the current row was read.
- IS_DATEReturn true if the input string can be parsed as a valid calendar date.
- IS_DISTINCT_FROMReturn true if the two operands differ, treating NULL as equal to NULL.
- IS_EMAILReturn true if the input string is a syntactically valid email address.
- IS_INTEGERReturn true if the input string parses as a signed integer with no fractional part.
- IS_IPV4Return true if the input string is a valid dotted-decimal IPv4 address.
- IS_IPV6Return true if the input string is a valid IPv6 address.
- IS_NOT_DISTINCT_FROMReturn true if the two operands are equal, treating NULL as equal to NULL.
- IS_NUMERICReturn true if the input string parses as a signed integer or decimal number.
- IS_UUIDReturn true if the input string is a valid UUID.
- IS_VALID_JSONReturn true if the input string is a well-formed JSON value.
- LUHN_CHECKReturn true if the input digit string passes the Luhn (mod-10) checksum.
- MASK_CREDIT_CARDRedact a credit card number for display while preserving the last four digits.
- MASK_EMAILRedact an email address for display while preserving the domain.
- MASK_PHONERedact a phone number for display while preserving the last four digits.
- MASK_SSNRedact a Social Security Number for display while preserving the last four digits.
- MONOTONICALLY_INCREASING_IDGenerate a 64-bit integer id that is unique and strictly increasing within a single query execution.
- NULLIFEMPTYReturn NULL if the input string is empty, otherwise return the input unchanged.
- NULLIFZEROReturn NULL if the input is zero, otherwise return the input unchanged.
- NUM_NONNULLSReturn the count of non-NULL arguments in a variadic argument list.
- NUM_NULLSReturn the count of NULL arguments in a variadic argument list.
- PG_BACKEND_PIDReturn the process id of the backend serving the current session.
- PG_COLUMN_SIZEReturn the number of bytes used to store a value in its internal representation.
- PG_CONF_LOAD_TIMEReturn the timestamp when the server configuration was last loaded.
- PG_INPUT_IS_VALIDReturn true if the input string can be cast to the specified data type without error.
- PG_POSTMASTER_START_TIMEReturn the timestamp at which the server process started.
- PG_SIZE_PRETTYFormat a byte count as a human-readable size string (bytes, kB, MB, GB, TB).
- PG_SLEEPPause the current session for a given number of seconds.
- PG_TYPEOFReturn the PG-compat data type name of an expression.
- PRINTFFormat a string using printf-style placeholders (alias for FORMAT_STRING).
- RANGE_INTERSECTReturn the overlapping portion of two ranges, or an empty range if they do not overlap.
- RANGE_MERGEReturn the smallest range that spans both input ranges.
- REMOVE_ACCENTSStrip diacritical marks from the input string, producing plain ASCII where possible.
- ROW_NUMBER_GENERATEGenerate a dense, 1-based row number for each row in the result set.
- SESSION_USERReturn the original authenticated user name for the current session.
- SET_BITReturn a copy of the input value with the bit at the given position set to 0 or 1.
- SET_CONFIGSet a configuration parameter for the session or transaction and return the new value.
- SHA224Compute the SHA-224 hash of a string and return it as a 56-character lowercase hexadecimal string.
- SHA256Compute the SHA-256 hash of a string and return it as a 64-character lowercase hexadecimal string.
- SHA384Compute the SHA-384 hash of a string and return it as a 96-character lowercase hexadecimal string.
- SHA512Compute the SHA-512 hash of a string and return it as a 128-character lowercase hexadecimal string.
- SLUGIFYConvert the input string to a lowercase, hyphen-separated, URL-safe slug.
- SPARK_PARTITION_IDReturn the id of the physical partition that produced the current row.
- STACKReshape a flat list of values into n rows of equal-width tuples.
- TO_CAMEL_CASEConvert the input string to lowerCamelCase.
- TO_SNAKE_CASEConvert the input string to snake_case.
- TO_TITLE_CASEConvert the input string to Title Case.
- TRY_CAST_BOOLAttempt to cast a value to BOOLEAN, returning NULL on failure instead of raising an error.
- TRY_CAST_FLOATAttempt to cast a value to FLOAT (DOUBLE), returning NULL on failure instead of raising an error.
- TRY_CAST_INTAttempt to cast a value to INT, returning NULL on failure instead of raising an error.
- TXID_CURRENTReturn the identifier of the current transaction.
- TYPEOFReturn the dialect-neutral data type name of an expression.
- UUIDGenerate a new random UUID (version 4).
- UUID_GENERATE_V4Generate a new random UUID (version 4).
- VERSIONReturn a human-readable string describing the engine version.
- ZEROIFNULLReturn 0 if the input is NULL, otherwise return the input unchanged.
numeric
regex
string
- ARRAY_TO_STRINGConcatenate array elements into a string with a delimiter, optionally replacing NULL elements.
- ASCIIReturn the Unicode code point of the first character of the input string.
- BIT_LENGTHReturn the number of bits in the input string's UTF-8 encoding.
- BTRIMStrip a custom character set from both ends of the input string, defaulting to whitespace.
- CHARReturn the character corresponding to the given Unicode code point.
- CHARACTER_LENGTHReturn the number of characters in the input string (alias of CHAR_LENGTH).
- CHAR_LENGTHReturn the number of characters in the input string.
- CHRReturn the character corresponding to the given Unicode code point (alias of CHAR).
- CONCAT_WSConcatenate arguments with a separator, skipping any NULL arguments.
- CONTAINSReturn true when the input string contains the given substring, false otherwise.
- DIFFERENCEReturn a 0-4 similarity score comparing the Soundex codes of two strings.
- ENDSWITHReturn true when the input string ends with the given suffix, false otherwise.
- ENDS_WITHReturn true when the input string ends with the given suffix, false otherwise.
- FORMATBuild a formatted string by substituting arguments into a format template.
- INITCAPReturn the input string with the first letter of each word capitalised and every other letter lowercased.
- INSTRReturn the 1-based position of the first occurrence of a substring, or 0 if not found.
- IS_NORMALIZEDReturn true when the input string is already in the specified Unicode normalization form.
- LEFTReturn the leftmost n characters of the input string.
- LENGTHReturn the number of characters in the input string.
- LEVENSHTEINCompute the minimum single-character edit distance between two strings.
- LOWERReturn the input string with every character converted to its lowercase equivalent.
- LPADPad the input string on the left with a repeating pad sequence until it reaches a target length.
- LTRIMRemove leading whitespace from the input string.
- NORMALIZEConvert the input string to the specified Unicode normalization form.
- OCTET_LENGTHReturn the number of bytes in the input string's UTF-8 encoding.
- OVERLAYReplace a range of characters in a string with a replacement substring (SQL-standard PLACING/FROM/FOR syntax).
- PARSE_IDENTSplit a dot-separated qualified SQL identifier into its component parts.
- POSITIONReturn the 1-based position of the first occurrence of a substring (SQL-standard IN syntax).
- QUOTE_IDENTWrap a string in double quotes so it is safe to use as a SQL identifier in dynamic SQL.
- QUOTE_LITERALWrap a string in single quotes so it is safe to use as a SQL string literal in dynamic SQL.
- QUOTE_NULLABLEQuote a string as a SQL literal, returning the unquoted keyword NULL when the input is NULL.
- REPEATReturn the input string repeated n times.
- REPLACESubstitute every literal occurrence of a search substring with a replacement string.
- REVERSEReverse the order of characters in a string, or the order of elements in an array.
- RIGHTReturn the rightmost n characters of the input string.
- RPADPad the input string on the right with a repeating pad sequence until it reaches a target length.
- RTRIMRemove trailing whitespace from the input string.
- SOUNDEXReturn the Soundex phonetic code for a string (one uppercase letter followed by three digits).
- SPACEReturn a string consisting of n space characters.
- SPLITSplit the input string by a literal delimiter and return the parts as an array.
- SPLIT_PARTSplit the input string by a literal delimiter and return the nth part.
- STARTSWITHReturn true when the input string begins with the given prefix, false otherwise.
- STARTS_WITHReturn true when the input string begins with the given prefix, false otherwise.
- STRING_AGGAggregate non-NULL values into a delimited string across grouped rows.
- STRING_TO_ARRAYSplit the input string by a literal delimiter, optionally mapping a sentinel to NULL.
- STRPOSReturn the 1-based position of the first occurrence of a substring, or 0 if not found.
- SUBSTRExtract a contiguous slice of characters from the input string (alias of SUBSTRING).
- SUBSTRINGExtract a contiguous slice of characters from the input string by 1-based position and length.
- SUBSTRING_INDEXReturn the portion of a string before or after the nth occurrence of a delimiter.
- TO_ASCIITransliterate non-ASCII characters to their closest ASCII equivalents.
- TO_HEXReturn the lowercase hexadecimal string representation of an integer.
- TRANSLATEReplace or delete individual characters in a string using a positional character mapping.
- TRIMRemove leading and trailing whitespace from the input string.
- UPPERReturn the input string with every character converted to its uppercase equivalent.
time-travel