Scalar Functions

HoraeDB SQL is implemented with DataFusion, Here is the list of scalar functions. See more detail, Refer to Datafusion

Math Functions

FunctionDescription
abs(x)absolute value
acos(x)inverse cosine
asin(x)inverse sine
atan(x)inverse tangent
atan2(y, x)inverse tangent of y / x
ceil(x)nearest integer greater than or equal to argument
cos(x)cosine
exp(x)exponential
floor(x)nearest integer less than or equal to argument
ln(x)natural logarithm
log10(x)base 10 logarithm
log2(x)base 2 logarithm
power(base, exponent)base raised to the power of exponent
round(x)round to nearest integer
signum(x)sign of the argument (-1, 0, +1)
sin(x)sine
sqrt(x)square root
tan(x)tangent
trunc(x)truncate toward zero

Conditional Functions

FunctionDescription
coalesceReturns the first of its arguments that is not null. Null is returned only if all arguments are null. It is often used to substitute a default value for null values when data is retrieved for display.
nullifReturns a null value if value1 equals value2; otherwise it returns value1. This can be used to perform the inverse operation of the coalesce expression.

String Functions

FunctionDescription
asciiReturns the numeric code of the first character of the argument. In UTF8 encoding, returns the Unicode code point of the character. In other multibyte encodings, the argument must be an ASCII character.
bit_lengthReturns the number of bits in a character string expression.
btrimRemoves the longest string containing any of the specified characters from the start and end of string.
char_lengthEquivalent to length.
character_lengthEquivalent to length.
concatConcatenates two or more strings into one string.
concat_wsCombines two values with a given separator.
chrReturns the character based on the number code.
initcapCapitalizes the first letter of each word in a string.
leftReturns the specified leftmost characters of a string.
lengthReturns the number of characters in a string.
lowerConverts all characters in a string to their lower case equivalent.
lpadLeft-pads a string to a given length with a specific set of characters.
ltrimRemoves the longest string containing any of the characters in characters from the start of string.
md5Calculates the MD5 hash of a given string.
octet_lengthEquivalent to length.
repeatReturns a string consisting of the input string repeated a specified number of times.
replaceReplaces all occurrences in a string of a substring with a new substring.
reverseReverses a string.
rightReturns the specified rightmost characters of a string.
rpadRight-pads a string to a given length with a specific set of characters.
rtrimRemoves the longest string containing any of the characters in characters from the end of string.
digestCalculates the hash of a given string.
split_partSplits a string on a specified delimiter and returns the specified field from the resulting array.
starts_withChecks whether a string starts with a particular substring.
strposSearches a string for a specific substring and returns its position.
substrExtracts a substring of a string.
translateTranslates one set of characters into another.
trimRemoves the longest string containing any of the characters in characters from either the start or end of string.
upperConverts all characters in a string to their upper case equivalent.

Regular Expression Functions

FunctionDescription
regexp_matchDetermines whether a string matches a regular expression pattern.
regexp_replaceReplaces all occurrences in a string of a substring that matches a regular expression pattern with a new substring.

Temporal Functions

FunctionDescription
to_timestampConverts a string to type Timestamp(Nanoseconds, None).
to_timestamp_millisConverts a string to type Timestamp(Milliseconds, None).
to_timestamp_microsConverts a string to type Timestamp(Microseconds, None).
to_timestamp_secondsConverts a string to type Timestamp(Seconds, None).
extractRetrieves subfields such as year or hour from date/time values.
date_partRetrieves subfield from date/time values.
date_truncTruncates date/time values to specified precision.
date_binBin date/time values to specified precision.
from_unixtimeConverts Unix epoch to type Timestamp(Nanoseconds, None).
nowReturns current time as Timestamp(Nanoseconds, UTC).

Other Functions

FunctionDescription
arrayCreate an array.
arrow_typeofReturns underlying type.
in_listCheck if value in list.
randomGenerate random value.
sha224sha224
sha256sha256
sha384sha384
sha512sha512
to_hexConvert to hex.