public final class Functions extends Object
This object also provides functions that correspond to Snowflake system-defined functions (built-in functions), including functions for aggregation and window functions.
| Modifier and Type | Method and Description |
|---|---|
static Column |
abs(Column col)
Returns the absolute value of a numeric expression.
|
static Column |
acos(Column col)
Computes the inverse cosine (arc cosine) of its input; the result is a number in the interval
[-pi, pi].
|
static Column |
add_months(Column startDate,
Column numMonths)
Adds or subtracts a specified number of months to a date or timestamp, preserving the
end-of-month information.
|
static Column |
any_value(Column e)
Returns a non-deterministic value for the specified column.
|
static Column |
approx_count_distinct(Column col)
Uses HyperLogLog to return an approximation of the distinct cardinality of the input (i.e.
|
static Column |
approx_percentile_accumulate(Column col)
Returns the internal representation of the t-Digest state (as a JSON object) at the end of
aggregation.
|
static Column |
approx_percentile_combine(Column state)
Combines (merges) percentile input states into a single output state.
|
static Column |
approx_percentile_estimate(Column col,
double percentile)
Returns the desired approximated percentile value for the specified t-Digest state.
|
static Column |
approx_percentile(Column col,
double percentile)
Returns an approximated value for the desired percentile.
|
static Column |
array_agg(Column col)
Returns the input values, pivoted into an ARRAY.
|
static Column |
array_append(Column array,
Column element)
Returns an ARRAY containing all elements from the source ARRAYas well as the new element.
|
static Column |
array_cat(Column array1,
Column array2)
Returns the concatenation of two ARRAYs.
|
static Column |
array_compact(Column array)
Returns a compacted ARRAY with missing and null values removed, effectively converting sparse
arrays into dense arrays.
|
static Column |
array_construct_compact(Column... cols)
Returns an ARRAY constructed from zero, one, or more inputs; the constructed ARRAY omits any
NULL input values.
|
static Column |
array_construct(Column... cols)
Returns an ARRAY constructed from zero, one, or more inputs.
|
static Column |
array_contains(Column variant,
Column array)
Returns
true if the specified VARIANT is found in the specified ARRAY. |
static Column |
array_insert(Column array,
Column pos,
Column element)
Returns an ARRAY containing all elements from the source ARRAY as well as the new element.
|
static Column |
array_intersection(Column col1,
Column col2)
Returns an ARRAY that contains the matching elements in the two input ARRAYs.
|
static Column |
array_position(Column variant,
Column array)
Returns the index of the first occurrence of an element in an ARRAY.
|
static Column |
array_prepend(Column array,
Column element)
Returns an ARRAY containing the new element as well as all elements from the source ARRAY.
|
static Column |
array_size(Column array)
Returns the size of the input ARRAY.
|
static Column |
array_slice(Column array,
Column from,
Column to)
Returns an ARRAY constructed from a specified subset of elements of the input ARRAY.
|
static Column |
array_to_string(Column array,
Column separator)
Returns an input ARRAY converted to a string by casting all values to strings (using
TO_VARCHAR) and concatenating them (using the string from the second argument to separate the
elements).
|
static Column |
arrays_overlap(Column a1,
Column a2)
Compares whether two arrays have at least one element in common.
|
static Column |
as_array(Column variant)
Casts a VARIANT value to an array.
|
static Column |
as_binary(Column variant)
Casts a VARIANT value to a binary string.
|
static Column |
as_char(Column variant)
Casts a VARIANT value to a string.
|
static Column |
as_date(Column variant)
Casts a VARIANT value to a date.
|
static Column |
as_decimal(Column variant)
Casts a VARIANT value to a fixed-point decimal (does not match floating-point values).
|
static Column |
as_decimal(Column variant,
int precision)
Casts a VARIANT value to a fixed-point decimal (does not match floating-point values), with
precision.
|
static Column |
as_decimal(Column variant,
int precision,
int scale)
Casts a VARIANT value to a fixed-point decimal (does not match floating-point values), with
precision and scale.
|
static Column |
as_double(Column variant)
Casts a VARIANT value to a floating-point value.
|
static Column |
as_integer(Column variant)
Casts a VARIANT value to an integer.
|
static Column |
as_number(Column variant)
Casts a VARIANT value to a fixed-point decimal (does not match floating-point values).
|
static Column |
as_number(Column variant,
int precision)
Casts a VARIANT value to a fixed-point decimal (does not match floating-point values), with
precision and scale.
|
static Column |
as_number(Column variant,
int precision,
int scale)
Casts a VARIANT value to a fixed-point decimal (does not match floating-point values), with
precision.
|
static Column |
as_object(Column variant)
Casts a VARIANT value to an object.
|
static Column |
as_real(Column variant)
Casts a VARIANT value to a floating-point value.
|
static Column |
as_time(Column variant)
Casts a VARIANT value to a time value.
|
static Column |
as_timestamp_ltz(Column variant)
Casts a VARIANT value to a TIMESTAMP value with local timezone.
|
static Column |
as_timestamp_ntz(Column variant)
Casts a VARIANT value to a TIMESTAMP value with no timezone.
|
static Column |
as_timestamp_tz(Column variant)
Casts a VARIANT value to a TIMESTAMP value with timezone.
|
static Column |
as_varchar(Column variant)
Casts a VARIANT value to a string.
|
static Column |
ascii(Column e)
Returns the ASCII code for the first character of a string.
|
static Column |
asin(Column col)
Computes the inverse sine (arc sine) of its argument; the result is a number in the interval
[-pi, pi].
|
static Column |
atan(Column col)
Computes the inverse tangent (arc tangent) of its argument; the result is a number in the
interval [-pi, pi].
|
static Column |
atan2(Column y,
Column x)
Computes the inverse tangent (arc tangent) of the ratio of its two arguments.
|
static Column |
avg(Column col)
Returns the average of non-NULL records.
|
static Column |
bitnot(Column col)
Returns the bitwise negation of a numeric expression.
|
static Column |
bitshiftleft(Column e,
Column numBits)
Shifts the bits for a numeric expression numBits positions to the left.
|
static Column |
bitshiftright(Column e,
Column numBits)
Shifts the bits for a numeric expression numBits positions to the right.
|
static Column |
callUDF(String udfName,
Column... cols)
Calls a user-defined function (UDF) by name.
|
static Column |
ceil(Column col)
Returns values from the specified column rounded to the nearest equal or larger integer.
|
static Column |
charindex(Column targetExpr,
Column sourceExpr)
Searches for targetExpr in sourceExpr and, if successful, returns the position (1-based) of the
targetExpr in sourceExpr.
|
static Column |
charindex(Column targetExpr,
Column sourceExpr,
Column position)
Searches for targetExpr in sourceExpr and, if successful, returns the position (1-based) of the
targetExpr in sourceExpr.
|
static Column |
check_json(Column col)
Checks the validity of a JSON document.
|
static Column |
check_xml(Column col)
Checks the validity of an XML document.
|
static Column |
chr(Column col)
Converts a Unicode code point (including 7-bit ASCII) into the character that matches the input
Unicode.
|
static Column |
coalesce(Column... cols)
Returns the first non-NULL expression among its arguments, or NULL if all its arguments are
NULL.
|
static Column |
col(DataFrame df)
Generates a Column representing the result of the input DataFrame.
|
static Column |
col(String name)
Creates a Column with the specified name.
|
static Column |
collate(Column expr,
String collationSpec)
Returns a copy of expr, but with the specified collationSpec property instead of the original
collation specification property.
|
static Column |
collation(Column expr)
Returns the collation specification of expr.
|
static Column |
concat_ws(Column separator,
Column... exprs)
Concatenates two or more strings, or concatenates two or more binary values.
|
static Column |
concat(Column... exprs)
Concatenates one or more strings, or concatenates one or more binary values.
|
static Column |
contains(Column col,
Column str)
Returns true if col contains str.
|
static Column |
convert_timezone(Column targetTimeZone,
Column sourceTimestamp)
Converts the given sourceTimestampNTZ to targetTimeZone.
|
static Column |
convert_timezone(Column sourceTimeZone,
Column targetTimeZone,
Column sourceTimestampNTZ)
Converts the given sourceTimestampNTZ from sourceTimeZone to targetTimeZone.
|
static Column |
corr(Column col1,
Column col2)
Returns the correlation coefficient for non-null pairs in a group.
|
static Column |
cos(Column col)
Computes the cosine of its argument; the argument should be expressed in radians.
|
static Column |
cosh(Column col)
Computes the hyperbolic cosine of its argument.
|
static Column |
count_distinct(Column first,
Column... remaining)
Returns either the number of non-NULL distinct records for the specified columns, or the total
number of the distinct records.
|
static Column |
count(Column col)
Returns either the number of non-NULL records for the specified columns, or the total number of
records.
|
static Column |
covar_pop(Column col1,
Column col2)
Calculates the population covariance for non-null pairs in a group.
|
static Column |
covar_samp(Column col1,
Column col2)
Calculates the sample covariance for non-null pairs in a group.
|
static Column |
cume_dist()
Finds the cumulative distribution of a value with regard to other values within the same window
partition.
|
static Column |
current_account()
Returns the account used by the user's current session.
|
static Column |
current_available_roles()
Returns a JSON string that lists all roles granted to the current user.
|
static Column |
current_database()
Returns the name of the database in use for the current session.
|
static Column |
current_date()
Returns the current date of the system.
|
static Column |
current_region()
Returns the name of the region for the account where the current user is logged in.
|
static Column |
current_role()
Returns the name of the role in use for the current session.
|
static Column |
current_schema()
Returns the name of the schema in use by the current session.
|
static Column |
current_schemas()
Returns active search path schemas.
|
static Column |
current_session()
Returns a unique system identifier for the Snowflake session corresponding to the present
connection.
|
static Column |
current_statement()
Returns the SQL text of the statement that is currently executing.
|
static Column |
current_time()
Returns the current time for the system.
|
static Column |
current_timestamp()
Returns the current timestamp for the system.
|
static Column |
current_user()
Returns the name of the user currently logged into the system.
|
static Column |
current_version()
Returns the current Snowflake version.
|
static Column |
current_warehouse()
Returns the name of the warehouse in use for the current session.
|
static Column |
date_from_parts(Column year,
Column month,
Column day)
Creates a date from individual numeric components that represent the year, month, and day of
the month.
|
static Column |
date_trunc(String format,
Column timestamp)
Truncates a DATE, TIME, or TIMESTAMP to the specified precision.
|
static Column |
dateadd(String part,
Column value,
Column expr)
Adds the specified value for the specified date or time art to date or time expr.
|
static Column |
datediff(String part,
Column col1,
Column col2)
Calculates the difference between two date, time, or timestamp columns based on the date or
time part requested.
|
static Column |
dayname(Column expr)
Extracts the three-letter day-of-week name from the specified date or timestamp.
|
static Column |
dayofmonth(Column e)
Extracts the day of month from a date or timestamp.
|
static Column |
dayofweek(Column e)
Extracts the day of week from a date or timestamp.
|
static Column |
dayofyear(Column e)
Extracts the day of year from a date or timestamp.
|
static Column |
degrees(Column e)
Converts radians to degrees.
|
static Column |
dense_rank()
Returns the rank of a value within a group of values, without gaps in the ranks.
|
static Column |
div0(Column dividend,
Column divisor)
Performs division like the division operator (/), but returns 0 when the divisor is 0 (rather
than reporting an error).
|
static Column |
endswith(Column expr,
Column str)
Returns TRUE if expr ends with str.
|
static Column |
equal_nan(Column col)
Returns true if the value in the column is not a number (NaN).
|
static Column |
exp(Column col)
Computes Euler's number e raised to a floating-point value.
|
static Column |
factorial(Column col)
Computes the factorial of its input.
|
static Column |
floor(Column col)
Returns values from the specified column rounded to the nearest equal or smaller integer.
|
static Column |
get_ignore_case(Column obj,
Column field)
Extracts a field value from an object; returns NULL if either of the arguments is NULL.
|
static Column |
get_path(Column col,
Column path)
Extracts a value from semi-structured data using a path name.
|
static Column |
get(Column col1,
Column col2)
Extracts a value from an object or array; returns NULL if either of the arguments is NULL.
|
static Column |
greatest(Column... cols)
Returns the largest value from a list of expressions.
|
static Column |
grouping_id(Column... cols)
Describes which of a list of expressions are grouped in a row produced by a GROUP BY query.
|
static Column |
grouping(Column col)
Describes which of a list of expressions are grouped in a row produced by a GROUP BY query.
|
static Column |
hash(Column... cols)
Returns a signed 64-bit hash value.
|
static Column |
hour(Column e)
Extracts the hour from a date or timestamp.
|
static Column |
iff(Column condition,
Column expr1,
Column expr2)
Returns one of two specified expressions, depending on a condition.
|
static Column |
in(Column[] columns,
DataFrame df)
Returns a conditional expression that you can pass to the filter or where method to perform the
equivalent of a WHERE ...
|
static Column |
in(Column[] columns,
List<List<Object>> values)
Returns a conditional expression that you can pass to the filter or where method to perform the
equivalent of a WHERE ...
|
static Column |
initcap(Column e)
Returns the input string with the first letter of each word in uppercase and the subsequent
letters in lowercase.
|
static Column |
insert(Column baseExpr,
Column position,
Column length,
Column insertExpr)
Replaces a substring of the specified length, starting at the specified position, with a new
string or binary value.
|
static Column |
is_array(Column col)
Returns true if the specified VARIANT column contains an ARRAY value.
|
static Column |
is_binary(Column col)
Returns true if the specified VARIANT column contains a binary value.
|
static Column |
is_boolean(Column col)
Returns true if the specified VARIANT column contains a Boolean value.
|
static Column |
is_char(Column col)
Returns true if the specified VARIANT column contains a string value.
|
static Column |
is_date_value(Column col)
Returns true if the specified VARIANT column contains a DATE value.
|
static Column |
is_date(Column col)
Returns true if the specified VARIANT column contains a DATE value.
|
static Column |
is_decimal(Column col)
Returns true if the specified VARIANT column contains a fixed-point decimal value or integer.
|
static Column |
is_double(Column col)
Returns true if the specified VARIANT column contains a floating-point value, fixed-point
decimal, or integer.
|
static Column |
is_integer(Column col)
Returns true if the specified VARIANT column contains an integer value.
|
static Column |
is_null_value(Column col)
Returns true if the specified VARIANT column is a JSON null value.
|
static Column |
is_null(Column col)
Returns true if the value in the column is null.
|
static Column |
is_object(Column col)
Returns true if the specified VARIANT column contains an OBJECT value.
|
static Column |
is_real(Column col)
Returns true if the specified VARIANT column contains a floating-point value, fixed-point
decimal, or integer.
|
static Column |
is_time(Column col)
Returns true if the specified VARIANT column contains a TIME value.
|
static Column |
is_timestamp_ltz(Column col)
Returns true if the specified VARIANT column contains a TIMESTAMP value to be interpreted using
the local time zone.
|
static Column |
is_timestamp_ntz(Column col)
Returns true if the specified VARIANT column contains a TIMESTAMP value with no time zone.
|
static Column |
is_timestamp_tz(Column col)
Returns true if the specified VARIANT column contains a TIMESTAMP value with a time zone.
|
static Column |
is_varchar(Column col)
Returns true if the specified VARIANT column contains a string value.
|
static Column |
json_extract_path_text(Column col,
Column path)
Parses a JSON string and returns the value of an element at a specified path in the resulting
JSON document.
|
static Column |
kurtosis(Column col)
Returns the population excess kurtosis of non-NULL records.
|
static Column |
lag(Column col)
Accesses data in a previous row in the same result set without having to join the table to
itself.
|
static Column |
lag(Column col,
int offset)
Accesses data in a previous row in the same result set without having to join the table to
itself.
|
static Column |
lag(Column col,
int offset,
Column defaultValue)
Accesses data in a previous row in the same result set without having to join the table to
itself.
|
static Column |
last_day(Column e)
Returns the last day of the specified date part for a date or timestamp.
|
static Column |
lead(Column col)
Accesses data in a subsequent row in the same result set without having to join the table to
itself.
|
static Column |
lead(Column col,
int offset)
Accesses data in a subsequent row in the same result set without having to join the table to
itself.
|
static Column |
lead(Column col,
int offset,
Column defaultValue)
Accesses data in a subsequent row in the same result set without having to join the table to
itself.
|
static Column |
least(Column... cols)
Returns the smallest value from a list of expressions.
|
static Column |
left(Column strExpr,
Column lengthExpr)
Returns a left most substring of strExpr.
|
static Column |
length(Column e)
Returns the length of an input string or binary value.
|
static Column |
listagg(Column col)
Returns the concatenated input values, separated by empty string.
|
static Column |
listagg(Column col,
String delimiter)
Returns the concatenated input values, separated by `delimiter` string.
|
static Column |
listagg(Column col,
String delimiter,
boolean isDistinct)
Returns the concatenated input values, separated by `delimiter` string.
|
static Column |
lit(Object literal)
Creates a Column expression for a literal value.
|
static Column |
log(Column base,
Column a)
Returns the logarithm of a numeric expression.
|
static Column |
lower(Column e)
Returns the input string with all characters converted to lowercase.
|
static Column |
lpad(Column str,
Column len,
Column pad)
Left-pads a string with characters from another string, or left-pads a binary value with bytes
from another binary value.
|
static Column |
ltrim(Column e)
Removes leading characters, including whitespace, from a string.
|
static Column |
ltrim(Column e,
Column trimString)
Removes leading characters, including whitespace, from a string.
|
static Column |
max(Column col)
Returns the maximum value for the records in a group.
|
static Column |
md5(Column e)
Returns a 32-character hex-encoded string containing the 128-bit MD5 message digest.
|
static Column |
mean(Column col)
Returns the average of non-NULL records.
|
static Column |
median(Column col)
Returns the median value for the records in a group.
|
static Column |
min(Column col)
Returns the minimum value for the records in a group.
|
static Column |
minute(Column e)
Extracts the minute from a date or timestamp.
|
static Column |
month(Column e)
Extracts the month from a date or timestamp.
|
static Column |
monthname(Column expr)
Extracts the three-letter month name from the specified date or timestamp.
|
static Column |
negate(Column col)
Returns the negation of the value in the column (equivalent to a unary minus).
|
static Column |
next_day(Column date,
Column dayOfWeek)
Returns the date of the first specified DOW (day of week) that occurs after the input date.
|
static Column |
not(Column col)
Returns the inverse of a boolean expression.
|
static Column |
ntile(Column col)
Divides an ordered data set equally into the number of buckets specified by n.
|
static Column |
object_construct(Column... key_values)
Returns an OBJECT constructed from the arguments.
|
static Column |
object_delete(Column obj,
Column key1,
Column... keys)
Returns an object containing the contents of the input (i.e.source) object with one or more
keys removed.
|
static Column |
object_insert(Column obj,
Column key,
Column value)
Returns an object consisting of the input object with a new key-value pair inserted.
|
static Column |
object_insert(Column obj,
Column key,
Column value,
Column update_flag)
Returns an object consisting of the input object with a new key-value pair inserted (or an
existing key updated with a new value).
|
static Column |
object_keys(Column obj)
Returns an array containing the list of keys in the input object.
|
static Column |
object_pick(Column obj,
Column key1,
Column... keys)
Returns a new OBJECT containing some of the key-value pairs from an existing object.
|
static Column |
objectagg(Column key,
Column value)
Returns one OBJECT per group.
|
static Column |
parse_json(Column col)
Parse the value of the specified column as a JSON string and returns the resulting JSON
document.
|
static Column |
parse_xml(Column col)
Parse the value of the specified column as a JSON string and returns the resulting XML
document.
|
static Column |
percent_rank()
Returns the relative rank of a value within a group of values, specified as a percentage
ranging from 0.0 to 1.0.
|
static Column |
pow(Column l,
Column r)
Returns a number (l) raised to the specified power (r).
|
static Column |
previous_day(Column date,
Column dayOfWeek)
Returns the date of the first specified DOW (day of week) that occurs before the input date.
|
static Column |
quarter(Column e)
Extracts the quarter from a date or timestamp.
|
static Column |
radians(Column e)
Converts degrees to radians.
|
static Column |
random()
Each call returns a pseudo-random 64-bit integer.
|
static Column |
random(long seed)
Each call returns a pseudo-random 64-bit integer.
|
static Column |
rank()
Returns the rank of a value within an ordered group of values.
|
static Column |
regexp_count(Column strExpr,
Column pattern)
Returns the number of times that a pattern occurs in a strExpr.
|
static Column |
regexp_count(Column strExpr,
Column pattern,
Column position,
Column parameters)
Returns the number of times that a pattern occurs in a strExpr.
|
static Column |
repeat(Column str,
Column n)
Builds a string by repeating the input for the specified number of times.
|
static Column |
replace(Column strExpr,
Column pattern)
Removes all occurrences of a specified strExpr, and optionally replaces them with replacement.
|
static Column |
replace(Column strExpr,
Column pattern,
Column replacement)
Removes all occurrences of a specified strExpr, and optionally replaces them with replacement.
|
static Column |
right(Column strExpr,
Column lengthExpr)
Returns a right most substring of strExpr.
|
static Column |
round(Column e)
Returns rounded values for the specified column.
|
static Column |
round(Column e,
Column scale)
Returns rounded values for the specified column.
|
static Column |
row_number()
Returns a unique row number for each row within a window partition.
|
static Column |
rpad(Column str,
Column len,
Column pad)
Right-pads a string with characters from another string, or right-pads a binary value with
bytes from another binary value.
|
static Column |
rtrim(Column e)
Removes trailing characters, including whitespace, from a string.
|
static Column |
rtrim(Column e,
Column trimString)
Removes trailing characters, including whitespace, from a string.
|
static Column |
second(Column e)
Extracts the second from a date or timestamp.
|
static Column |
seq1()
Generates a sequence of monotonically increasing integers, with wrap-around.
|
static Column |
seq1(boolean startsFromZero)
Generates a sequence of monotonically increasing integers, with wrap-around.
|
static Column |
seq2()
Generates a sequence of monotonically increasing integers, with wrap-around.
|
static Column |
seq2(boolean startsFromZero)
Generates a sequence of monotonically increasing integers, with wrap-around.
|
static Column |
seq4()
Generates a sequence of monotonically increasing integers, with wrap-around.
|
static Column |
seq4(boolean startsFromZero)
Generates a sequence of monotonically increasing integers, with wrap-around.
|
static Column |
seq8()
Generates a sequence of monotonically increasing integers, with wrap-around.
|
static Column |
seq8(boolean startsFromZero)
Generates a sequence of monotonically increasing integers, with wrap-around.
|
static Column |
sha1(Column e)
Returns a 40-character hex-encoded string containing the 160-bit SHA-1 message digest.
|
static Column |
sha2(Column e,
int numBits)
Returns a hex-encoded string containing the N-bit SHA-2 message digest, where N is the
specified output digest size.
|
static Column |
sin(Column e)
Computes the sine of its argument; the argument should be expressed in radians.
|
static Column |
sinh(Column e)
Computes the hyperbolic sine of its argument.
|
static Column |
skew(Column col)
Returns the sample skewness of non-NULL records.
|
static Column |
soundex(Column e)
Returns a string that contains a phonetic representation of the input string.
|
static Column |
split(Column str,
Column pattern)
Splits a given string with a given separator and returns the result in an array of strings.
|
static Column |
sqlExpr(String sqlText)
Creates a Column expression from row SQL text.
|
static Column |
sqrt(Column col)
Returns the square-root of a non-negative numeric expression.
|
static Column |
startswith(Column col,
Column str)
Returns true if col starts with str.
|
static Column |
stddev_pop(Column col)
Returns the population standard deviation (square root of variance) of non-NULL values.
|
static Column |
stddev_samp(Column col)
Returns the sample standard deviation (square root of sample variance) of non-NULL values.
|
static Column |
stddev(Column col)
Returns the sample standard deviation (square root of sample variance) of non-NULL values.
|
static Column |
strip_null_value(Column col)
Converts a JSON "null" value in the specified column to a SQL NULL value.
|
static Column |
strtok_to_array(Column array)
Tokenizes the given string using the given set of delimiters and returns the tokens as an
array.
|
static Column |
strtok_to_array(Column array,
Column delimiter)
Tokenizes the given string using the given set of delimiters and returns the tokens as an
array.
|
static Column |
substring(Column str,
Column pos,
Column len)
Returns the portion of the string or binary value str, starting from the character/byte
specified by pos, with limited length.
|
static Column |
sum_distinct(Column col)
Returns the sum of non-NULL distinct records in a group.
|
static Column |
sum(Column col)
Returns the sum of non-NULL records in a group.
|
static Column |
sysdate()
Returns the current timestamp for the system, but in the UTC time zone.
|
static Column |
tan(Column e)
Computes the tangent of its argument; the argument should be expressed in radians.
|
static Column |
tanh(Column e)
Computes the hyperbolic tangent of its argument.
|
static Column |
time_from_parts(Column hour,
Column minute,
Column second)
Creates a time from individual numeric components.
|
static Column |
time_from_parts(Column hour,
Column minute,
Column second,
Column nanosecond)
Creates a time from individual numeric components.
|
static Column |
timestamp_from_parts(Column dateExpr,
Column timeExpr)
Creates a timestamp from individual numeric components.
|
static Column |
timestamp_from_parts(Column year,
Column month,
Column day,
Column hour,
Column minute,
Column second)
Creates a timestamp from individual numeric components.
|
static Column |
timestamp_from_parts(Column year,
Column month,
Column day,
Column hour,
Column minute,
Column second,
Column nanosecond)
Creates a timestamp from individual numeric components.
|
static Column |
timestamp_ltz_from_parts(Column year,
Column month,
Column day,
Column hour,
Column minute,
Column second)
Creates a timestamp from individual numeric components.
|
static Column |
timestamp_ltz_from_parts(Column year,
Column month,
Column day,
Column hour,
Column minute,
Column second,
Column nanosecond)
Creates a timestamp from individual numeric components.
|
static Column |
timestamp_ntz_from_parts(Column dateExpr,
Column timeExpr)
Creates a timestamp from individual numeric components.
|
static Column |
timestamp_ntz_from_parts(Column year,
Column month,
Column day,
Column hour,
Column minute,
Column second)
Creates a timestamp from individual numeric components.
|
static Column |
timestamp_ntz_from_parts(Column year,
Column month,
Column day,
Column hour,
Column minute,
Column second,
Column nanosecond)
Creates a timestamp from individual numeric components.
|
static Column |
timestamp_tz_from_parts(Column year,
Column month,
Column day,
Column hour,
Column minute,
Column second)
Creates a timestamp from individual numeric components.
|
static Column |
timestamp_tz_from_parts(Column year,
Column month,
Column day,
Column hour,
Column minute,
Column second,
Column nanosecond)
Creates a timestamp from individual numeric components.
|
static Column |
timestamp_tz_from_parts(Column year,
Column month,
Column day,
Column hour,
Column minute,
Column second,
Column nanosecond,
Column timezone)
Creates a timestamp from individual numeric components.
|
static Column |
to_array(Column col)
Converts the input expression into an array:
|
static Column |
to_date(Column e)
Converts an input expression to a date.
|
static Column |
to_date(Column e,
Column fmt)
Converts an input expression to a date.
|
static Column |
to_decimal(Column expr,
int precision,
int scale)
Converts an input expression to a decimal
|
static Column |
to_json(Column col)
Converts any VARIANT value to a string containing the JSON representation of the value.
|
static Column |
to_object(Column col)
Converts the input value to an object:
|
static Column |
to_timestamp(Column s)
Converts an input expression into the corresponding timestamp.
|
static Column |
to_timestamp(Column s,
Column fmt)
Converts an input expression into the corresponding timestamp.
|
static Column |
to_variant(Column col)
Converts any value to VARIANT value or NULL (if input is NULL).
|
static Column |
to_xml(Column col)
Converts any VARIANT value to a string containing the XML representation of the value.
|
static Column |
toScalar(DataFrame df)
Generates a Column representing the result of the input DataFrame.
|
static Column |
translate(Column src,
Column matchingString,
Column replaceString)
Translates src from the characters in matchingString to the characters in replaceString.
|
static Column |
trim(Column e,
Column trimString)
Removes leading and trailing characters from a string.
|
static Column |
trunc(Column expr,
Column scale)
Rounds the input expression down to the nearest (or equal) integer closer to zero, or to the
nearest equal or smaller value with the specified number of places after the decimal point.
|
static UserDefinedFunction |
udf(JavaUDF0<?> func,
DataType output)
Registers a Java Lambda of 0 argument as a Snowflake UDF and returns the UDF.
|
static UserDefinedFunction |
udf(JavaUDF1<?,?> func,
DataType input,
DataType output)
Registers a Java Lambda of 1 argument as a Snowflake UDF and returns the UDF.
|
static UserDefinedFunction |
udf(JavaUDF10<?,?,?,?,?,?,?,?,?,?,?> func,
DataType[] input,
DataType output)
Registers a Java Lambda of 10 arguments as a Snowflake UDF and returns the UDF.
|
static UserDefinedFunction |
udf(JavaUDF11<?,?,?,?,?,?,?,?,?,?,?,?> func,
DataType[] input,
DataType output)
Registers a Java Lambda of 11 arguments as a Snowflake UDF and returns the UDF.
|
static UserDefinedFunction |
udf(JavaUDF12<?,?,?,?,?,?,?,?,?,?,?,?,?> func,
DataType[] input,
DataType output)
Registers a Java Lambda of 12 arguments as a Snowflake UDF and returns the UDF.
|
static UserDefinedFunction |
udf(JavaUDF13<?,?,?,?,?,?,?,?,?,?,?,?,?,?> func,
DataType[] input,
DataType output)
Registers a Java Lambda of 13 arguments as a Snowflake UDF and returns the UDF.
|
static UserDefinedFunction |
udf(JavaUDF14<?,?,?,?,?,?,?,?,?,?,?,?,?,?,?> func,
DataType[] input,
DataType output)
Registers a Java Lambda of 14 arguments as a Snowflake UDF and returns the UDF.
|
static UserDefinedFunction |
udf(JavaUDF15<?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?> func,
DataType[] input,
DataType output)
Registers a Java Lambda of 15 arguments as a Snowflake UDF and returns the UDF.
|
static UserDefinedFunction |
udf(JavaUDF16<?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?> func,
DataType[] input,
DataType output)
Registers a Java Lambda of 16 arguments as a Snowflake UDF and returns the UDF.
|
static UserDefinedFunction |
udf(JavaUDF17<?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?> func,
DataType[] input,
DataType output)
Registers a Java Lambda of 17 arguments as a Snowflake UDF and returns the UDF.
|
static UserDefinedFunction |
udf(JavaUDF18<?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?> func,
DataType[] input,
DataType output)
Registers a Java Lambda of 18 arguments as a Snowflake UDF and returns the UDF.
|
static UserDefinedFunction |
udf(JavaUDF19<?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?> func,
DataType[] input,
DataType output)
Registers a Java Lambda of 19 arguments as a Snowflake UDF and returns the UDF.
|
static UserDefinedFunction |
udf(JavaUDF2<?,?,?> func,
DataType[] input,
DataType output)
Registers a Java Lambda of 2 arguments as a Snowflake UDF and returns the UDF.
|
static UserDefinedFunction |
udf(JavaUDF20<?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?> func,
DataType[] input,
DataType output)
Registers a Java Lambda of 20 arguments as a Snowflake UDF and returns the UDF.
|
static UserDefinedFunction |
udf(JavaUDF21<?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?> func,
DataType[] input,
DataType output)
Registers a Java Lambda of 21 arguments as a Snowflake UDF and returns the UDF.
|
static UserDefinedFunction |
udf(JavaUDF22<?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?> func,
DataType[] input,
DataType output)
Registers a Java Lambda of 22 arguments as a Snowflake UDF and returns the UDF.
|
static UserDefinedFunction |
udf(JavaUDF3<?,?,?,?> func,
DataType[] input,
DataType output)
Registers a Java Lambda of 3 arguments as a Snowflake UDF and returns the UDF.
|
static UserDefinedFunction |
udf(JavaUDF4<?,?,?,?,?> func,
DataType[] input,
DataType output)
Registers a Java Lambda of 4 arguments as a Snowflake UDF and returns the UDF.
|
static UserDefinedFunction |
udf(JavaUDF5<?,?,?,?,?,?> func,
DataType[] input,
DataType output)
Registers a Java Lambda of 5 arguments as a Snowflake UDF and returns the UDF.
|
static UserDefinedFunction |
udf(JavaUDF6<?,?,?,?,?,?,?> func,
DataType[] input,
DataType output)
Registers a Java Lambda of 6 arguments as a Snowflake UDF and returns the UDF.
|
static UserDefinedFunction |
udf(JavaUDF7<?,?,?,?,?,?,?,?> func,
DataType[] input,
DataType output)
Registers a Java Lambda of 7 arguments as a Snowflake UDF and returns the UDF.
|
static UserDefinedFunction |
udf(JavaUDF8<?,?,?,?,?,?,?,?,?> func,
DataType[] input,
DataType output)
Registers a Java Lambda of 8 arguments as a Snowflake UDF and returns the UDF.
|
static UserDefinedFunction |
udf(JavaUDF9<?,?,?,?,?,?,?,?,?,?> func,
DataType[] input,
DataType output)
Registers a Java Lambda of 9 arguments as a Snowflake UDF and returns the UDF.
|
static Column |
uniform(Column min,
Column max,
Column gen)
Returns a uniformly random number, in the inclusive range (`min`, `max`)
|
static Column |
upper(Column e)
Returns the input string with all characters converted to uppercase.
|
static Column |
var_pop(Column col)
Returns the population variance of non-NULL records in a group.
|
static Column |
var_samp(Column col)
Returns the sample variance of non-NULL records in a group.
|
static Column |
variance(Column col)
Returns the sample variance of non-NULL records in a group.
|
static Column |
weekofyear(Column e)
Extracts the week of year from a date or timestamp.
|
static CaseExpr |
when(Column condition,
Column value)
Works like a cascading if-then-else statement.
|
static Column |
xmlget(Column xml,
Column tag)
Extracts the first XML element object (often referred to as simply a tag) from a content of
outer XML element object by the name of the tag
|
static Column |
xmlget(Column xml,
Column tag,
Column instance)
Extracts an XML element object (often referred to as simply a tag) from a content of outer XML
element object by the name of the tag and its instance number (counting from 0).
|
static Column |
year(Column e)
Extracts the year from a date or timestamp.
|
public static Column col(String name)
name - The column namepublic static Column col(DataFrame df)
toScalar function.
For example:
DataFrame df1 = session.sql("select * from values(1,1,1),(2,2,3) as T(c1, c2, c3)");
DataFrame df2 = session.sql("select * from values(2) as T(a)");
df1.select(Functions.col("c1"), Functions.col(df2)).show();
df - The sub-query Dataframepublic static Column toScalar(DataFrame df)
For example:
DataFrame df1 = session.sql("select * from values(1,1,1),(2,2,3) as T(c1, c2, c3)");
DataFrame df2 = session.sql("select * from values(2) as T(a)");
df1.select(Functions.col("c1"), Functions.toScalar(df2)).show();
df - The sub-query Dataframepublic static Column lit(Object literal)
literal - The literal valuepublic static Column lead(Column col, int offset, Column defaultValue)
col - The input columnoffset - The function offsetdefaultValue - The default value of lead functionpublic static Column lead(Column col, int offset)
col - The input columnoffset - The function offsetpublic static Column lead(Column col)
col - The input columnpublic static Column sqlExpr(String sqlText)
Note that the function does not interpret or check the SQL text.
sqlText - The SQL querypublic static Column approx_count_distinct(Column col)
col - The input columnpublic static Column avg(Column col)
col - The input columnpublic static Column corr(Column col1, Column col2)
col1 - The first input columncol2 - The second input columnpublic static Column count(Column col)
col - The input columnpublic static Column count_distinct(Column first, Column... remaining)
first - The first columnremaining - A column list except the first columnpublic static Column covar_pop(Column col1, Column col2)
col1 - The first columncol2 - The second columnpublic static Column covar_samp(Column col1, Column col2)
col1 - The first columncol2 - The second columnpublic static Column grouping(Column col)
col - The input columnpublic static Column grouping_id(Column... cols)
cols - A list of input columnpublic static Column kurtosis(Column col)
col - The input columnpublic static Column max(Column col)
col - The input columnpublic static Column min(Column col)
col - The input columnpublic static Column mean(Column col)
col - The input columnpublic static Column median(Column col)
col - The input columnpublic static Column skew(Column col)
col - The input columnpublic static Column stddev(Column col)
col - The input columnpublic static Column stddev_samp(Column col)
col - The input Columnpublic static Column stddev_pop(Column col)
col - The input columnpublic static Column sum(Column col)
col - The input columnpublic static Column sum_distinct(Column col)
col - The input columnpublic static Column variance(Column col)
col - The input columnpublic static Column var_samp(Column col)
col - The input columnpublic static Column var_pop(Column col)
col - The input columnpublic static Column approx_percentile(Column col, double percentile)
col - The input columnpercentile - The desired percentilepublic static Column approx_percentile_accumulate(Column col)
col - The input columnpublic static Column approx_percentile_estimate(Column col, double percentile)
col - The input columnpercentile - The desired percentilepublic static Column approx_percentile_combine(Column state)
This allows scenarios where APPROX_PERCENTILE_ACCUMULATE is run over horizontal partitions of the same table, producing an algorithm state for each table partition. These states can later be combined using APPROX_PERCENTILE_COMBINE, producing the same output state as a single run of APPROX_PERCENTILE_ACCUMULATE over the entire table.
state - The input columnpublic static Column cume_dist()
public static Column dense_rank()
public static Column lag(Column col, int offset, Column defaultValue)
col - The input columnoffset - The function offsetdefaultValue - The default valuepublic static Column lag(Column col, int offset)
col - The input columnoffset - The function offsetpublic static Column lag(Column col)
col - The input columnpublic static Column ntile(Column col)
col - The input columnpublic static Column percent_rank()
public static Column rank()
public static Column row_number()
public static Column coalesce(Column... cols)
cols - The list of input columnpublic static Column equal_nan(Column col)
col - The input columnpublic static Column is_null(Column col)
col - The input columnpublic static Column negate(Column col)
col - The input columnpublic static Column not(Column col)
col - The input columnpublic static Column random(long seed)
seed - The random seedpublic static Column random()
public static Column bitnot(Column col)
col - The input valuepublic static Column to_decimal(Column expr, int precision, int scale)
expr - The input columnprecision - The precisionscale - The scalepublic static Column div0(Column dividend, Column divisor)
dividend - The dividenddivisor - The divisorpublic static Column sqrt(Column col)
col - The input columnpublic static Column abs(Column col)
col - The input columnpublic static Column acos(Column col)
col - The input columnpublic static Column asin(Column col)
col - The input columnpublic static Column atan(Column col)
col - The input columnpublic static Column atan2(Column y, Column x)
y - The value of yx - The value of xpublic static Column ceil(Column col)
col - The input columnpublic static Column floor(Column col)
col - The input columnpublic static Column cos(Column col)
col - The input columnpublic static Column cosh(Column col)
col - The input columnpublic static Column exp(Column col)
col - The input columnpublic static Column factorial(Column col)
col - The input columnpublic static Column greatest(Column... cols)
cols - The list of input columnpublic static Column least(Column... cols)
cols - The list of input columnpublic static Column log(Column base, Column a)
base - The value of basea - the value of Apublic static Column pow(Column l, Column r)
l - The value of lr - The value of rpublic static Column round(Column e, Column scale)
e - The input columnscale - The scalepublic static Column round(Column e)
e - The input columnpublic static Column bitshiftleft(Column e, Column numBits)
e - The input columnnumBits - The number of bitspublic static Column bitshiftright(Column e, Column numBits)
e - The input columnnumBits - The number of bitspublic static Column sin(Column e)
e - The input columnpublic static Column sinh(Column e)
e - The input columnpublic static Column tan(Column e)
e - The input columnpublic static Column tanh(Column e)
e - The input columnpublic static Column degrees(Column e)
e - The input columnpublic static Column radians(Column e)
e - The input columnpublic static Column md5(Column e)
e - The input columnpublic static Column sha1(Column e)
e - The input columnpublic static Column sha2(Column e, int numBits)
e - The input columnnumBits - The number of bitspublic static Column hash(Column... cols)
cols - The list of input columnpublic static Column ascii(Column e)
e - The input columnpublic static Column concat_ws(Column separator, Column... exprs)
separator - The separatorexprs - The list of input valuespublic static Column initcap(Column e)
e - The input columnpublic static Column length(Column e)
e - The input columnpublic static Column lower(Column e)
e - The input columnpublic static Column upper(Column e)
e - The input columnpublic static Column lpad(Column str, Column len, Column pad)
str - The input stringlen - The lengthpad - The padpublic static Column rpad(Column str, Column len, Column pad)
str - The input stringlen - The lengthpad - The padpublic static Column ltrim(Column e, Column trimString)
e - The input columntrimString - The trim stringpublic static Column ltrim(Column e)
e - The input columnpublic static Column rtrim(Column e, Column trimString)
e - The input columntrimString - The trim stringpublic static Column rtrim(Column e)
e - The input columnpublic static Column trim(Column e, Column trimString)
e - The input columntrimString - The trim stringpublic static Column repeat(Column str, Column n)
str - The input stringn - The time of repeatpublic static Column soundex(Column e)
e - The input columnpublic static Column split(Column str, Column pattern)
str - The input stringpattern - The patternpublic static Column substring(Column str, Column pos, Column len)
str - The input stringlen - The lengthpos - The positionpublic static Column any_value(Column e)
e - The input columnpublic static Column translate(Column src, Column matchingString, Column replaceString)
src - The source columnmatchingString - The matching stringreplaceString - The replacementpublic static Column contains(Column col, Column str)
col - The input columnstr - The target stringpublic static Column startswith(Column col, Column str)
col - The input columnstr - The target stringpublic static Column chr(Column col)
alias for Snowflake char function.
col - The input columnpublic static Column add_months(Column startDate, Column numMonths)
startDate - The start datenumMonths - the number of Monthspublic static Column current_date()
public static Column current_timestamp()
public static Column current_region()
public static Column current_time()
public static Column current_version()
public static Column current_account()
public static Column current_role()
public static Column current_available_roles()
public static Column current_session()
public static Column current_statement()
public static Column current_user()
public static Column current_database()
public static Column current_schema()
public static Column current_schemas()
public static Column current_warehouse()
public static Column sysdate()
public static Column convert_timezone(Column sourceTimeZone, Column targetTimeZone, Column sourceTimestampNTZ)
Supported time zones are listed here
Example
df.select(Functions.convert_timezone(Functions.lit("America/Los_Angeles"),
Functions.lit("America/New_York"), df.col("time")));
sourceTimestampNTZ - The timestamptargetTimeZone - The target time zonesourceTimeZone - The source time zonepublic static Column convert_timezone(Column targetTimeZone, Column sourceTimestamp)
Supported time zones are listed here
Example
df.select(Functions.convert_timezone(Functions.lit("America/New_York"), df.col("time")));
sourceTimestamp - The timestamptargetTimeZone - The target time zonepublic static Column year(Column e)
e - The input columnpublic static Column quarter(Column e)
e - The input columnpublic static Column month(Column e)
e - The input columnpublic static Column dayofweek(Column e)
e - The input columnpublic static Column dayofmonth(Column e)
e - The input columnpublic static Column dayofyear(Column e)
e - The input columnpublic static Column last_day(Column e)
e - The input columnpublic static Column weekofyear(Column e)
e - The input columnpublic static Column hour(Column e)
e - The input columnpublic static Column minute(Column e)
e - The input columnpublic static Column second(Column e)
e - The input columnpublic static Column next_day(Column date, Column dayOfWeek)
date - The datedayOfWeek - The day of weekpublic static Column previous_day(Column date, Column dayOfWeek)
date - The datedayOfWeek - The day of weekpublic static Column to_timestamp(Column s)
s - The input columnpublic static Column to_timestamp(Column s, Column fmt)
s - The input valuefmt - The time formatpublic static Column to_date(Column e)
e - The input valuepublic static Column to_date(Column e, Column fmt)
e - The input valuefmt - The time formatpublic static Column date_from_parts(Column year, Column month, Column day)
year - The yearmonth - The monthday - The daypublic static Column time_from_parts(Column hour, Column minute, Column second, Column nanosecond)
hour - The hourminute - The minutesecond - The secondnanosecond - The nanosecondpublic static Column time_from_parts(Column hour, Column minute, Column second)
hour - The hourminute - The minutesecond - The secondpublic static Column timestamp_from_parts(Column year, Column month, Column day, Column hour, Column minute, Column second)
year - The yearmonth - The monthday - The dayhour - The hourminute - The minutesecond - The secondpublic static Column timestamp_from_parts(Column year, Column month, Column day, Column hour, Column minute, Column second, Column nanosecond)
year - The yearmonth - The monthday - The dayhour - The hourminute - The minutesecond - The secondnanosecond - The nanosecondpublic static Column timestamp_from_parts(Column dateExpr, Column timeExpr)
dateExpr - The date expressiontimeExpr - The time expressionpublic static Column timestamp_ltz_from_parts(Column year, Column month, Column day, Column hour, Column minute, Column second)
year - The yearmonth - The monthday - The dayhour - The hourminute - The minutesecond - The secondpublic static Column timestamp_ltz_from_parts(Column year, Column month, Column day, Column hour, Column minute, Column second, Column nanosecond)
year - The yearmonth - The monthday - The dayhour - The hourminute - The minutesecond - The secondnanosecond - The nanosecondpublic static Column timestamp_ntz_from_parts(Column year, Column month, Column day, Column hour, Column minute, Column second)
year - The yearmonth - The monthday - The dayhour - The hourminute - The minutesecond - The secondpublic static Column timestamp_ntz_from_parts(Column year, Column month, Column day, Column hour, Column minute, Column second, Column nanosecond)
year - The yearmonth - The monthday - The dayhour - The hourminute - The minutesecond - The secondnanosecond - The nanosecondpublic static Column timestamp_ntz_from_parts(Column dateExpr, Column timeExpr)
dateExpr - The date expressiontimeExpr - The time expressionpublic static Column timestamp_tz_from_parts(Column year, Column month, Column day, Column hour, Column minute, Column second)
year - The yearmonth - The monthday - The dayhour - The hourminute - The minutesecond - The secondpublic static Column timestamp_tz_from_parts(Column year, Column month, Column day, Column hour, Column minute, Column second, Column nanosecond)
year - The yearmonth - The monthday - The dayhour - The hourminute - The minutesecond - The secondnanosecond - The nanosecondpublic static Column timestamp_tz_from_parts(Column year, Column month, Column day, Column hour, Column minute, Column second, Column nanosecond, Column timezone)
year - The yearmonth - The monthday - The dayhour - The hourminute - The minutesecond - The secondnanosecond - The nanosecondtimezone - The time zonepublic static Column dayname(Column expr)
expr - The input valuepublic static Column monthname(Column expr)
expr - The input valuepublic static Column dateadd(String part, Column value, Column expr)
Supported date and time parts are listed here
Example: add one year on dates
date.select(Functions.dateadd("year", Functions.lit(1), date.col("date_col")))
part - The part of time being addedvalue - The value being addedexpr - The input valuepublic static Column datediff(String part, Column col1, Column col2)
Supported date and time parts are listed here
Example: year difference between two date columns
date.select(Functions.datediff("year", date.col("date_col1"), date.col("date_col2")))
part - The part of timecol1 - The first input valuecol2 - The second input valuepublic static Column trunc(Column expr, Column scale)
expr - The input valuescale - The scalepublic static Column date_trunc(String format, Column timestamp)
format - The time formattimestamp - The input timestamppublic static Column concat(Column... exprs)
exprs - A list of input valuespublic static Column arrays_overlap(Column a1, Column a2)
a1 - The first input arraya2 - The second input arraypublic static Column endswith(Column expr, Column str)
expr - The input valuestr - The ending stringpublic static Column insert(Column baseExpr, Column position, Column length, Column insertExpr)
baseExpr - The base expressionposition - The positioninsertExpr - The new expressionlength - The lengthpublic static Column left(Column strExpr, Column lengthExpr)
strExpr - The input stringlengthExpr - The lengthpublic static Column right(Column strExpr, Column lengthExpr)
strExpr - The input stringlengthExpr - The lengthpublic static Column regexp_count(Column strExpr, Column pattern, Column position, Column parameters)
Pattern syntax is specified here
Parameter detail is specified here
strExpr - The input stringpattern - The patternposition - The positionparameters - The parameterspublic static Column regexp_count(Column strExpr, Column pattern)
Pattern syntax is specified here
Parameter detail is specified here
strExpr - The input stringpattern - The patternpublic static Column replace(Column strExpr, Column pattern, Column replacement)
strExpr - The input stringpattern - The patternreplacement - The replacement stringpublic static Column replace(Column strExpr, Column pattern)
strExpr - The input stringpattern - The patternpublic static Column charindex(Column targetExpr, Column sourceExpr)
sourceExpr - The source valuetargetExpr - The target valuepublic static Column charindex(Column targetExpr, Column sourceExpr, Column position)
sourceExpr - The source valuetargetExpr - The target valueposition - The positionpublic static Column collate(Column expr, String collationSpec)
Collation Specification is specified here
expr - The input valuecollationSpec - The collation specificationpublic static Column collation(Column expr)
expr - The input valuepublic static Column array_intersection(Column col1, Column col2)
col1 - The first input arraycol2 - The second input arraypublic static Column is_array(Column col)
col - The input valuepublic static Column is_boolean(Column col)
col - The input valuepublic static Column is_binary(Column col)
col - The input valuepublic static Column is_char(Column col)
col - The input valuepublic static Column is_varchar(Column col)
col - The input valuepublic static Column is_date(Column col)
col - The input valuepublic static Column is_date_value(Column col)
col - The input valuepublic static Column is_decimal(Column col)
col - The input valuepublic static Column is_double(Column col)
col - The input valuepublic static Column is_real(Column col)
col - The input valuepublic static Column is_integer(Column col)
col - The input valuepublic static Column is_null_value(Column col)
col - The input valuepublic static Column is_object(Column col)
col - The input valuepublic static Column is_time(Column col)
col - The input valuepublic static Column is_timestamp_ltz(Column col)
col - The input valuepublic static Column is_timestamp_ntz(Column col)
col - The input valuepublic static Column is_timestamp_tz(Column col)
col - The input valuepublic static Column check_json(Column col)
col - The input valuepublic static Column check_xml(Column col)
col - The input valuepublic static Column json_extract_path_text(Column col, Column path)
col - Column containing the JSON string that should be parsed.path - Column containing the path to the element that should be extracted.public static Column parse_json(Column col)
col - The input valuepublic static Column parse_xml(Column col)
col - The input valuepublic static Column strip_null_value(Column col)
col - The input valuepublic static Column array_agg(Column col)
col - The input valuepublic static Column array_append(Column array, Column element)
array - The column containing the source ARRAY.element - The column containing the element to be appended. The element may be of almost
any data type. The data type does not need to match the data type(s) of the existing
elements in the ARRAY.public static Column array_cat(Column array1, Column array2)
array1 - Column containing the source ARRAY.array2 - Column containing the ARRAY to be appended to array1.public static Column array_compact(Column array)
array - The input arraypublic static Column array_construct(Column... cols)
cols - Columns containing the values (or expressions that evaluate to values). The values
do not all need to be of the same data type.public static Column array_construct_compact(Column... cols)
cols - Columns containing the values (or expressions that evaluate to values). The values
do not all need to be of the same data type.public static Column array_contains(Column variant, Column array)
true if the specified VARIANT is found in the specified ARRAY.variant - Column containing the VARIANT to find.array - Column containing the ARRAY to search.public static Column array_insert(Column array, Column pos, Column element)
array - Column containing the source ARRAY.pos - Column containing a (zero-based) position in the source ARRAY. The new element is
inserted at this position. The original element from this position (if any) and all
subsequent elements (if any) are shifted by one position to the right in the resulting
array (i.e. inserting at position 0 has the same effect as using [[array_prepend]]). A
negative position is interpreted as an index from the back of the array (e.g. -1
results in insertion before the last element in the array).element - Column containing the element to be inserted. The new element is located at
position pos. The relative order of the other elements from the source array is
preserved.public static Column array_position(Column variant, Column array)
variant - Column containing the VARIANT value that you want to find. The function searches
for the first occurrence of this value in the array.array - Column containing the ARRAY to be searched.public static Column array_prepend(Column array, Column element)
array - Column containing the source ARRAY.element - Column containing the element to be prepended.public static Column array_size(Column array)
If the specified column contains a VARIANT value that contains an ARRAY, the size of the ARRAY is returned; otherwise, NULL is returned if the value is not an ARRAY.
array - The input arraypublic static Column array_slice(Column array, Column from, Column to)
array - Column containing the source ARRAY.from - Column containing a position in the source ARRAY. The position of the first element
is 0. Elements from positions less than this parameter are not included in the
resulting ARRAY.to - Column containing a position in the source ARRAY. Elements from positions equal to or
greater than this parameter are not included in the resulting array.public static Column array_to_string(Column array, Column separator)
array - Column containing the ARRAY of elements to convert to a string.separator - Column containing the string to put between each element (e.g. a space, comma,
or other human-readable separator).public static Column objectagg(Column key, Column value)
key - The keyvalue - The valuepublic static Column object_construct(Column... key_values)
key_values - The key and valuepublic static Column object_delete(Column obj, Column key1, Column... keys)
obj - The input objectkey1 - The key being removedkeys - A list of keys being removed except key1public static Column object_insert(Column obj, Column key, Column value)
obj - The input objectkey - The keyvalue - The valuepublic static Column object_insert(Column obj, Column key, Column value, Column update_flag)
obj - The input objectkey - The keyvalue - The valueupdate_flag - The flagspublic static Column object_pick(Column obj, Column key1, Column... keys)
To identify the key-value pairs to include in the new object, pass in the keys as arguments, or pass in an array containing the keys.
If a specified key is not present in the input object, the key is ignored.
obj - The input objectkey1 - The keykeys - A list of keys except key1public static Column as_array(Column variant)
variant - The input variantpublic static Column as_binary(Column variant)
variant - The input variantpublic static Column as_char(Column variant)
variant - The input variantpublic static Column as_varchar(Column variant)
variant - The input variantpublic static Column as_date(Column variant)
variant - The input variantpublic static Column as_decimal(Column variant)
variant - The input variantpublic static Column as_decimal(Column variant, int precision)
variant - The input variantprecision - The precisionpublic static Column as_decimal(Column variant, int precision, int scale)
variant - The input variantprecision - The precisionscale - The scalepublic static Column as_number(Column variant)
variant - The input variantpublic static Column as_number(Column variant, int precision)
variant - The input variantprecision - The precisionpublic static Column as_number(Column variant, int precision, int scale)
variant - The input variantprecision - The precisionscale - The scalepublic static Column as_double(Column variant)
variant - The input variantpublic static Column as_real(Column variant)
variant - The input variantpublic static Column as_integer(Column variant)
variant - The input variantpublic static Column as_object(Column variant)
variant - The input variantpublic static Column as_time(Column variant)
variant - The input variantpublic static Column as_timestamp_ltz(Column variant)
variant - The input variantpublic static Column as_timestamp_ntz(Column variant)
variant - The input variantpublic static Column as_timestamp_tz(Column variant)
variant - The input variantpublic static Column strtok_to_array(Column array)
array - The input arraypublic static Column strtok_to_array(Column array, Column delimiter)
array - The input arraydelimiter - The delimiterpublic static Column to_array(Column col)
If the input is an ARRAY, or VARIANT containing an array value, the result is unchanged. For NULL or a JSON null input, returns NULL. For any other value, the result is a single-element array containing this value.
col - The input valuepublic static Column to_json(Column col)
col - The input valuepublic static Column to_object(Column col)
For a variant value containing an object, returns this object (in a value of type OBJECT). For a variant value containing JSON null or for NULL input, returns NULL. For all other input values, reports an error.
col - The input valuepublic static Column to_variant(Column col)
col - The input valuepublic static Column to_xml(Column col)
col - The input valuepublic static Column get(Column col1, Column col2)
col1 - The first input valuecol2 - The second input valuepublic static Column get_ignore_case(Column obj, Column field)
obj - The input objectfield - The fieldpublic static Column object_keys(Column obj)
obj - The input objectpublic static Column xmlget(Column xml, Column tag, Column instance)
xml - The input xmltag - The taginstance - The instancepublic static Column xmlget(Column xml, Column tag)
xml - The input xmltag - The tagpublic static Column get_path(Column col, Column path)
col - The input valuepath - The pathpublic static CaseExpr when(Column condition, Column value)
import com.snowflake.snowpark_java.Functions;
df.select(Functions
.when(df.col("col").is_null, Functions.lit(1))
.when(df.col("col").equal_to(Functions.lit(1)), Functions.lit(6))
.otherwise(Functions.lit(7)));
condition - The conditionvalue - The result valuepublic static Column iff(Column condition, Column expr1, Column expr2)
This is equivalent to an `if-then-else` expression. If `condition` evaluates to TRUE, the function returns `expr1`. Otherwise, the function returns `expr2`.
condition - The condition to evaluate.expr1 - The expression to return if the condition evaluates to TRUE.expr2 - The expression to return if the condition is not TRUE (i.e. if it is FALSE or
NULL).public static Column in(Column[] columns, List<List<Object>> values)
The expression evaluates to true if the values in a row matches the values in one of the specified sequences.
For example, the following code returns a DataFrame that contains the rows in which the columns `c1` and `c2` contain the values: - `1` and `"a"`, or - `2` and `"b"` This is equivalent to `SELECT * FROM table WHERE (c1, c2) IN ((1, 'a'), (2, 'b'))`.
import com.snowflake.snowpark_java.Functions;
df.filter(Functions.in(new Column[]{df.col("c1"), df.col("c2")},
Arrays.asList(Array.asList(1, "a"), Array.asList(2, "b"))));
columns - A sequence of the columns to compare for the IN operation.values - A sequence containing the sequences of values to compare for the IN operation.public static Column in(Column[] columns, DataFrame df)
The expression evaluates to true if the value in the column is one of the values in the column of the same name in a specified DataFrame.
For example, the following code returns a DataFrame that contains the rows where the values of the columns `c1` and `c2` in `df2` match the values of the columns `a` and `b` in `df1`. This is equivalent to SELECT * FROM table2 WHERE (c1, c2) IN (SELECT a, b FROM table1).
import com.snowflake.snowpark_java.Functions;
import com.snowflake.snowpark_java.DataFrame;
DataFrame df1 = session.sql("select a, b from table1");
DataFrame df2 = session.table("table2");
df2.filter(Functions.in(new Column[]{df2.col("c1"), df2.col("c2")}, df1));
columns - A sequence of the columns to compare for the IN operation.df - The DataFrame used as the values for the IN operationpublic static Column seq1()
public static Column seq1(boolean startsFromZero)
startsFromZero - if true, the sequence continues at 0 after wrap-around, otherwise,
continues at the smallest representable number based on the given integer width.public static Column seq2()
public static Column seq2(boolean startsFromZero)
startsFromZero - if true, the sequence continues at 0 after wrap-around, otherwise,
continues at the smallest representable number based on the given integer width.public static Column seq4()
public static Column seq4(boolean startsFromZero)
startsFromZero - if true, the sequence continues at 0 after wrap-around, otherwise,
continues at the smallest representable number based on the given integer width.public static Column seq8()
public static Column seq8(boolean startsFromZero)
startsFromZero - if true, the sequence continues at 0 after wrap-around, otherwise,
continues at the smallest representable number based on the given integer width.public static Column uniform(Column min, Column max, Column gen)
For example: {{{ import com.snowflake.snowpark_java.Functions; session.generator(10, Functions.seq4(), Functions.uniform(Functions.lit(1), Functions.lit(5), Functions.random())).show() }}}
min - The lower boundmax - The upper boundgen - The generator expression for the function. for more information, see
herepublic static Column listagg(Column col, String delimiter, boolean isDistinct)
For example:
df.groupBy(df.col("col1")).agg(Functions.listagg(df.col("col2"), ",")
.withinGroup(df.col("col2").asc()))
df.select(Functions.listagg(df.col("col2"), ",", false))
col - The expression (typically a Column) that determines the values to be put into the
list. The expression should evaluate to a string, or to a data type that can be cast to
string.delimiter - A string delimiter.isDistinct - Whether the input expression is distinct.public static Column listagg(Column col, String delimiter)
For example:
df.groupBy(df.col("col1")).agg(Functions.listagg(df.col("col2"), ",")
.withinGroup(df.col("col2").asc()))
df.select(Functions.listagg(df.col("col2"), ",", false))
col - The expression (typically a Column) that determines the values to be put into the
list. The expression should evaluate to a string, or to a data type that can be cast to
string.delimiter - A string delimiter.public static Column listagg(Column col)
For example:
df.groupBy(df.col("col1")).agg(Functions.listagg(df.col("col2"), ",")
.withinGroup(df.col("col2").asc()))
df.select(Functions.listagg(df.col("col2"), ",", false))
col - The expression (typically a Column) that determines the values to be put into the
list. The expression should evaluate to a string, or to a data type that can be cast to
string.public static Column callUDF(String udfName, Column... cols)
udfName - The name of UDFcols - The list of parameterspublic static UserDefinedFunction udf(JavaUDF0<?> func, DataType output)
func - the Java lambda to be registeredoutput - the UDF return types.DataTypepublic static UserDefinedFunction udf(JavaUDF1<?,?> func, DataType input, DataType output)
func - the Java lambda to be registeredinput - the UDF input types.DataTypeoutput - the UDF return types.DataTypepublic static UserDefinedFunction udf(JavaUDF2<?,?,?> func, DataType[] input, DataType output)
func - the Java lambda to be registeredinput - the UDF input types.DataTypesoutput - the UDF return types.DataTypepublic static UserDefinedFunction udf(JavaUDF3<?,?,?,?> func, DataType[] input, DataType output)
func - the Java lambda to be registeredinput - the UDF input types.DataTypesoutput - the UDF return types.DataTypepublic static UserDefinedFunction udf(JavaUDF4<?,?,?,?,?> func, DataType[] input, DataType output)
func - the Java lambda to be registeredinput - the UDF input types.DataTypesoutput - the UDF return types.DataTypepublic static UserDefinedFunction udf(JavaUDF5<?,?,?,?,?,?> func, DataType[] input, DataType output)
func - the Java lambda to be registeredinput - the UDF input types.DataTypesoutput - the UDF return types.DataTypepublic static UserDefinedFunction udf(JavaUDF6<?,?,?,?,?,?,?> func, DataType[] input, DataType output)
func - the Java lambda to be registeredinput - the UDF input types.DataTypesoutput - the UDF return types.DataTypepublic static UserDefinedFunction udf(JavaUDF7<?,?,?,?,?,?,?,?> func, DataType[] input, DataType output)
func - the Java lambda to be registeredinput - the UDF input types.DataTypesoutput - the UDF return types.DataTypepublic static UserDefinedFunction udf(JavaUDF8<?,?,?,?,?,?,?,?,?> func, DataType[] input, DataType output)
func - the Java lambda to be registeredinput - the UDF input types.DataTypesoutput - the UDF return types.DataTypepublic static UserDefinedFunction udf(JavaUDF9<?,?,?,?,?,?,?,?,?,?> func, DataType[] input, DataType output)
func - the Java lambda to be registeredinput - the UDF input types.DataTypesoutput - the UDF return types.DataTypepublic static UserDefinedFunction udf(JavaUDF10<?,?,?,?,?,?,?,?,?,?,?> func, DataType[] input, DataType output)
func - the Java lambda to be registeredinput - the UDF input types.DataTypesoutput - the UDF return types.DataTypepublic static UserDefinedFunction udf(JavaUDF11<?,?,?,?,?,?,?,?,?,?,?,?> func, DataType[] input, DataType output)
func - the Java lambda to be registeredinput - the UDF input types.DataTypesoutput - the UDF return types.DataTypepublic static UserDefinedFunction udf(JavaUDF12<?,?,?,?,?,?,?,?,?,?,?,?,?> func, DataType[] input, DataType output)
func - the Java lambda to be registeredinput - the UDF input types.DataTypesoutput - the UDF return types.DataTypepublic static UserDefinedFunction udf(JavaUDF13<?,?,?,?,?,?,?,?,?,?,?,?,?,?> func, DataType[] input, DataType output)
func - the Java lambda to be registeredinput - the UDF input types.DataTypesoutput - the UDF return types.DataTypepublic static UserDefinedFunction udf(JavaUDF14<?,?,?,?,?,?,?,?,?,?,?,?,?,?,?> func, DataType[] input, DataType output)
func - the Java lambda to be registeredinput - the UDF input types.DataTypesoutput - the UDF return types.DataTypepublic static UserDefinedFunction udf(JavaUDF15<?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?> func, DataType[] input, DataType output)
func - the Java lambda to be registeredinput - the UDF input types.DataTypesoutput - the UDF return types.DataTypepublic static UserDefinedFunction udf(JavaUDF16<?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?> func, DataType[] input, DataType output)
func - the Java lambda to be registeredinput - the UDF input types.DataTypesoutput - the UDF return types.DataTypepublic static UserDefinedFunction udf(JavaUDF17<?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?> func, DataType[] input, DataType output)
func - the Java lambda to be registeredinput - the UDF input types.DataTypesoutput - the UDF return types.DataTypepublic static UserDefinedFunction udf(JavaUDF18<?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?> func, DataType[] input, DataType output)
func - the Java lambda to be registeredinput - the UDF input types.DataTypesoutput - the UDF return types.DataTypepublic static UserDefinedFunction udf(JavaUDF19<?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?> func, DataType[] input, DataType output)
func - the Java lambda to be registeredinput - the UDF input types.DataTypesoutput - the UDF return types.DataTypepublic static UserDefinedFunction udf(JavaUDF20<?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?> func, DataType[] input, DataType output)
func - the Java lambda to be registeredinput - the UDF input types.DataTypesoutput - the UDF return types.DataTypepublic static UserDefinedFunction udf(JavaUDF21<?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?> func, DataType[] input, DataType output)
func - the Java lambda to be registeredinput - the UDF input types.DataTypesoutput - the UDF return types.DataTypepublic static UserDefinedFunction udf(JavaUDF22<?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?> func, DataType[] input, DataType output)
func - the Java lambda to be registeredinput - the UDF input types.DataTypesoutput - the UDF return types.DataType© 2022 Snowflake Inc. All Rights Reserved