Skip to content

Function List

Supported Data Sources: presto, impala, hive, spark, greenplum, oracle, postgresql, redshift, sqlserver, tidb, mysql, db2, mongodb, maxcompute

Numeric Functions

Function NameDescriptionParameter DescriptionReturn TypeUnsupported Data Sources
abs(N)Absolute value operation. For example: abs(-1), returns the number type: 1Numeric type parameter, optional types: NUMBERNUMBER
ceil(N)Get the smallest integer value greater than or equal to the specified valueNumeric type parameter, optional types: NUMBERNUMBER
floor(N)Get the largest integer value less than or equal to the specified valueNumeric type parameter, optional types: NUMBERNUMBER
median(N)Get the median of the specified numeric columnNumeric type parameter, optional types: NUMBERNUMBERimpala hive spark
sqlserver tidb mysql
mod(DIVIDEND,DIVISOR)Modulo operation, parameters can be decimals. For example: mod(12.3, 5), returns the number type: 2.31. Dividend, optional types: NUMBER; 2. Divisor, optional types: NUMBERNUMBER
growth_rate(CURRENT,PREVIOUS)Growth rate1. New value, optional types: NUMBER;
2. Previous value, optional types: NUMBER
NUMBER
percentile(N,PERCENT)Calculate the percentile1. Numeric type parameter, optional types: NUMBER;
2. Internal parameter, optional types: NUMBER
NUMBERimpala hive spark
sqlserver tidb mysql
mongodb maxcompute
power(BASE,EXPONENT)Power operation. For example: power(2,3), returns the number type: 81. Base, optional types: NUMBER;
2. Exponent, optional types: NUMBER
NUMBER
round(N,LITERAL_PRECISION)Round to the specified number of digits1. Numeric type parameter, optional types: NUMBER;
2. Specified precision, optional types: NUMBER
NUMBER
sign(N)Sign function. For example: sign(x), if x>0, returns 1; if x=0, returns 0; if x<0, returns -1Numeric type parameter, optional types: NUMBERNUMBER
sqrt(N)Square root operationNumeric type parameter, optional types: NUMBERNUMBER
cbrt(N)Cube root operationNumeric type parameter, optional types: NUMBERNUMBERmysql oracle sqlserver
db2 impala tidb
mongodb
acos(N)Returns the arccosine of N, in radians, N must be a value between [-1, 1], for example: acos(0.5) = 1.0471975511966Numeric type parameter, optional types: NUMBERNUMBER
asin(N)Returns the arcsine of N, in radians, N must be a value between [-1, 1], for example: asin(0.5) = 0.523598775598299Numeric type parameter, optional types: NUMBERNUMBER
atan(N)Returns the arctangent of N, in radians, for example: atan(1) = 0.785398163397448Numeric type parameter, optional types: NUMBERNUMBER
atan2(ARG1, ARG2)Returns the arctangent of arg1/arg2, in radians, for example: atan2(2, 2) = 0.785398163397448Numeric type parameter, optional types: NUMBERNUMBERhive
cos(N)Returns the cosine of N, N is in radians, for example: cos(pi()/3) = 0.5Numeric type parameter, optional types: NUMBERNUMBER
cot(N)Returns the cotangent of N, N is in radians, N cannot be 0, for example: cot(pi()/4) = 1Numeric type parameter, optional types: NUMBERNUMBER
sin(N)Returns the sine of N, N is in radians, for example: sin(pi()/6) = 0.5Numeric type parameter, optional types: NUMBERNUMBER
tan(N)Returns the tangent of N, N is in radians, for example: tan(pi()/4) = 1Numeric type parameter, optional types: NUMBERNUMBER
cosh(N)Returns the hyperbolic cosine of N, for example: cosh(1) = 1.5430806348152437Numeric type parameter, optional types: NUMBERNUMBERpostgres greenplum mysql
sqlserver hive tidb
mongodb redshift
sinh(N)Returns the hyperbolic sine of N, for example: sinh(1) = 0.8686709614860095Numeric type parameter, optional types: NUMBERNUMBERpostgres greenplum mysql
sqlserver hive tidb
presto mongodb redshift
tanh(N)Returns the hyperbolic tangent of N, for example: tanh(1) = 0.7615941559557649Numeric type parameter, optional types: NUMBERNUMBERpostgres greenplum mysql
sqlserver hive tidb
mongodb redshift
degrees(N)Converts radians to degrees, N is in radiansNumeric type parameter, optional types: NUMBERNUMBERoracle
radians(N)Converts degrees to radians, N is in degreesNumeric type parameter, optional types: NUMBERNUMBERoracle
pi()π constant, equal to 3.14159265358979NUMBERorace db2
exp(N)e raised to the power of N, e is the base of the natural logarithm, exp(1) = 2.171828182845904Numeric type parameter, optional types: NUMBERNUMBER
ln(N)Returns the natural logarithm of N, the natural logarithm is based on the constant e(2.71828182845904), N must be greater than 0, for example: ln(1) = 0Numeric type parameter, optional types: NUMBERNUMBER
log(BASE, N)Returns the logarithm of N with BASE as the base, BASE must be greater than 0 and not equal to 1, N must be greater than 0, for example: log(3, 9) = 2BASE, optional types: NUMBER
N, optional types: NUMBER
NUMBERdb2 redshift
log2(N)Returns the logarithm of N with 2 as the base, N must be greater than 0, for example: log2(4) = 2Numeric type parameter, optional types: NUMBERNUMBERdb2 redshift
log10(N)Returns the logarithm of N with 10 as the base, N must be greater than 0, for example: log10(100) = 2Numeric type parameter, optional types: NUMBERNUMBER
rand()Random value in the range 0.0 <= N < 1.0NUMBER
greatest(ARG1, ARG2)Returns the largest value in the listARG1: Numeric type parameter, optional types: NUMBER
ARG2: Numeric type parameter, optional types: NUMBER
NUMBER
least(ARG1, ARG2)Returns the smallest value in the listARG1: Numeric type parameter, optional types: NUMBER
ARG2: Numeric type parameter, optional types: NUMBER
NUMBER

String Functions

Function NameDescriptionParameter DescriptionReturn TypeUnsupported Data Sources
concat(S1,S2,S3...)Concatenate multiple parameters as text together. For example: concat('abc', 123), returns the string type: 'abc123'Text type parameter, optional types: STRINGSTRING
initcap(S)Format the specified string, capitalize the first letter of each word in the string, and convert other letters to lowercaseText type parameter, optional types: STRINGSTRINGtidb mongodb
length(S)Calculate the length of the stringText type parameter, optional types: STRINGNUMBER
lower(S)Convert all characters of the specified string to lowercaseText type parameter, optional types: STRINGSTRING
position(S,PATTERN)Get the position of the first occurrence of the substring in the specified string1. Text type parameter, optional types: STRING;
2. Internal parameter, optional types: STRING
NUMBER
to_string(ARG)Convert the input field or value to textParameter involved in the calculation, optional types: ANYSTRING
trim(S)Remove spaces at the beginning and end of the stringText type parameter, optional types: STRINGSTRING
replace(s,s1,s2)Replace string. Usage replace(s, s1, s2), s2 replaces all occurrences of s1 in s.1. Text type parameter, optional types: STRING2;
2. First text parameter, optional types: STRING;
3. Second text parameter, optional types: STRING
STRING
substring(S,START,LENGTH)Extract substring. Usage substring(s, start, length), start is 1-based.1. Text type parameter, optional types: STRING;
2. Specified start, optional types: NUMBER;
3. Specified length, optional types: NUMBER
STRING
upper(S)Convert all characters of the specified string to uppercaseText type parameter, optional types: STRINGSTRING
unlike(S,LITERAL_PATTERN)The specified field does not contain specific text1. Text type parameter, optional types: STRING;
2. Specified pattern, optional types: STRING
BOOL
like(S,LITERAL_PATTERN)The specified field contains specific text1. Text type parameter, optional types: STRING;
2. Specified pattern, optional types: STRING
BOOL
TRIM(s)Remove spaces at the beginning and end of the specified string. Example:
TRIM({usertype})
TRIM(' X '))
STRING typeReturns the string typeSupported data sources include: Athena, Clickhouse, Dameng, Db2, Postgresql, Greenplum, Spark, Hologres, Impala, Kylin, Maxcompute, Mysql, Mongodb, Oracle, Presto, Redshift, Saphana, Sqlserver, Tidb, Vertica
ltrim(s1, s2)This function searches for content in the s1 string starting from the beginning that matches the s2 string, stops searching when the content does not match the s2 string, and deletes the found content. Example ltrim('abcbabca','ab'), returns the result as cbabca.Parameter 1: string type.
Parameter 2: string type.
Returns the string type.Supported data sources: Athena, Clickhouse, Dameng, Db2, Postgresql, Greenplum, Spark, Hologres, Impala, Kylin, Maxcompute, Mysql, Mongodb, Oracle, Presto, Redshift, Saphana, Sqlserver, Tidb, Vertica
rtrim(s1, s2)This function searches for content in the s1 string starting from the end that matches the s2 string, stops searching when the content does not match the s2 string, and deletes the found content. Example: rtrim('abadcdabab','ab') returns the value as abadcd.Parameter 1: string type.
Parameter 2: string type.
Returns the string type.Supported data sources: Athena, Clickhouse, Dameng, Db2, Postgresql, Greenplum, Spark, Hologres, Impala, Kylin, Maxcompute, Mysql, Mongodb, Oracle, Presto, Redshift, Saphana, Sqlserver, Tidb, Vertica
split(s, delimiter, n)This function splits the string s by the delimiter and returns the nth (starting from 1) string after splitting. For example, split('abc,abc,abcdef',',',3), returns the string abcdef.Parameter 1: string type.
Parameter 2: string type.
Parameter 3: int type.
Returns the string type.Supported data sources: Athena, Clickhouse, Doris, Postgresql, Greenplum, Spark, Hive, Hologres, Impala, Maxcompute, Mysql, Mongodb, Phoenix, Presto, Redshift, Tidb, Vertica
regexp_extract(s, regexp, index)This function splits the string s according to the rules of the regular expression regexp and returns the character specified by indexParameter 1: string type.
Parameter 2: string type.
Parameter 3: int type.
Returns the string type.Supported data sources:Athena, Doris, Postgresql, Spark, Hive, Hologres, Impala, Presto
regexp_match(s, regexp)Determines whether the string s matches the regular expression regexp pattern. Returns TRUE if the match is successful, and FALSE if the match fails.Parameter 1: string type.
Parameter 2: string type.
Returns the bool type.Supported data sources: Athena, Clickhouse, Dameng, Db2, Doris, Postgresql, Greenplum, Spark, Hive, Hologres, Impala, Maxcompute, Mysql, Mongodb, Oracle, Presto, Redshift, Saphana, Tidb, Vertica
regexp_replace(s, regexp, replacement)Replaces the characters in the string s that match the regular expression regexp with the specified string replacement.Parameter 1: string type.
Parameter 2: string type.
Parameter 3: string type.
Returns the string type.Supported data sources:Athena, Clickhouse, Dameng, Db2, Doris, Postgresql, Greenplum, Spark, Hive, Hologres, Impala, Maxcompute, Mysql, Oracle, Phoenix, Presto, Redshift, Vertica

Window Functions

Function NameDescriptionParameter DescriptionReturn TypeUnsupported Data Sources
row_number()Window function, returns the row number of the current window, counting from 1 and incrementing sequentially without repetition, such as 1, 2, 3, 4. Usage: row_number() OVER( [ PARTITION BY expr1 ] ORDER BY expr2 [ DESC ] )NUMBERimpala hive skqrk
oracle tidb mysql
mongodb
rank()Window function, returns the rank of the current window (maintaining gaps), counting from 1, with the same rank numbers for ties, and subsequent ranks skipping, such as 1, 2, 2, 4. Usage: rank() OVER( [ PARTITION BY expr1 ] ORDER BY expr2 [ DESC ] )NUMBERimpala hive
skqrk tidb mysql
mongodb
dense_rank()Window function, returns the rank of the current window (without maintaining gaps), counting from 1, with the same rank numbers for ties, and subsequent ranks not skipping, such as 1, 2, 2, 3. Usage: dense_rank() OVER( [ PARTITION BY expr1 ] ORDER BY expr2 [ DESC ] )NUMBERimpala hive
skqrk tidb mysql
mongodb
lag(ARG,I)Window function, retrieves the arg data of the record that is i distance before the current record1. Parameter involved in the calculation, optional type: ANY;
2. Integer type parameter, optional type: NUMBER
ANYimpala hive
skqrk tidb mysql
mongodb
lead(ARG,I)Window function, retrieves the arg data of the record that is i distance after the current record1. Parameter involved in the calculation, optional type: ANY;
2. Integer type parameter, optional type: NUMBER
ANYimpala hive
skqrk tidb mysql
mongodb

Date Functions

Function NameDescriptionParameter DescriptionReturn TypeUnsupported Data Sources
add_day(T,I)Returns the date after the number of days specified by the numeric field from the start date, or the date before the number of days if the numeric field is negative. For example: add_day('2018-02-02',3), returns date type: 2018-02-051. Date type parameter, optional type: DATE;
2. Integer type parameter, optional type: NUMBER
DATE
add_hour(T,I)Returns the time after the number of hours specified by the numeric field from the start time, or the time before the number of hours if the numeric field is negative. For example: add_hour('2018-02-02 08:30:00.000',3), returns date type: 2018-02-02 11:30:00.0001. Date type parameter, optional type: DATE;
2. Integer type parameter, optional type: NUMBER
DATE
add_minute(T,I)Returns the time after the number of minutes specified by the numeric field from the start time, or the time before the number of minutes if the numeric field is negative. For example: add_minute('2018-02-02 08:30:00.000',3), returns date type: 2018-02-02 08:33:00.0001. Date type parameter, optional type: DATE;
2. Integer type parameter, optional type: NUMBER
DATE
add_month(T,I)Returns the date after the number of months specified by the numeric field from the start date, or the date before the number of months if the numeric field is negative. For example: add_month('2018-02-02',3), returns date type: 2018-05-021. Date type parameter, optional type: DATE;
2. Integer type parameter, optional type: NUMBER
DATE
add_quarter(T,I)Returns the date after the number of quarters specified by the numeric field from the start date, or the date before the number of quarters if the numeric field is negative. For example: add_quarter('2018-02-02',3), returns date type: 2018-05-021. Date type parameter, optional type: DATE;
2. Integer type parameter, optional type: NUMBER
DATE
add_week(T,I)Returns the date after the number of weeks specified by the numeric field from the start date, or the date before the number of weeks if the numeric field is negative. For example: add_week('2018-02-02',3), returns date type: 2018-05-021. Date type parameter, optional type: DATE;
2. Integer type parameter, optional type: NUMBER
DATE
add_year(T,I)Returns the date after the number of years specified by the numeric field from the start date, or the date before the number of years if the numeric field is negative. For example: add_year('2018-02-02',3), returns date type: 2021-02-021. Date type parameter, optional type: DATE;
2. Integer type parameter, optional type: NUMBER
DATE
add_year_keep_woy(T,I)Similar to add_year, but adjusts the date to keep the week of the year unchanged1. Date type parameter, optional type: DATE;
2. Integer type parameter, optional type: NUMBER
DATEmysql tidb
sqlserver redshift spark
hive impala presto
db2 mongodb maxcompute
diff_in_day(START,END)Compares the difference in days between two dates. For example: diff_in_day('2015-02-03', '2018-02-03'), returns integer type: 10951. Specify start, optional type: DATE;
2. Specify end, optional type: DATE
NUMBER
diff_in_hour(START,END)Compares the difference in hours between two times. For example: diff_in_hour('2015-03-24 16:32:32', '2018-02-02 12:34:43'), returns integer type: 251001. Specify start, optional type: DATE;
2. Specify end, optional type: DATE
NUMBER
diff_in_minute(START,END)Compares the difference in minutes between two times. For example: diff_in_minute('2015-03-24 16:32:32', '2018-02-02 12:34:43'), returns integer type: 15060021. Specify start, optional type: DATE;
2. Specify end, optional type: DATE
NUMBER
diff_in_month(START,END)Compares the difference in months between two dates. For example: diff_in_month('2015-02-03', '2018-02-03'), returns integer type: 361. Specify start, optional type: DATE;
2. Specify end, optional type: DATE
NUMBER
diff_in_year(START,END)Compares the difference in years between two times. For example: diff_in_year('2015-02-03', '2018-02-03'), returns integer type: 31. Specify start, optional type: DATE;
2. Specify end, optional type: DATE
NUMBER
end_of_month(T)Gets the start time of the last day of the month for the time fieldDate type parameter, optional type: DATEDATE
extract_day(T)Gets the day part of the parameter, indicating the day of the month. For example: extract_day('2018-02-02'), returns integer type: 2Date type parameter, optional type: DATENUMBER
extract_dow(T)Gets the day part of the parameter, indicating the day of the week. For example: extract_dow('2018-02-02'), returns integer type: 5Date type parameter, optional type: DATENUMBER
extract_doy(T)Gets the day part of the parameter, indicating the day of the year. For example: extract_doy('2018-02-02'), returns integer type: 33Date type parameter, optional type: DATENUMBER
extract_hour(T)Gets the hour part of the parameter, indicating the current hour. For example: extract_hour('2018-02-03 13:23:21'), returns integer type: 13Date type parameter, optional type: DATENUMBER
extract_minute(T)Gets the minute part of the parameter, indicating the current minute. For example: extract_minute('2018-02-03 13:23:21'), returns integer type: 02Date type parameter, optional type: DATENUMBER
extract_month(T)Gets the month part of the parameter. For example: extract_month('2018-02-02'), returns integer type: 2Date type parameter, optional type: DATENUMBER
extract_quarter(T)Gets the quarter part of the parameter. For example: extract_quarter('2018-02-02'), returns integer type: 1Date type parameter, optional type: DATENUMBER
extract_second(T)Gets the second part of the parameter, indicating the current second. For example: extract_second('2018-02-03 13:23:21'), returns integer type: 03Date type parameter, optional type: DATENUMBER
extract_week(T)Gets the week part of the parameter, indicating the week of the year. For example: extract_week('2018-02-02'), returns integer type: 4Date type parameter, optional type: DATENUMBER
extract_year(T)Gets the year part of the parameter. For example: extract_year('2018-02-02'), returns integer type: 2018Date type parameter, optional type: DATENUMBER
month_weekday_count(YEAR,MONTH)Gets the number of weekdays in the specified month. For example: month_weekday_count(2018, 2), returns integer type: 201. Year, optional type: NUMBER;
2. Month, optional type: NUMBER
NUMBERmysql tidb
sqlserver redshift oracle
impala hive spark
db2 mongodb
maxcompute
now()Returns the current time, date typeNo parametersDATE
parse_time(S,LITERAL_PATTERN)Parses the s parameter into a date type using the literal_pattern1. Text type parameter, optional type: STRING;
2. Specify pattern, optional type: STRING
DATEsqlserver
time_in_range(T,S)Determines whether the date is within the specified range, optional ranges include: 'Current Year', 'Current Year-to-Date', 'Current Quarter', 'Current Quarter-to-Date', 'Current Month', 'Current Month-to-Date', 'Current Week', 'Current Week-to-Date', 'Today', 'Current Hour', 'Yesterday', 'Recent 7 days', 'Recent 30 days', 'Recent 90 days', 'All Available Date', 'All Invalid Date', 'All'1. Date type parameter, optional type: DATE;
2. Text type parameter, optional type: STRING
BOOL
today()Returns the current date, date typeNo parametersDATE
trunc_day(T)Truncates the time or date column to the day. For example: trunc_day('2018-02-02 12:30:59'), returns date type: '2018-02-02'Date type parameter, optional type: DATEDATE
trunc_hour(T)Truncates the time column to the hour, all finer granularity is set to 0. For example: trunc_hour('2018-02-02 12:23:32'), returns date type: '2018-02-02 12:00:00'Date type parameter, optional type: DATEDATE
trunc_minute(T)Truncates the time column to the minute, all finer granularity is set to 0. For example: trunc_minute('2018-02-02 12:23:32'), returns date type: '2018-02-02 12:23:00'Date type parameter, optional type: DATEDATE
trunc_month(T)Truncates the time or date column to the month, the date is set to the 1st. For example: trunc_month('2018-02-02 12:23:32'), returns date type: '2018-02-01'Date type parameter, optional type: DATEDATE
trunc_millisecond(T)Truncates the time column to the millisecond, all finer granularity is set to 0. For example: trunc_millisecond('2018-02-02 12:23:32.123'), returns date type: '2018-02-02 12:23:32.123'Date type parameter, optional type: DATEDATE
trunc_quarter(T)Truncates the time or date column to the quarter, the month is set to the first month of the quarter, the date is set to the 1st. For example: trunc_quarter('2018-05-02 12:23:32'), returns date type: '2018-04-01'Date type parameter, optional type: DATEDATE
trunc_second(T)Truncates the time column to the second, all finer granularity is set to 0. For example: trunc_second('2018-02-02 12:23:32.123'), returns date type: '2018-02-02 12:23:32.000'Date type parameter, optional type: DATEDATE
trunc_week(T)Truncates the time or date column to the week, the month and date are set to the first day of the week. For example: trunc_week('2018-02-02'), returns date type: '2018-01-29'Date type parameter, optional type: DATEDATE
trunc_year(T)Truncates the time or date column to the year, the month and date are set to January 1st. For example: trunc_year('2018-02-02 12:23:32'), returns date type: '2018-01-01'Date type parameter, optional type: DATEDATE

Aggregate Functions

Function NameDescriptionParameter DescriptionReturn TypeUnsupported Data Sources
avg(N)Get the average value of the specified numeric columnNumeric type parameter, optional type: NUMBERNUMBER
count(ARG)Get the number of values in the specified columnParameter to be calculated, optional type: ANYNUMBER
distinct(ARG)Query unique values (deduplication) in the columnParameter to be calculated, optional type: ANYANY
distinct_count(ARG)Get the number of non-duplicate results in the specified columnParameter to be calculated, optional type: ANYNUMBER
max(ARG)Get the maximum value of the specified numeric columnParameter to be calculated, optional type: ANYANY
max_by(ARG, COMPARE)Get the value of the arg column corresponding to the row with the maximum value in the compare column, if there are multiple maximum values, take one randomly1. Parameter to be calculated, optional type: ANY;
2. Comparison value, optional type: ANY
ANYimpala hive
spark redshift
sqlserver tidb
mysql db2 mongodb
maxcompute
min(ARG)Get the minimum value of the specified numeric columnParameter to be calculated, optional type: ANYANY
min_by(ARG, COMPARE)Get the value of the arg column corresponding to the row with the minimum value in the compare column, if there are multiple minimum values, take one randomly1. Parameter to be calculated, optional type: ANY;
2. Comparison value, optional type: ANY
ANYimpala hive
spark redshift
sqlserver tidb
mysql db2 mongodb
maxcompute
sum(N)Get the sum of the specified numeric columnNumeric type parameter, optional type: NUMBERNUMBER
corr(ARG1, ARG2)Return the correlation coefficient of two numeric columns, e.g., (arg1, arg2) = [(1,2),(2,3),(3,4),(4,5),(5,6),(1000,1001)], corr(arg1, arg2) = 11. ARG1, optional type: NUMBER
2. ARG2, optional type: NUMBER
NUMBERmysql sqlserver impala
tidb mongodb redshift
covar_pop(ARG1, ARG2)Return the population covariance of two numeric columns, e.g., (arg1, arg2) = [(1,2),(2,3),(3,4),(4,5),(5,6),(1000,1001)], covar_pop(arg1, arg2) = 138058.472222222221. ARG1, optional type: NUMBER
2. ARG2, optional type: NUMBER
NUMBERmysql sqlserver impala
tidb mongodb redshift
covar_samp(ARG1, ARG2)Return the sample covariance of two numeric columns, e.g., (arg1, arg2) = [(1,2),(2,3),(3,4),(4,5),(5,6),(1000,1001)], covar_samp(arg1, arg2) = 165670.166666666661. ARG1, optional type: NUMBER
2. ARG2, optional type: NUMBER
NUMBERmysql sqlserver impala
tidb mongodb redshift
regr_avgx(ARG1, ARG2)Return the average of the independent variable (sum(ARG2)/N), e.g., (arg1, arg2) = [(1,2),(2,3),(3,4),(4,5),(5,6),(1000,1)], regr_avgx(arg1, arg2) = 3.51. ARG1, optional type: NUMBER
2. ARG2, optional type: NUMBER
NUMBERmysql sqlserver hive(less than 2.2)
spark impala tidb
presto mongodb redshift
regr_avgy(ARG1, ARG2)Return the average of the dependent variable (sum(ARG1)/N), e.g., (arg1, arg2) = [(1,2),(2,3),(3,4),(4,5),(5,6),(1000,1)], regr_avgy(arg1, arg2) = 3.51. ARG1, optional type: NUMBER
2. ARG2, optional type: NUMBER
NUMBERmysql sqlserver hive(less than 2.2)
spark impala tidb
presto mongodb redshift
regr_count(ARG1, ARG2)Number of input rows where both expressions are not null, e.g., (arg1, arg2) = [(1,2),(2,3),(3,4),(4,5),(5,6),(1000,1), (null, 7), (6, null)], regr_count(arg1, arg2) = 61. ARG1, optional type: NUMBER
2. ARG2, optional type: NUMBER
NUMBERmysql sqlserver hive(less than 2.2)
spark impala tidb
presto mongodb redshift
regr_intercept(ARG1, ARG2)Intercept of the linear equation of the least squares fit determined by the (arg2, arg1) pairs, e.g., (arg1, arg2) = [(1,2),(2,3),(3,4),(4,5),(5,6),(1000,1)], regr_intercept(arg1, arg2) = 665.6666666666661. ARG1, optional type: NUMBER
2. ARG2, optional type: NUMBER
NUMBERmysql sqlserver hive(less than 2.2)
spark impala tidb
mongodb redshift
regr_r2(ARG1, ARG2)Square of the correlation coefficient, e.g., (arg1, arg2) = [(1,2),(2,3),(3,4),(4,5),(5,6),(10,1)], regr_r2(arg1, arg2) = 0.063231850117096021. ARG1, optional type: NUMBER
2. ARG2, optional type: NUMBER
NUMBERmysql sqlserver hive(less than 2.2)
spark impala tidb
presto mongodb redshift
regr_slope(ARG1, ARG2)Slope of the linear equation of the least squares fit determined by the (arg2, arg1) pairs, e.g., (arg1, arg2) = [(1,2),(2,3),(3,4),(4,5),(5,6),(10,1)], regr_slope(arg1, arg2) = -0.428571428571428551. ARG1, optional type: NUMBER
2. ARG2, optional type: NUMBER
NUMBERmysql sqlserver hive(less than 2.2)
spark impala tidb
mongodb redshift
regr_sxx(ARG1, ARG2)sum(arg2^2) - sum(arg2)^2/N (sum of squares of the independent variable), e.g., (arg1, arg2) = [(1,2),(2,3),(3,4),(4,5),(5,6),(10,1)], regr_sxx(arg1, arg2) = 17.51. ARG1, optional type: NUMBER
2. ARG2, optional type: NUMBER
NUMBERmysql sqlserver hive(less than 2.2)
spark impala tidb
presto mongodb redshift
regr_sxy(ARG1, ARG2)sum(arg2 * arg1) - sum(arg2) * sum(arg1)/N (sum of products of the independent variable and the dependent variable), e.g., (arg1, arg2) = [(1,2),(2,3),(3,4),(4,5),(5,6),(10,1)], regr_sxy(arg1, arg2) = -7.51. ARG1, optional type: NUMBER
2. ARG2, optional type: NUMBER
NUMBERmysql sqlserver hive(less than 2.2)
spark impala tidb
presto mongodb redshift
regr_syy(ARG1, ARG2)sum(arg1^2) - sum(arg1)^2/N (sum of squares of the dependent variable), e.g., (arg1, arg2) = [(1,2),(2,3),(3,4),(4,5),(5,6),(10,1)], regr_syy(arg1, arg2) = 50.8333333333333361. ARG1, optional type: NUMBER
2. ARG2, optional type: NUMBER
NUMBERmysql sqlserver hive(less than 2.2)
spark impala tidb
presto mongodb redshift
stddev_pop(N)Return the population standard deviation of the numeric column, e.g., n = [(1000),(1001),(1003),(1004),(1005),(1000)], stddev_pop(n) = 1.9507833184532709Numeric type parameter, optional type: NUMBERNUMBERtidb
stddev_samp(N)Return the sample standard deviation of the numeric column, e.g., n = [(1000),(1001),(1003),(1004),(1005),(1000)], stddev_samp(n) = 2.1369760566432809Numeric type parameter, optional type: NUMBERNUMBERtidb
var_pop(N)Return the population variance of the numeric column, e.g., n = [(1000),(1001),(1003),(1004),(1005),(1000)], stddev_samp(n) = 2.1369760566432809Numeric type parameter, optional type: NUMBERNUMBERtidb mongodb
var_samp(N)Return the sample variance (square of the sample standard deviation) of the numeric column, e.g., n = [(1000),(1001),(1003),(1004),(1005),(1000)], var_samp(n) = 4.5666666666666667Numeric type parameter, optional type: NUMBERNUMBERtidb mongodb
string_agg(S, DELIMITER)Concatenate the field S into a string, separated by DELIMITER, where oracle must include the within group clause1. S: Field to be concatenated, optional type: ANY
2. DELIMITER: Separator, optional type: STRING
STRINGmysql hive sparksql
impala presto tidb
mongodb maxcompute

Other Functions

Function NameDescriptionParameter DescriptionReturn TypeUnsupported Data Sources
between(ARG,START,END)Determines if arg is within [start,end]1. Parameter to be calculated, optional type: ANY;
2. Specified start, optional type: ANY; 3. Specified end, optional type: ANY
BOOL
between_ie(ARG,START,END)Determines if arg is within (start,end]1. Parameter to be calculated, optional type: ANY;
2. Specified start, optional type: ANY; 3. Specified end, optional type: ANY
BOOL
group(ARG)Group statisticsParameter to be calculated, optional type: ANYANY
if(B,TRUE,FALSE)Conditional branch judgment, the types of the last two parameters must be the same. For example: if({score}>=60, 'Pass', 'Fail')1. Condition, boolean type parameter, optional type: BOOL;
2. Value when condition is true, optional type: ANY;
3. Value when condition is false, optional type: ANY
ANY
in(ARG,ARR)Whether the value of the field is in the list1. Parameter to be calculated, optional type: ANY; 2. Array type parameter, optional type: ARRAYBOOL
isnotnull(ARG)Determines if the specified field is not nullParameter to be calculated, optional type: ANYBOOL
isnull(ARG)Determines if the specified field is nullParameter to be calculated, optional type: ANYBOOL
first(ARG)Gets the value of the first record in the specified columnParameter to be calculated, optional type: ANYANYredshift
sqlserver tidb mysql
db2 mongodb maxcompute
jsonget(JSON,KEY)Gets the specified key of JSON1. JSON type parameter, optional type: JSON;
2. Specified key, optional type: STRING
STRINGimpala
hive spark oracle
db2 mongodb maxcompute
last(ARG)Gets the value of the last record in the specified columnParameter to be calculated, optional type: ANYANYredshift
sqlserver tidb mysql
db2 mongodb maxcompute
list_collect(ARG)Aggregation function, collects the parameters of arg into an arrayParameter to be calculated, optional type: ANYARRAYimpala hive
spark oracle redshift
sqlserver tidb mysql
db2 mongodb maxcompute
list_collect_flatten(ARR)Aggregation function, collects and flattens the parameters of arr into an arrayArray type parameter, optional type: ARRAYARRAYimpala hive
spark oracle redshift
sqlserver tidb mysql
db2 mongodb maxcompute
list_count(ARR)Gets the length of the arrayArray type parameter, optional type: ARRAYNUMBERimpala hive
spark oracle redshift
sqlserver tidb mysql
db2 mongodb maxcompute
list_except(ARR1,ARR2)Calculates the difference set of two arrays1. First array, optional type: ARRAY;
2. Second array, optional type: ARRAY
ARRAYimpala hive
spark oracle redshift
sqlserver tidb mysql
db2 mongodb maxcompute
list_intersect(ARR1,ARR2)Calculates the intersection of two arrays1. First array, optional type: ARRAY; 2. Second array, optional type: ARRAYARRAYimpala hive
spark oracle redshift
sqlserver tidb mysql
db2 mongodb maxcompute
list_union(ARR1,ARR2)Calculates the union of two arrays1. First array, optional type: ARRAY;
2. Second array, optional type: ARRAY
ARRAYimpala hive
spark oracle redshift
sqlserver tidb mysql
db2 mongodb maxcompute
notin(ARG,ARR)Whether the value of the field is not in the list1. Parameter to be calculated, optional type: ANY;
2. Array type parameter, optional type: ARRAY
BOOL
nth(ARG,I)Gets the i-th value1. Parameter to be calculated, optional type: ANY;
2. Integer type parameter, optional type: NUMBER
ANYimpala hive
spark oracle redshift
sqlserver tidb mysql
db2 mongodb maxcompute
set_collect(ARG)Aggregation function, collects the parameters of arg into a deduplicated arrayParameter to be calculated, optional type: ANYARRAYimpala hive
spark oracle redshift
sqlserver tidb mysql mongodb maxcompute
set_collect_flatten(ARR)Aggregation function, collects and flattens the parameters of arr into a deduplicated arrayArray type parameter, optional type: ARRAYARRAYimpala hive
spark oracle redshift
sqlserver tidb mysql
db2 mongodb maxcompute
set_union(ARR1,ARR2)Calculates the deduplicated union of two arrays1. First array, optional type: ARRAY;
2. Second array, optional type: ARRAY
ARRAYimpala hive
spark oracle redshift
sqlserver tidb mysql
db2 mongodb maxcompute
case when condition then result1 [else result2] endThis function outputs based on the result of the condition expression. When condition is true, it returns result1. When condition is false, it returns result2, the else branch is not mandatory. Example
case
when {code} = 1 then 'Pass'
else 'Fail'
end
condition is an expression that returns a boolean valueANY
filter(where condition)This function filters based on the result of the condition expression. If the condition returns true, the current record meets the filter criteria. Example
count(1) filter (where state = 'authorized')
condition is an expression that returns a boolean valueARRAY
calculate(expr)This function indicates prioritizing the calculation of the aggregation expression. Example
SUM({energy}) FILTER (WHERE {logindate} > CALCULATE(min({logindate})))
Parameter is an aggregation expressionANYmongo、hive、impala、Kylin open source edition、hbase、phoenix、elastic search、solr

HENGSHI SENSE Platform User Manual