Class BaseExpressions<InType,OutType>
- Type Parameters:
InType- The accepted type of input expressions, it isExpressionfor Scala andObjectfor Java. Generally the expression DSL works on expressions, the reason why Java accepts Object is to remove cumbersome call tolit()for literals. Scala alleviates this problem via implicit conversions.OutType- The produced type of the DSL. It isApiExpressionfor Java andExpressionfor Scala. In Scala the infix operations are included via implicit conversions. In Java we introduced a wrapper that enables the operations without pulling them through the whole stack.
- Direct Known Subclasses:
ApiExpression
Expression
AST for expression operations.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabs()Calculates the absolute value of given value.acos()Calculates the arc cosine of a given number.Boolean AND in three-valued logic.arrayAgg()Returns array aggregate of a given expression.arrayAppend(InType element) Appends an element to the end of the array and returns the result.arrayConcat(InType... arrays) Returns an array that is the result of concatenating at least one array.arrayContains(InType needle) Returns whether the given element exists in an array.Returns an array with unique elements.arrayExcept(InType array) Returns an ARRAY that contains the elements from array1 that are not in array2.arrayIntersect(InType array) Returns an ARRAY that contains the elements from array1 that are also in array2, without duplicates.arrayMax()Returns the maximum value from the array.arrayMin()Returns the minimum value from the array.arrayPosition(InType needle) Returns the position of the first occurrence of element in the given array as int.arrayPrepend(InType element) Appends an element to the beginning of the array and returns the result.arrayRemove(InType needle) Removes all elements that equal to element from array.Returns an array in reverse order.arraySlice(InType startOffset) arraySlice(InType startOffset, InType endOffset) Returns a subarray of the input array between 'start_offset' and 'end_offset' inclusive.arrayUnion(InType array) Returns an array of the elements in the union of array1 and array2, without duplicates.Specifies a name for an expression i.e. a field.asc()Specifies ascending order of an expression i.e. a field for orderBy unresolvedCall.ascii()Returns the numeric value of the first character of the input string.asin()Calculates the arc sine of a given number.Accesses the element of an array or map based on a key or an index (starting at 1).atan()Calculates the arc tangent of a given number.avg()Returns the average (arithmetic mean) of the numeric field across all input values.Returns true if the given expression is between lowerBound and upperBound (both inclusive).bin()Returns a string representation of an integer numeric value in binary format.btrim()Returns a string that removes the left and right whitespaces from the given string.Returns a string that removes the left and right chars in trimStr from the given string.Returns the number of elements of an array or number of entries of a map.cast(org.apache.flink.table.types.DataType toType) Returns a new value being cast totoType.ceil()Calculates the smallest integer greater than or equal to a given number.ceil(org.apache.flink.table.expressions.TimeIntervalUnit timeIntervalUnit) Rounds up a time point to the given unit.Returns the length of a string.chr()Returns the ASCII character result of the input integer.collect()Returns multiset aggregate of a given expression.Concatenates two strings.cos()Calculates the cosine of a given number.cosh()Calculates the hyperbolic cosine of a given value.cot()Calculates the cotangent of a given number.count()Returns the number of input rows for which the field is not null.day()Creates an interval of the given number of days.days()Creates an interval of the given number of days.Decodes the first argument into a String using the provided character set.degrees()Converts numeric from radians to degrees.desc()Specifies descending order of an expression i.e. a field for orderBy unresolvedCall.distinct()Similar to a SQL distinct aggregation clause such as COUNT(DISTINCT a), declares that an aggregation function is only applied on distinct input values.Returns left divided by right.element()Returns the sole element of an array with a single element.Returns theindex-th expression.Encodes the string into a BINARY using the provided character set.end()Returns the end time (exclusive) of a window when applied on a window reference.Returns whetherexprends withendExpr.exp()Calculates the Euler's number raised to the given power.extract(org.apache.flink.table.expressions.TimeIntervalUnit timeIntervalUnit) Extracts parts of a time point or time interval.Returns the first value of field across all input values.flatten()Converts a Flink composite type (such as Tuple, POJO, etc.) and all of its direct subtypes into a flat representation where every subtype is a separate field.floor()Calculates the largest integer less than or equal to a given number.floor(org.apache.flink.table.expressions.TimeIntervalUnit timeIntervalUnit) Rounds down a time point to the given unit.Returns the base string decoded with base64.get(int index) Accesses the field of a Flink composite type (such as Tuple, POJO, etc.) by index and returns it's value.Accesses the field of a Flink composite type (such as Tuple, POJO, etc.) by name and returns it's value.hex()Returns a string representation of an integer numeric value or a string in hex format.hour()Creates an interval of the given number of hours.hours()Creates an interval of the given number of hours.ReturnsnullReplacementif the given expression is NULL; otherwise the expression is returned.final OutTypeReturns true if an expression exists in a given list of expressions.Returns true if an expression exists in a given table sub-query.initCap()Converts the initial letter of each word in a string to uppercase.Returns the position of the first occurrence of the input string.Equals.isFalse()Returns true if given boolean expression is false.Greater than.isGreaterOrEqual(InType other) Greater than or equal.isJson()Determine whether a given string is valid JSON.isJson(org.apache.flink.table.api.JsonType type) Determine whether a given string is valid JSON.Less than.isLessOrEqual(InType other) Less than or equal.isNotEqual(InType other) Not equal.Returns true if given boolean expression is not false (for null and true).Returns true if the given expression is not null.Returns true if given boolean expression is not true (for null and false).isNull()Returns true if the given expression is null.isTrue()Returns true if given boolean expression is true.jsonExists(String path) Determines whether a JSON string satisfies a given search criterion.jsonExists(String path, org.apache.flink.table.api.JsonExistsOnError onError) Returns whether a JSON string satisfies a given search criterion.Extracts JSON values from a JSON string.Extracts JSON values from a JSON string.jsonQuery(String path, org.apache.flink.table.api.JsonQueryWrapper wrappingBehavior, org.apache.flink.table.api.JsonQueryOnEmptyOrError onEmpty, org.apache.flink.table.api.JsonQueryOnEmptyOrError onError) Extracts JSON values from a JSON string.Extracts JSON values from a JSON string.jsonQuery(String path, org.apache.flink.table.types.DataType returnType, org.apache.flink.table.api.JsonQueryWrapper wrappingBehavior) Extracts JSON values from a JSON string.jsonQuery(String path, org.apache.flink.table.types.DataType returnType, org.apache.flink.table.api.JsonQueryWrapper wrappingBehavior, org.apache.flink.table.api.JsonQueryOnEmptyOrError onEmpty, org.apache.flink.table.api.JsonQueryOnEmptyOrError onError) Extracts JSON values from a JSON string.Returns a string by quotes a string as a JSON value and wrapping it with double quote characters.Returns a string by unquoting JSON value.Extracts a scalar from a JSON string.Extracts a scalar from a JSON string.jsonValue(String path, org.apache.flink.table.types.DataType returningType, InType defaultOnEmptyOrError) Extracts a scalar from a JSON string.jsonValue(String path, org.apache.flink.table.types.DataType returningType, org.apache.flink.table.api.JsonValueOnEmptyOrError onEmpty, InType defaultOnEmpty, org.apache.flink.table.api.JsonValueOnEmptyOrError onError, InType defaultOnError) Extracts a scalar from a JSON string.Returns the last value of field across all input values.Returns the leftmost integer characters from the input string.Returns true, if a string matches the specified LIKE pattern with default escape character '/'.Returns true, if a string matches the specified LIKE pattern with specified escape character consisting of a single char.listAgg()Concatenates the values of string expressions and places separator(,) values between them.Concatenates the values of string expressions and places separator values between them.ln()Calculates the natural logarithm of the given value.Returns the position of the first occurrence in the input string.Returns the position of the first occurrence in the input string after position integer.log()Calculates the natural logarithm of the given value.Calculates the logarithm of the given value to the given base.log10()Calculates the base 10 logarithm of the given value.log2()Calculates the base 2 logarithm of the given value.Returns all of the characters in a string in lower case using the rules of the default locale.Returns a string left-padded with the given pad string to a length of len characters.ltrim()Returns a string that removes the left whitespaces from the given string.Returns a string that removes the left chars in trimStr from the given string.Returns an array of all entries in the given map.mapKeys()Returns the keys of the map as an array.Returns a map created by merging at least one map.Returns the values of the map as an array.max()Returns the maximum value of field across all input values.md5()Returns the MD5 hash of the string argument; null if string is null.milli()Creates an interval of the given number of milliseconds.millis()Creates an interval of the given number of milliseconds.min()Returns the minimum value of field across all input values.Returns left minus right.minute()Creates an interval of the given number of minutes.minutes()Creates an interval of the given number of minutes.Calculates the remainder of division the given number by another one.month()Creates an interval of the given number of months.months()Creates an interval of the given number of months.not()Inverts a given boolean expression.notBetween(InType lowerBound, InType upperBound) Returns true if the given expression is not between lowerBound and upperBound (both inclusive).Boolean OR in three-valued logic.Defines an aggregation to be used for a previously specified over window.Replaces a substring of string with a string starting at a position (starting at 1).Replaces a substring of string with a string starting at a position (starting at 1).Parse url and return various parameter of the URL.Parse url and return various parameter of the URL.percentile(InType percentage) percentile(InType percentage, InType frequency) Returns the exact percentile value ofexprat the specifiedpercentagein a group.Returns left plus right.Returns the position of string in an other string starting at 1.Calculates the given number raised to the power of the other value.final OutTypeReturns a formatted string from printf-style format string.proctime()Declares a field as the proctime attribute for indicating, accessing, and working in Flink's processing time.quarter()Creates an interval of the given number of quarters.quarters()Creates an interval of the given number of quarters.radians()Converts numeric from degrees to radians.Returns TRUE if any (possibly empty) substring matches the Java regular expression, otherwise FALSE.regexpCount(InType regex) Returns the number of timesstrmatches theregexpattern.regexpExtract(InType regex) Returns a string extracted with a specified regular expression.regexpExtract(InType regex, InType extractIndex) Returns a string extracted with a specified regular expression and a regex match group index.regexpExtractAll(InType regex) Extracts all the strings in str that match the regex expression.regexpExtractAll(InType regex, InType extractIndex) Extracts all the substrings instrthat match theregexexpression and correspond to the regex groupextractIndex.regexpInstr(InType regex) Returns the position of the first substring instrthat matchesregex.regexpReplace(InType regex, InType replacement) Returns a string with all substrings that match the regular expression consecutively being replaced.regexpSubstr(InType regex) Returns the first substring instrthat matchesregex.Returns a string that repeats the base string n times.Returns a new string which replaces all the occurrences of the search target with the replacement string (non-overlapping).reverse()Reverse each character in current string.Returns the rightmost integer characters from the input string.Rounds the given number to integer places right to the decimal point.rowtime()Declares a field as the rowtime attribute for indicating, accessing, and working in Flink's event time.Returns a string right-padded with the given pad string to a length of len characters.rtrim()Returns a string that removes the right whitespaces from the given string.Returns a string that removes the right chars in trimStr from the given string.second()Creates an interval of the given number of seconds.seconds()Creates an interval of the given number of seconds.sha1()Returns the SHA-1 hash of the string argument; null if string is null.Returns the hash for the given string expression using the SHA-2 family of hash functions (SHA-224, SHA-256, SHA-384, or SHA-512).sha224()Returns the SHA-224 hash of the string argument; null if string is null.sha256()Returns the SHA-256 hash of the string argument; null if string is null.sha384()Returns the SHA-384 hash of the string argument; null if string is null.sha512()Returns the SHA-512 hash of the string argument; null if string is null.sign()Calculates the signum of a given number.Returns true, if a string matches the specified SQL regex pattern.sin()Calculates the sine of a given number.sinh()Calculates the hyperbolic sine of a given value.Returns an array of substrings by splitting the input string based on a given delimiter.splitIndex(InType separator, InType index) Split target string with custom separator and pick the index-th(start with 0) result.sqrt()Calculates the square root of a given value.start()Returns the start time (inclusive) of a window when applied on a window reference.startsWith(InType startExpr) Returns whetherexprstarts withstartExpr.Returns the population standard deviation of an expression (the square root of varPop()).Returns the sample standard deviation of an expression (the square root of varSamp()).strToMap()Creates a map by parsing text.Creates a map by parsing text.Creates a substring of the given string beginning at the given index to the end.Creates a substring of the given string at given index for a given length.Creates a substring of the given string beginning at the given index to the end.Creates a substring of the given string at given index for a given length.sum()Returns the sum of the numeric field across all input values.sum0()Returns the sum of the numeric field across all input values.tan()Calculates the tangent of a given number.tanh()Calculates the hyperbolic tangent of a given number.Ternary conditional operator that decides which of two other expressions should be evaluated based on a evaluated boolean condition.Returns left multiplied by right.protected abstract OutTypetoApiSpecificExpression(org.apache.flink.table.expressions.Expression expression) toBase64()Returns the base64-encoded result of the input string.toDate()Parses a date string in the form "yyyy-MM-dd" to a SQL Date.protected abstract org.apache.flink.table.expressions.ExpressiontoExpr()toTime()Parses a time string in the form "HH:mm:ss" to a SQL Time.Parses a timestamp string in the form "yyyy-MM-dd HH:mm:ss[.SSS]" to a SQL Timestamp.Translate anexprwhere all characters infromStrhave been replaced with those intoStr.trim()Removes leading and trailing space characters from the given string.Removes leading and trailing characters from the given string.Removes leading space characters from the given string.trimLeading(InType character) Removes leading characters from the given string.Removes trailing space characters from the given string.trimTrailing(InType character) Removes trailing characters from the given string.truncate()Returns a number of truncated to 0 decimal places.Returns a number of truncated to n decimal places.tryCast(org.apache.flink.table.types.DataType toType) Likecast(DataType), but in case of error, returnsnullrather than failing the job.unhex()Converts hexadecimal stringexprto BINARY.Returns all of the characters in a string in upper case using the rules of the default locale.Decodes a given string in 'application/x-www-form-urlencoded' format using the UTF-8 encoding scheme.Translates a string into 'application/x-www-form-urlencoded' format using the UTF-8 encoding scheme.varPop()Returns the population standard variance of an expression.varSamp()Returns the sample variance of a given expression.week()Creates an interval of the given number of weeks.weeks()Creates an interval of the given number of weeks.year()Creates an interval of the given number of years.years()Creates an interval of the given number of years.
-
Constructor Details
-
BaseExpressions
public BaseExpressions()
-
-
Method Details
-
toExpr
protected abstract org.apache.flink.table.expressions.Expression toExpr() -
toApiSpecificExpression
protected abstract OutType toApiSpecificExpression(org.apache.flink.table.expressions.Expression expression) -
as
Specifies a name for an expression i.e. a field.- Parameters:
name- name for one fieldextraNames- additional names if the expression expands to multiple fields
-
arrayExcept
Returns an ARRAY that contains the elements from array1 that are not in array2. If no elements remain after excluding the elements in array2 from array1, the function returns an empty ARRAY.If one or both arguments are NULL, the function returns NULL. The order of the elements from array1 is kept.
-
arrayIntersect
Returns an ARRAY that contains the elements from array1 that are also in array2, without duplicates. If no elements that are both in array1 and array2, the function returns an empty ARRAY.If one or both arguments are NULL, the function returns NULL. The order of the elements from array1 is kept.
-
and
Boolean AND in three-valued logic. This is an infix notation. See alsoExpressions.and(Object, Object, Object...)for prefix notation with multiple arguments. -
or
Boolean OR in three-valued logic. This is an infix notation. See alsoExpressions.or(Object, Object, Object...)for prefix notation with multiple arguments. -
not
Inverts a given boolean expression.This method supports a three-valued logic by preserving
NULL. This means if the input expression isNULL, the result will also beNULL.The resulting type is nullable if and only if the input type is nullable.
Examples:
lit(true).not() // false lit(false).not() // true lit(null, DataTypes.BOOLEAN()).not() // null -
isGreater
Greater than. -
isGreaterOrEqual
Greater than or equal. -
isLess
Less than. -
isLessOrEqual
Less than or equal. -
isEqual
Equals. -
isNotEqual
Not equal. -
plus
Returns left plus right. -
minus
Returns left minus right. -
dividedBy
Returns left divided by right. -
times
Returns left multiplied by right. -
concat
Concatenates two strings. -
between
Returns true if the given expression is between lowerBound and upperBound (both inclusive). False otherwise. The parameters must be numeric types or identical comparable types.- Parameters:
lowerBound- numeric or comparable expressionupperBound- numeric or comparable expression
-
notBetween
Returns true if the given expression is not between lowerBound and upperBound (both inclusive). False otherwise. The parameters must be numeric types or identical comparable types.- Parameters:
lowerBound- numeric or comparable expressionupperBound- numeric or comparable expression
-
then
Ternary conditional operator that decides which of two other expressions should be evaluated based on a evaluated boolean condition.e.g. lit(42).isGreater(5).then("A", "B") leads to "A"
- Parameters:
ifTrue- expression to be evaluated if condition holdsifFalse- expression to be evaluated if condition does not hold
-
ifNull
ReturnsnullReplacementif the given expression is NULL; otherwise the expression is returned.This function returns a data type that is very specific in terms of nullability. The returned type is the common type of both arguments but only nullable if the
nullReplacementis nullable.The function allows to pass nullable columns into a function or table that is declared with a NOT NULL constraint.
E.g.,
$('nullable_column').ifNull(5)returns never NULL. -
isNull
Returns true if the given expression is null. -
isNotNull
Returns true if the given expression is not null. -
isTrue
Returns true if given boolean expression is true. False otherwise (for null and false). -
isFalse
Returns true if given boolean expression is false. False otherwise (for null and true). -
isNotTrue
Returns true if given boolean expression is not true (for null and false). False otherwise. -
isNotFalse
Returns true if given boolean expression is not false (for null and true). False otherwise. -
distinct
Similar to a SQL distinct aggregation clause such as COUNT(DISTINCT a), declares that an aggregation function is only applied on distinct input values.For example:
orders .groupBy($("a")) .select($("a"), $("b").sum().distinct().as("d")) -
sum
Returns the sum of the numeric field across all input values. If all values are null, null is returned. -
sum0
Returns the sum of the numeric field across all input values. If all values are null, 0 is returned. -
min
Returns the minimum value of field across all input values. -
max
Returns the maximum value of field across all input values. -
count
Returns the number of input rows for which the field is not null. -
avg
Returns the average (arithmetic mean) of the numeric field across all input values. -
firstValue
Returns the first value of field across all input values. -
lastValue
Returns the last value of field across all input values. -
listAgg
Concatenates the values of string expressions and places separator(,) values between them. The separator is not added at the end of string. -
listAgg
Concatenates the values of string expressions and places separator values between them. The separator is not added at the end of string. The default value of separator is ‘,’.- Parameters:
separator- string containing the character
-
stddevPop
Returns the population standard deviation of an expression (the square root of varPop()). -
stddevSamp
Returns the sample standard deviation of an expression (the square root of varSamp()). -
varPop
Returns the population standard variance of an expression. -
varSamp
Returns the sample variance of a given expression. -
collect
Returns multiset aggregate of a given expression. -
arrayAgg
Returns array aggregate of a given expression. -
cast
Returns a new value being cast totoType. A cast error throws an exception and fails the job. When performing a cast operation that may fail, likeDataTypes.STRING()toDataTypes.INT(), one should rather usetryCast(DataType), in order to handle errors. IfExecutionConfigOptions.TABLE_EXEC_LEGACY_CAST_BEHAVIOURis enabled, this function behaves liketryCast(DataType).E.g.
"42".cast(DataTypes.INT())returns42;null.cast(DataTypes.STRING())returnsnullof typeDataTypes.STRING();"non-number".cast(DataTypes.INT())throws an exception and fails the job. -
tryCast
Likecast(DataType), but in case of error, returnsnullrather than failing the job.E.g.
"42".tryCast(DataTypes.INT())returns42;null.tryCast(DataTypes.STRING())returnsnullof typeDataTypes.STRING();"non-number".tryCast(DataTypes.INT())returnsnullof typeDataTypes.INT();coalesce("non-number".tryCast(DataTypes.INT()), 0)returns0of typeDataTypes.INT(). -
asc
Specifies ascending order of an expression i.e. a field for orderBy unresolvedCall. -
desc
Specifies descending order of an expression i.e. a field for orderBy unresolvedCall. -
in
Returns true if an expression exists in a given list of expressions. This is a shorthand for multiple OR conditions.If the testing set contains null, the result will be null if the element can not be found and true if it can be found. If the element is null, the result is always null.
e.g. lit("42").in(1, 2, 3) leads to false.
-
in
Returns true if an expression exists in a given table sub-query. The sub-query table must consist of one column. This column must have the same data type as the expression.Note: This operation is not supported in a streaming environment yet.
-
start
Returns the start time (inclusive) of a window when applied on a window reference. -
end
Returns the end time (exclusive) of a window when applied on a window reference.e.g. if a window ends at 10:59:59.999 this property will return 11:00:00.000.
-
mod
Calculates the remainder of division the given number by another one. -
exp
Calculates the Euler's number raised to the given power. -
log10
Calculates the base 10 logarithm of the given value. -
log2
Calculates the base 2 logarithm of the given value. -
ln
Calculates the natural logarithm of the given value. -
log
Calculates the natural logarithm of the given value. -
log
Calculates the logarithm of the given value to the given base. -
power
Calculates the given number raised to the power of the other value. -
cosh
Calculates the hyperbolic cosine of a given value. -
sqrt
Calculates the square root of a given value. -
abs
Calculates the absolute value of given value. -
floor
Calculates the largest integer less than or equal to a given number. -
sinh
Calculates the hyperbolic sine of a given value. -
ceil
Calculates the smallest integer greater than or equal to a given number. -
sin
Calculates the sine of a given number. -
cos
Calculates the cosine of a given number. -
tan
Calculates the tangent of a given number. -
cot
Calculates the cotangent of a given number. -
asin
Calculates the arc sine of a given number. -
acos
Calculates the arc cosine of a given number. -
atan
Calculates the arc tangent of a given number. -
tanh
Calculates the hyperbolic tangent of a given number. -
degrees
Converts numeric from radians to degrees. -
radians
Converts numeric from degrees to radians. -
sign
Calculates the signum of a given number. -
round
Rounds the given number to integer places right to the decimal point. -
bin
Returns a string representation of an integer numeric value in binary format. Returns null if numeric is null. E.g. "4" leads to "100", "12" leads to "1100". -
hex
Returns a string representation of an integer numeric value or a string in hex format. Returns null if numeric or string is null.E.g. a numeric 20 leads to "14", a numeric 100 leads to "64", and a string "hello,world" leads to "68656c6c6f2c776f726c64".
-
unhex
Converts hexadecimal stringexprto BINARY. If the length ofexpris odd, the first character is discarded and the result is left padded with a null byte.- Returns:
- a BINARY.
null if expr is null or expr contains non-hex characters.
-
truncate
Returns a number of truncated to n decimal places. If n is 0,the result has no decimal point or fractional part. n can be negative to cause n digits left of the decimal point of the value to become zero. E.g. truncate(42.345, 2) to 42.34. -
truncate
Returns a number of truncated to 0 decimal places. E.g. truncate(42.345) to 42.0. -
startsWith
Returns whetherexprstarts withstartExpr. IfstartExpris empty, the result is true.
exprandstartExprshould have same type.- Parameters:
startExpr- A STRING or BINARY expression.- Returns:
- A BOOLEAN.
-
endsWith
Returns whetherexprends withendExpr. IfendExpris empty, the result is true.
exprandendExprshould have same type.- Parameters:
endExpr- A STRING or BINARY expression.- Returns:
- A BOOLEAN.
-
substring
Creates a substring of the given string at given index for a given length.- Parameters:
beginIndex- first character of the substring (starting at 1, inclusive)length- number of characters of the substring
-
substring
Creates a substring of the given string beginning at the given index to the end.- Parameters:
beginIndex- first character of the substring (starting at 1, inclusive)
-
substr
Creates a substring of the given string at given index for a given length.- Parameters:
beginIndex- first character of the substring (starting at 1, inclusive)length- number of characters of the substring
-
substr
Creates a substring of the given string beginning at the given index to the end.- Parameters:
beginIndex- first character of the substring (starting at 1, inclusive)
-
translate
Translate anexprwhere all characters infromStrhave been replaced with those intoStr.
NOTE: IftoStrhas a shorter length thanfromStr, unmatched characters are removed.- Parameters:
fromStr- a STRING expressiontoStr- a STRING expression
-
trimLeading
Removes leading space characters from the given string. -
trimLeading
Removes leading characters from the given string.- Parameters:
character- string containing the character
-
trimTrailing
Removes trailing space characters from the given string. -
trimTrailing
Removes trailing characters from the given string.- Parameters:
character- string containing the character
-
trim
Removes leading and trailing space characters from the given string. -
trim
Removes leading and trailing characters from the given string.- Parameters:
character- string containing the character
-
replace
Returns a new string which replaces all the occurrences of the search target with the replacement string (non-overlapping). -
charLength
Returns the length of a string. -
upperCase
Returns all of the characters in a string in upper case using the rules of the default locale. -
lowerCase
Returns all of the characters in a string in lower case using the rules of the default locale. -
initCap
Converts the initial letter of each word in a string to uppercase. Assumes a string containing only [A-Za-z0-9], everything else is treated as whitespace. -
like
Returns true, if a string matches the specified LIKE pattern with default escape character '/'.e.g. "Jo_n%" matches all strings that start with "Jo(arbitrary letter)n"
-
like
Returns true, if a string matches the specified LIKE pattern with specified escape character consisting of a single char.e.g. "Jo_n%" matches all strings that start with "Jo(arbitrary letter)n"
-
similar
Returns true, if a string matches the specified SQL regex pattern.e.g. "A+" matches all strings that consist of at least one A
-
position
Returns the position of string in an other string starting at 1. Returns 0 if string could not be found.e.g. lit("a").position("bbbbba") leads to 6
-
lpad
Returns a string left-padded with the given pad string to a length of len characters. If the string is longer than len, the return value is shortened to len characters.e.g. lit("hi").lpad(4, "??") returns "??hi", lit("hi").lpad(1, '??') returns "h"
-
rpad
Returns a string right-padded with the given pad string to a length of len characters. If the string is longer than len, the return value is shortened to len characters.e.g. lit("hi").rpad(4, "??") returns "hi??", lit("hi").rpad(1, '??') returns "h"
-
over
Defines an aggregation to be used for a previously specified over window.For example:
table .window(Over partitionBy 'c orderBy 'rowtime preceding 2.rows following CURRENT_ROW as 'w) .select('c, 'a, 'a.count over 'w, 'a.sum over 'w) -
overlay
Replaces a substring of string with a string starting at a position (starting at 1).e.g. lit("xxxxxtest").overlay("xxxx", 6) leads to "xxxxxxxxx"
-
overlay
Replaces a substring of string with a string starting at a position (starting at 1). The length specifies how many characters should be removed.e.g. lit("xxxxxtest").overlay("xxxx", 6, 2) leads to "xxxxxxxxxst"
-
regexp
Returns TRUE if any (possibly empty) substring matches the Java regular expression, otherwise FALSE. Returns NULL if any of arguments is NULL. -
regexpCount
Returns the number of timesstrmatches theregexpattern.regexmust be a Java regular expression.- Parameters:
regex- A STRING expression with a matching pattern.- Returns:
- An INTEGER representation of the number of matches.
null if any of the arguments are null orregexis invalid.
-
regexpReplace
Returns a string with all substrings that match the regular expression consecutively being replaced. -
regexpExtract
Returns a string extracted with a specified regular expression and a regex match group index. -
regexpExtract
Returns a string extracted with a specified regular expression. -
regexpExtractAll
Extracts all the substrings instrthat match theregexexpression and correspond to the regex groupextractIndex.
regexmay contain multiple groups.extractIndexindicates which regex group to extract and starts from 1, also the default value if not specified. 0 means matching the entire regular expression.- Parameters:
regex- A STRING expression with a matching pattern.extractIndex- An optional INTEGER expression with default 1.- Returns:
- An ARRAY<STRING> of all the matched substrings.
null if any of the arguments are null or invalid.
-
regexpExtractAll
Extracts all the strings in str that match the regex expression. -
regexpInstr
Returns the position of the first substring instrthat matchesregex.
Result indexes begin at 1, 0 if there is no match.- Parameters:
regex- A STRING expression with a matching pattern.- Returns:
- An INTEGER representation of the first matched substring index.
null if any of the arguments are null orregexis invalid.
-
regexpSubstr
Returns the first substring instrthat matchesregex.- Parameters:
regex- A STRING expression with a matching pattern.- Returns:
- A STRING representation of the first matched substring.
null if any of the arguments are null orregexis invalid or pattern is not found.
-
jsonQuote
Returns a string by quotes a string as a JSON value and wrapping it with double quote characters. -
jsonUnquote
Returns a string by unquoting JSON value. -
fromBase64
Returns the base string decoded with base64. -
toBase64
Returns the base64-encoded result of the input string. -
ascii
Returns the numeric value of the first character of the input string. -
chr
Returns the ASCII character result of the input integer. -
decode
Decodes the first argument into a String using the provided character set. -
encode
Encodes the string into a BINARY using the provided character set. -
left
Returns the leftmost integer characters from the input string. -
right
Returns the rightmost integer characters from the input string. -
instr
Returns the position of the first occurrence of the input string. -
locate
Returns the position of the first occurrence in the input string. -
locate
Returns the position of the first occurrence in the input string after position integer. -
urlDecode
Decodes a given string in 'application/x-www-form-urlencoded' format using the UTF-8 encoding scheme. If the input is null, or there is an issue with the decoding process(such as encountering an illegal escape pattern), or the encoding scheme is not supported, will return null. -
urlEncode
Translates a string into 'application/x-www-form-urlencoded' format using the UTF-8 encoding scheme. If the input is null, or there is an issue with the encoding process, or the encoding scheme is not supported, will return null. -
parseUrl
Parse url and return various parameter of the URL. If accept any null arguments, return null. -
parseUrl
Parse url and return various parameter of the URL. If accept any null arguments, return null. -
printf
Returns a formatted string from printf-style format string. The function exploits theFormatterwith Locale.US.- Parameters:
obj- any expression- Returns:
- a formatted string. null if
formatis null or invalid.
-
ltrim
Returns a string that removes the left whitespaces from the given string. -
ltrim
Returns a string that removes the left chars in trimStr from the given string. -
rtrim
Returns a string that removes the right whitespaces from the given string. -
rtrim
Returns a string that removes the right chars in trimStr from the given string. -
btrim
Returns a string that removes the left and right whitespaces from the given string. -
btrim
Returns a string that removes the left and right chars in trimStr from the given string. -
repeat
Returns a string that repeats the base string n times. -
reverse
Reverse each character in current string.- Returns:
- a new string which character order is reverse to current string.
-
splitIndex
Split target string with custom separator and pick the index-th(start with 0) result.- Parameters:
separator- custom separator.index- index of the result which you want.- Returns:
- the string at the index of split results.
-
strToMap
Creates a map by parsing text. Split text into key-value pairs using two delimiters. The first delimiter separates pairs, and the second delimiter separates key and value. If only one parameter is given, default delimiters are used: ',' as delimiter1 and '=' as delimiter2. Both delimiters are treated as regular expressions.- Returns:
- the map
-
strToMap
Creates a map by parsing text. Split text into key-value pairs using two delimiters. The first delimiter separates pairs, and the second delimiter separates key and value. BothlistDelimiterandkeyValueDelimiterare treated as regular expressions.- Parameters:
listDelimiter- the delimiter to separates pairskeyValueDelimiter- the delimiter to separates key and value- Returns:
- the map
-
elt
Returns theindex-th expression.indexmust be an integer between 1 and the number of expressions.- Parameters:
expr- a STRING or BINARY expressionexprs- a STRING or BINARY expression- Returns:
- result type is the least common type of all expressions.
null ifindexis null or out of range.
-
toDate
Parses a date string in the form "yyyy-MM-dd" to a SQL Date. -
toTime
Parses a time string in the form "HH:mm:ss" to a SQL Time. -
toTimestamp
Parses a timestamp string in the form "yyyy-MM-dd HH:mm:ss[.SSS]" to a SQL Timestamp. -
extract
Extracts parts of a time point or time interval. Returns the part as a long value.e.g. lit("2006-06-05").toDate().extract(DAY) leads to 5
-
floor
Rounds down a time point to the given unit.e.g. lit("12:44:31").toDate().floor(MINUTE) leads to 12:44:00
-
ceil
Rounds up a time point to the given unit.e.g. lit("12:44:31").toDate().ceil(MINUTE) leads to 12:45:00
-
get
Accesses the field of a Flink composite type (such as Tuple, POJO, etc.) by name and returns it's value.- Parameters:
name- name of the field (similar to Flink's field expressions)
-
get
Accesses the field of a Flink composite type (such as Tuple, POJO, etc.) by index and returns it's value.- Parameters:
index- position of the field
-
flatten
Converts a Flink composite type (such as Tuple, POJO, etc.) and all of its direct subtypes into a flat representation where every subtype is a separate field. -
at
Accesses the element of an array or map based on a key or an index (starting at 1).- Parameters:
index- key or position of the element (array index starting at 1)
-
cardinality
Returns the number of elements of an array or number of entries of a map. -
element
Returns the sole element of an array with a single element. Returns null if the array is empty. Throws an exception if the array has more than one element. -
arrayAppend
Appends an element to the end of the array and returns the result.If the array itself is null, the function will return null. If an element to add is null, the null element will be added to the end of the array. The given element is cast implicitly to the array's element type if necessary.
-
arrayContains
Returns whether the given element exists in an array.Checking for null elements in the array is supported. If the array itself is null, the function will return null. The given element is cast implicitly to the array's element type if necessary.
-
arrayDistinct
Returns an array with unique elements.If the array itself is null, the function will return null. Keeps ordering of elements.
-
arrayPosition
Returns the position of the first occurrence of element in the given array as int. Returns 0 if the given value could not be found in the array. Returns null if either of the arguments are nullNOTE: that this is not zero based, but 1-based index. The first element in the array has index 1.
-
arrayPrepend
Appends an element to the beginning of the array and returns the result.If the array itself is null, the function will return null. If an element to add is null, the null element will be added to the beginning of the array. The given element is cast implicitly to the array's element type if necessary.
-
arrayRemove
Removes all elements that equal to element from array.If the array itself is null, the function will return null. Keeps ordering of elements.
-
arrayReverse
Returns an array in reverse order.If the array itself is null, the function will return null.
-
arraySlice
Returns a subarray of the input array between 'start_offset' and 'end_offset' inclusive. The offsets are 1-based however 0 is also treated as the beginning of the array. Positive values are counted from the beginning of the array while negative from the end. If 'end_offset' is omitted then this offset is treated as the length of the array. If 'start_offset' is after 'end_offset' or both are out of array bounds an empty array will be returned.Returns null if any input is null.
-
arraySlice
-
arrayUnion
Returns an array of the elements in the union of array1 and array2, without duplicates.If any of the array is null, the function will return null.
-
arrayConcat
Returns an array that is the result of concatenating at least one array. This array contains all the elements in the first array, followed by all the elements in the second array, and so forth, up to the Nth array.If any input array is NULL, the function returns NULL.
-
arrayMax
Returns the maximum value from the array.if array itself is null, the function returns null.
-
arrayMin
Returns the minimum value from the array.if array itself is null, the function returns null.
-
split
Returns an array of substrings by splitting the input string based on a given delimiter.If the delimiter is not found in the string, the original string is returned as the only element in the array. If the delimiter is empty, every character in the string is split. If the string or delimiter is null, a null value is returned. If the delimiter is found at the beginning or end of the string, or there are contiguous delimiters, then an empty string is added to the array.
-
mapKeys
Returns the keys of the map as an array. -
mapValues
Returns the values of the map as an array. -
mapEntries
Returns an array of all entries in the given map. -
mapUnion
Returns a map created by merging at least one map. These maps should have a common map type. If there are overlapping keys, the value from 'map2' will overwrite the value from 'map1', the value from 'map3' will overwrite the value from 'map2', the value from 'mapn' will overwrite the value from 'map(n-1)'. If any of maps is null, return null. -
rowtime
Declares a field as the rowtime attribute for indicating, accessing, and working in Flink's event time. -
proctime
Declares a field as the proctime attribute for indicating, accessing, and working in Flink's processing time. -
year
Creates an interval of the given number of years.The produced expression is of type
DataTypes.INTERVAL -
years
Creates an interval of the given number of years. -
quarter
Creates an interval of the given number of quarters. -
quarters
Creates an interval of the given number of quarters. -
month
Creates an interval of the given number of months. -
months
Creates an interval of the given number of months. -
week
Creates an interval of the given number of weeks. -
weeks
Creates an interval of the given number of weeks. -
day
Creates an interval of the given number of days. -
days
Creates an interval of the given number of days. -
hour
Creates an interval of the given number of hours. -
hours
Creates an interval of the given number of hours. -
minute
Creates an interval of the given number of minutes. -
minutes
Creates an interval of the given number of minutes. -
second
Creates an interval of the given number of seconds. -
seconds
Creates an interval of the given number of seconds. -
milli
Creates an interval of the given number of milliseconds. -
millis
Creates an interval of the given number of milliseconds. -
md5
Returns the MD5 hash of the string argument; null if string is null.- Returns:
- string of 32 hexadecimal digits or null
-
sha1
Returns the SHA-1 hash of the string argument; null if string is null.- Returns:
- string of 40 hexadecimal digits or null
-
sha224
Returns the SHA-224 hash of the string argument; null if string is null.- Returns:
- string of 56 hexadecimal digits or null
-
sha256
Returns the SHA-256 hash of the string argument; null if string is null.- Returns:
- string of 64 hexadecimal digits or null
-
sha384
Returns the SHA-384 hash of the string argument; null if string is null.- Returns:
- string of 96 hexadecimal digits or null
-
sha512
Returns the SHA-512 hash of the string argument; null if string is null.- Returns:
- string of 128 hexadecimal digits or null
-
sha2
Returns the hash for the given string expression using the SHA-2 family of hash functions (SHA-224, SHA-256, SHA-384, or SHA-512).- Parameters:
hashLength- bit length of the result (either 224, 256, 384, or 512)- Returns:
- string or null if one of the arguments is null.
-
isJson
Determine whether a given string is valid JSON.Specifying the optional argument puts a constraint on which type of JSON object is allowed. If the string is valid JSON, but not that type,
falseis returned. The default isJsonType.VALUE.Examples:
lit("1").isJson() // true lit("[]").isJson() // true lit("{}").isJson() // true lit("\"abc\"").isJson() // true lit("abc").isJson() // false nullOf(DataTypes.STRING()).isJson() // false lit("1").isJson(JsonType.SCALAR) // true lit("1").isJson(JsonType.ARRAY) // false lit("1").isJson(JsonType.OBJECT) // false lit("{}").isJson(JsonType.SCALAR) // false lit("{}").isJson(JsonType.ARRAY) // false lit("{}").isJson(JsonType.OBJECT) // true- Parameters:
type- The type of JSON object to validate against.- Returns:
trueif the string is a valid JSON of the given ,falseotherwise.
-
isJson
Determine whether a given string is valid JSON.This is a shortcut for
isJson(JsonType.VALUE). SeeisJson(JsonType).- Returns:
trueif the string is a valid JSON value,falseotherwise.
-
jsonExists
Returns whether a JSON string satisfies a given search criterion.This follows the ISO/IEC TR 19075-6 specification for JSON support in SQL.
Examples:
// true lit("{\"a\": true}").jsonExists("$.a") // false lit("{\"a\": true}").jsonExists("$.b") // true lit("{\"a\": [{ \"b\": 1 }]}").jsonExists("$.a[0].b") // true lit("{\"a\": true}").jsonExists("strict $.b", JsonExistsOnError.TRUE) // false lit("{\"a\": true}").jsonExists("strict $.b", JsonExistsOnError.FALSE)- Parameters:
path- JSON path to search for.onError- Behavior in case of an error.- Returns:
trueif the JSON string satisfies the search criterion.
-
jsonExists
Determines whether a JSON string satisfies a given search criterion.This follows the ISO/IEC TR 19075-6 specification for JSON support in SQL.
Examples:
// true lit("{\"a\": true}").jsonExists("$.a") // false lit("{\"a\": true}").jsonExists("$.b") // true lit("{\"a\": [{ \"b\": 1 }]}").jsonExists("$.a[0].b") // true lit("{\"a\": true}").jsonExists("strict $.b", JsonExistsOnError.TRUE) // false lit("{\"a\": true}").jsonExists("strict $.b", JsonExistsOnError.FALSE)- Parameters:
path- JSON path to search for.- Returns:
trueif the JSON string satisfies the search criterion.
-
jsonValue
public OutType jsonValue(String path, org.apache.flink.table.types.DataType returningType, org.apache.flink.table.api.JsonValueOnEmptyOrError onEmpty, InType defaultOnEmpty, org.apache.flink.table.api.JsonValueOnEmptyOrError onError, InType defaultOnError) Extracts a scalar from a JSON string.This method searches a JSON string for a given path expression and returns the value if the value at that path is scalar. Non-scalar values cannot be returned. By default, the value is returned as
DataTypes.STRING(). Using a different type can be chosen, with the following types being supported:DataTypes.STRING()DataTypes.BOOLEAN()DataTypes.INT()DataTypes.DOUBLE()
For empty path expressions or errors a behavior can be defined to either return
null, raise an error or return a defined default value instead.See
jsonQuery(String, JsonQueryWrapper, JsonQueryOnEmptyOrError, JsonQueryOnEmptyOrError)for extracting non-scalar values from a JSON string.Examples:
// STRING: "true" lit("{\"a\": true}").jsonValue("$.a") // DOUBLE: 0.998 lit("{\"a.b\": [0.998,0.996]}").jsonValue("$.['a.b'][0]", DataTypes.DOUBLE()) // BOOLEAN: true lit("{\"a\": true}").jsonValue("$.a", DataTypes.BOOLEAN()) // BOOLEAN: "false" lit("{\"a\": true}").jsonValue("lax $.b", JsonValueOnEmptyOrError.DEFAULT, false, JsonValueOnEmptyOrError.NULL, null) // BOOLEAN: "false" lit("{\"a\": true}").jsonValue("strict $.b", JsonValueOnEmptyOrError.NULL, null, JsonValueOnEmptyOrError.DEFAULT, false)- Parameters:
path- JSON path to extract.returningType- Type to convert the extracted scalar to, otherwise defaults toDataTypes.STRING().onEmpty- Behavior in case the path expression is empty.defaultOnEmpty- Default value to return if the path expression is empty and is set toJsonValueOnEmptyOrError.DEFAULT.onError- Behavior in case of an error.defaultOnError- Default value to return if there is an error and is set toJsonValueOnEmptyOrError.DEFAULT.- Returns:
- The extracted scalar value.
-
jsonValue
Extracts a scalar from a JSON string.This method searches a JSON string for a given path expression and returns the value if the value at that path is scalar. Non-scalar values cannot be returned. By default, the value is returned as
DataTypes.STRING().See also
jsonValue(String, DataType, JsonValueOnEmptyOrError, Object, JsonValueOnEmptyOrError, Object).- Parameters:
path- JSON path to extract.returningType- Type to convert the extracted scalar to, otherwise defaults toDataTypes.STRING().- Returns:
- The extracted scalar value.
-
jsonValue
public OutType jsonValue(String path, org.apache.flink.table.types.DataType returningType, InType defaultOnEmptyOrError) Extracts a scalar from a JSON string.This method searches a JSON string for a given path expression and returns the value if the value at that path is scalar. Non-scalar values cannot be returned. By default, the value is returned as
DataTypes.STRING().See also
jsonValue(String, DataType, JsonValueOnEmptyOrError, Object, JsonValueOnEmptyOrError, Object).This is a convenience method using
JsonValueOnEmptyOrError.DEFAULTfor both empty and error cases with the same default value.- Parameters:
path- JSON path to extract.returningType- Type to convert the extracted scalar to, otherwise defaults toDataTypes.STRING().- Returns:
- The extracted scalar value.
-
jsonValue
Extracts a scalar from a JSON string.This method searches a JSON string for a given path expression and returns the value if the value at that path is scalar. Non-scalar values cannot be returned. By default, the value is returned as
DataTypes.STRING().See also
jsonValue(String, DataType, JsonValueOnEmptyOrError, Object, JsonValueOnEmptyOrError, Object).- Parameters:
path- JSON path to extract.- Returns:
- The extracted scalar value.
-
jsonQuery
public OutType jsonQuery(String path, org.apache.flink.table.types.DataType returnType, org.apache.flink.table.api.JsonQueryWrapper wrappingBehavior, org.apache.flink.table.api.JsonQueryOnEmptyOrError onEmpty, org.apache.flink.table.api.JsonQueryOnEmptyOrError onError) Extracts JSON values from a JSON string.This follows the ISO/IEC TR 19075-6 specification for JSON support in SQL. The result is always returned as a
DataTypes.STRING().The determines whether the extracted value should be wrapped into an array, and whether to do so unconditionally or only if the value itself isn't an array already.
and determine the behavior in case the path expression is empty, or in case an error was raised, respectively. By default, in both cases
nullis returned. Other choices are to use an empty array, an empty object, or to raise an error.See
jsonValue(String, DataType, JsonValueOnEmptyOrError, Object, JsonValueOnEmptyOrError, Object)for extracting scalars from a JSON string.Examples:
lit("{ \"a\": { \"b\": 1 } }").jsonQuery("$.a") // "{ \"b\": 1 }" lit("[1, 2]").jsonQuery("$") // "[1, 2]" nullOf(DataTypes.STRING()).jsonQuery("$") // null // Wrap result into an array lit("{}").jsonQuery("$", JsonQueryWrapper.CONDITIONAL_ARRAY) // "[{}]" lit("[1, 2]").jsonQuery("$", JsonQueryWrapper.CONDITIONAL_ARRAY) // "[1, 2]" lit("[1, 2]").jsonQuery("$", JsonQueryWrapper.UNCONDITIONAL_ARRAY) // "[[1, 2]]" // Scalars must be wrapped to be returned lit(1).jsonQuery("$") // null lit(1).jsonQuery("$", JsonQueryWrapper.CONDITIONAL_ARRAY) // "[1]" // Behavior if path expression is empty / there is an error // "{}" lit("{}").jsonQuery("lax $.invalid", JsonQueryWrapper.WITHOUT_ARRAY, JsonQueryOnEmptyOrError.EMPTY_OBJECT, JsonQueryOnEmptyOrError.NULL) // "[]" lit("{}").jsonQuery("strict $.invalid", JsonQueryWrapper.WITHOUT_ARRAY, JsonQueryOnEmptyOrError.NULL, JsonQueryOnEmptyOrError.EMPTY_ARRAY) // Return results as an array instead of a string lit("[1, 2]").jsonQuery("$", DataTypes.ARRAY(DataTypes.STRING()), JsonQueryWrapper.CONDITIONAL_ARRAY) // ["1", "2"] lit("[1, 2]").jsonQuery("$", DataTypes.ARRAY(DataTypes.STRING()), JsonQueryWrapper.UNCONDITIONAL_ARRAY) // ["[1, 2]"]- Parameters:
path- JSON path to search for.returnType- Type to convert the extracted array to, otherwise defaults toDataTypes.STRING().wrappingBehavior- Determine if and when to wrap the resulting value into an array.onEmpty- Behavior in case the path expression is empty.onError- Behavior in case of an error.- Returns:
- The extracted JSON value.
-
jsonQuery
public OutType jsonQuery(String path, org.apache.flink.table.api.JsonQueryWrapper wrappingBehavior, org.apache.flink.table.api.JsonQueryOnEmptyOrError onEmpty, org.apache.flink.table.api.JsonQueryOnEmptyOrError onError) Extracts JSON values from a JSON string.The result is returned as a
DataTypes.STRING().See also
jsonQuery(String, DataType, JsonQueryWrapper, JsonQueryOnEmptyOrError, JsonQueryOnEmptyOrError).- Parameters:
path- JSON path to search for.wrappingBehavior- Determine if and when to wrap the resulting value into an array.onEmpty- Behavior in case the path expression is empty.onError- Behavior in case of an error.- Returns:
- The extracted JSON value.
-
jsonQuery
Extracts JSON values from a JSON string.The determines whether the extracted value should be wrapped into an array, and whether to do so unconditionally or only if the value itself isn't an array already.
See also
jsonQuery(String, JsonQueryWrapper, JsonQueryOnEmptyOrError, JsonQueryOnEmptyOrError).- Parameters:
path- JSON path to search for.wrappingBehavior- Determine if and when to wrap the resulting value into an array.- Returns:
- The extracted JSON value.
-
jsonQuery
public OutType jsonQuery(String path, org.apache.flink.table.types.DataType returnType, org.apache.flink.table.api.JsonQueryWrapper wrappingBehavior) Extracts JSON values from a JSON string.The determines whether the extracted value should be wrapped into an array, and whether to do so unconditionally or only if the value itself isn't an array already.
See also
jsonQuery(String, JsonQueryWrapper, JsonQueryOnEmptyOrError, JsonQueryOnEmptyOrError).- Parameters:
path- JSON path to search for.returnType- Type to convert the extracted array to, otherwise defaults toDataTypes.STRING().wrappingBehavior- Determine if and when to wrap the resulting value into an array.- Returns:
- The extracted JSON value.
-
jsonQuery
Extracts JSON values from a JSON string.See also
jsonQuery(String, JsonQueryWrapper, JsonQueryOnEmptyOrError, JsonQueryOnEmptyOrError).- Parameters:
path- JSON path to search for.- Returns:
- The extracted JSON value.
-
jsonQuery
Extracts JSON values from a JSON string.See also
jsonQuery(String, JsonQueryWrapper, JsonQueryOnEmptyOrError, JsonQueryOnEmptyOrError).- Parameters:
path- JSON path to search for.returnType- Type to convert the extracted array to, otherwise defaults toDataTypes.STRING().- Returns:
- The extracted JSON value.
-
percentile
-
percentile
Returns the exact percentile value ofexprat the specifiedpercentagein a group.percentagemust be a literal numeric value between [0.0, 1.0] or an array of such values. If a variable expression is passed to this function, the result will be calculated using any one of them.frequencydescribes how many timesexprshould be counted, the default value is 1.If no
exprlies exactly at the desired percentile, the result is calculated using linear interpolation of the two nearest exprs. Ifexprorfrequencyis null, orfrequencyis not positive, the input row will be ignored.NOTE: It is recommended to use this function in a window scenario, as it typically offers better performance. In a regular group aggregation scenario, users should be aware of the performance overhead caused by a full sort triggered by each record.
- Parameters:
percentage- A NUMERIC NOT NULL or ARRAY<NUMERIC NOT NULL> NOT NULL expression.frequency- An optional INTEGER_NUMERIC expression.- Returns:
- A DOUBLE if percentage is numeric, or an ARRAY<DOUBLE> if percentage is an array. null if percentage is an empty array.
-