Functions¶
Normal Functions¶
|
Returns a |
|
Returns a |
|
Creates a new map column. |
|
Creates a |
|
Creates a new array column. |
|
Creates a new map from two arrays. |
|
Marks a DataFrame as small enough for use in broadcast joins. |
|
Returns the first column that is not null. |
Creates a string column for the file name of the current Spark task. |
|
|
An expression that returns true iff the column is NaN. |
|
An expression that returns true iff the column is null. |
A column that generates monotonically increasing 64-bit integers. |
|
|
Returns col1 if it is not NaN, or col2 if col1 is NaN. |
|
Generates a random column with independent and identically distributed (i.i.d.) samples uniformly distributed in [0.0, 1.0). |
|
Generates a column with independent and identically distributed (i.i.d.) samples from the standard normal distribution. |
A column for partition ID. |
|
|
Creates a new struct column. |
|
Evaluates a list of conditions and returns one of multiple possible result expressions. |
|
Computes bitwise not. |
|
Computes bitwise not. |
|
Parses the expression string into the column that it represents |
|
Returns the greatest value of the list of column names, skipping null values. |
|
Returns the least value of the list of column names, skipping null values. |
Math Functions¶
|
Computes the square root of the specified float value. |
|
Computes the absolute value. |
|
Computes inverse cosine of the input column. |
|
Computes inverse hyperbolic cosine of the input column. |
|
Computes inverse sine of the input column. |
|
Computes inverse hyperbolic sine of the input column. |
|
Compute inverse tangent of the input column. |
|
Computes inverse hyperbolic tangent of the input column. |
|
|
|
Returns the string representation of the binary value of the given column. |
|
Computes the cube-root of the given value. |
|
Computes the ceiling of the given value. |
|
Convert a number in a string column from one base to another. |
|
Computes cosine of the input column. |
|
Computes hyperbolic cosine of the input column. |
|
Computes cotangent of the input column. |
|
Computes cosecant of the input column. |
|
Computes the exponential of the given value. |
|
Computes the exponential of the given value minus one. |
|
Computes the factorial of the given value. |
|
Computes the floor of the given value. |
|
Computes hex value of the given column, which could be |
|
Inverse of hex. |
|
Computes |
|
Returns the first argument-based logarithm of the second argument. |
|
Computes the logarithm of the given value in Base 10. |
|
Computes the natural logarithm of the given value plus one. |
|
Returns the base-2 logarithm of the argument. |
|
Returns the value of the first argument raised to the power of the second argument. |
|
Returns the double value that is closest in value to the argument and is equal to a mathematical integer. |
|
Round the given value to scale decimal places using HALF_UP rounding mode if scale >= 0 or at integral part when scale < 0. |
|
Round the given value to scale decimal places using HALF_EVEN rounding mode if scale >= 0 or at integral part when scale < 0. |
|
Computes secant of the input column. |
|
Shift the given value numBits left. |
|
(Signed) shift the given value numBits right. |
|
Unsigned shift the given value numBits right. |
|
Computes the signum of the given value. |
|
Computes sine of the input column. |
|
Computes hyperbolic sine of the input column. |
|
Computes tangent of the input column. |
|
Computes hyperbolic tangent of the input column. |
|
Use |
|
Converts an angle measured in radians to an approximately equivalent angle measured in degrees. |
|
Use |
|
Converts an angle measured in degrees to an approximately equivalent angle measured in radians. |
Datetime Functions¶
|
Returns the date that is months months after start |
Returns the current date at the start of query evaluation as a |
|
Returns the current timestamp at the start of query evaluation as a |
|
|
Returns the date that is days days after start |
|
Converts a date/timestamp/string to a value of string in the format specified by the date format given by the second argument. |
|
Returns the date that is days days before start |
|
Returns timestamp truncated to the unit specified by the format. |
|
Returns the number of days from start to end. |
|
Extract the day of the month of a given date as integer. |
|
Extract the day of the week of a given date as integer. |
|
Extract the day of the year of a given date as integer. |
|
Extract the seconds of a given date as integer. |
|
Extract the week number of a given date as integer. |
|
Extract the year of a given date as integer. |
|
Extract the quarter of a given date as integer. |
|
Extract the month of a given date as integer. |
|
Returns the last day of the month which the given date belongs to. |
|
Extract the minutes of a given date as integer. |
|
Returns number of months between dates date1 and date2. |
|
Returns the first date which is later than the value of the date column. |
|
Extract the hours of a given date as integer. |
|
Returns a column with a date built from the year, month and day columns. |
|
Converts the number of seconds from unix epoch (1970-01-01 00:00:00 UTC) to a string representing the timestamp of that moment in the current system time zone in the given format. |
|
Convert time string with given pattern (‘yyyy-MM-dd HH:mm:ss’, by default) to Unix time stamp (in seconds), using the default timezone and the default locale, return null if fail. |
|
Converts a |
|
Converts a |
|
Returns date truncated to the unit specified by the format. |
|
This is a common function for databases supporting TIMESTAMP WITHOUT TIMEZONE. |
|
This is a common function for databases supporting TIMESTAMP WITHOUT TIMEZONE. |
|
Bucketize rows into one or more time windows given a timestamp specifying column. |
|
Generates session window given a timestamp specifying column. |
|
Converts the number of seconds from the Unix epoch (1970-01-01T00:00:00Z) to a timestamp. |
Collection Functions¶
|
Collection function: returns null if the array is null, true if the array contains the given value, and false otherwise. |
|
Collection function: returns true if the arrays contain any common non-null element; if not, returns null if both the arrays are non-empty and any of them contains a null element; returns false otherwise. |
|
Collection function: returns an array containing all the elements in x from index start (array indices start at 1, or from the end if start is negative) with the specified length. |
|
Concatenates the elements of column using the delimiter. |
|
Concatenates multiple input columns together into a single column. |
|
Collection function: Locates the position of the first occurrence of the given value in the given array. |
|
Collection function: Returns element of array at given index in extraction if col is array. |
|
Collection function: sorts the input array in ascending order. |
|
Collection function: Remove all elements that equal to element from the given array. |
|
Collection function: removes duplicate values from the array. |
|
Collection function: returns an array of the elements in the intersection of col1 and col2, without duplicates. |
|
Collection function: returns an array of the elements in the union of col1 and col2, without duplicates. |
|
Collection function: returns an array of the elements in col1 but not in col2, without duplicates. |
|
Returns an array of elements after applying a transformation to each element in the input array. |
|
Returns whether a predicate holds for one or more elements in the array. |
|
Returns whether a predicate holds for every element in the array. |
|
Returns an array of elements for which a predicate holds in a given array. |
|
Applies a binary operator to an initial state and all elements in the array, and reduces this to a single state. |
|
Merge two given arrays, element-wise, into a single array using a function. |
|
Applies a function to every key-value pair in a map and returns a map with the results of those applications as the new keys for the pairs. |
|
Applies a function to every key-value pair in a map and returns a map with the results of those applications as the new values for the pairs. |
|
Returns a map whose key-value pairs satisfy a predicate. |
|
Merge two given maps, key-wise into a single map using a function. |
|
Returns a new row for each element in the given array or map. |
|
Returns a new row for each element in the given array or map. |
|
Returns a new row for each element with position in the given array or map. |
|
Returns a new row for each element with position in the given array or map. |
|
Extracts json object from a json string based on json path specified, and returns json string of the extracted json object. |
|
Creates a new row for a json column according to the given field names. |
|
Parses a column containing a JSON string into a |
|
Parses a JSON string and infers its schema in DDL format. |
|
Converts a column containing a |
|
Collection function: returns the length of the array or map stored in the column. |
|
Collection function: sorts the input array in ascending or descending order according to the natural ordering of the array elements. |
|
Collection function: returns the maximum value of the array. |
|
Collection function: returns the minimum value of the array. |
|
Collection function: Generates a random permutation of the given array. |
|
Collection function: returns a reversed string or an array with reverse order of elements. |
|
Collection function: creates a single array from an array of arrays. |
|
Generate a sequence of integers from start to stop, incrementing by step. |
|
Collection function: creates an array containing a column repeated count times. |
|
Collection function: Returns an unordered array containing the keys of the map. |
|
Collection function: Returns an unordered array containing the values of the map. |
|
Collection function: Returns an unordered array of all entries in the given map. |
|
Collection function: Returns a map created from the given array of entries. |
|
Collection function: Returns a merged array of structs in which the N-th struct contains all N-th values of input arrays. |
|
Returns the union of all the given maps. |
|
Parses a column containing a CSV string to a row with the specified schema. |
|
Parses a CSV string and infers its schema in DDL format. |
|
Converts a column containing a |
Partition Transformation Functions¶
|
Partition transform function: A transform for timestamps and dates to partition data into years. |
|
Partition transform function: A transform for timestamps and dates to partition data into months. |
|
Partition transform function: A transform for timestamps and dates to partition data into days. |
|
Partition transform function: A transform for timestamps to partition data into hours. |
|
Partition transform function: A transform for any type that partitions by a hash of the input column. |
Aggregate Functions¶
|
Use |
|
Aggregate function: returns a new |
|
Aggregate function: returns the average of the values in a group. |
|
Aggregate function: returns a list of objects with duplicates. |
|
Aggregate function: returns a set of objects with duplicate elements eliminated. |
|
Returns a new |
|
Aggregate function: returns the number of items in a group. |
|
Returns a new |
|
Returns a new |
|
Returns a new |
|
Returns a new |
|
Aggregate function: returns the first value in a group. |
|
Aggregate function: indicates whether a specified column in a GROUP BY list is aggregated or not, returns 1 for aggregated or 0 for not aggregated in the result set. |
|
Aggregate function: returns the level of grouping, equals to |
|
Aggregate function: returns the kurtosis of the values in a group. |
|
Aggregate function: returns the last value in a group. |
|
Aggregate function: returns the maximum value of the expression in a group. |
|
Returns the value associated with the maximum value of ord. |
|
Aggregate function: returns the average of the values in a group. |
|
Aggregate function: returns the minimum value of the expression in a group. |
|
Returns the value associated with the minimum value of ord. |
|
Returns the approximate percentile of the numeric column col which is the smallest value in the ordered col values (sorted from least to greatest) such that no more than percentage of col values is less than the value or equal to that value. |
|
Aggregate function: returns the product of the values in a group. |
|
Aggregate function: returns the skewness of the values in a group. |
|
Aggregate function: alias for stddev_samp. |
|
Aggregate function: returns population standard deviation of the expression in a group. |
|
Aggregate function: returns the unbiased sample standard deviation of the expression in a group. |
|
Aggregate function: returns the sum of all values in the expression. |
|
Aggregate function: returns the sum of distinct values in the expression. |
|
Aggregate function: returns the sum of distinct values in the expression. |
|
Aggregate function: returns the population variance of the values in a group. |
|
Aggregate function: returns the unbiased sample variance of the values in a group. |
|
Aggregate function: alias for var_samp |
Window Functions¶
Window function: returns the cumulative distribution of values within a window partition, i.e. |
|
Window function: returns the rank of rows within a window partition, without any gaps. |
|
|
Window function: returns the value that is offset rows before the current row, and default if there is less than offset rows before the current row. |
|
Window function: returns the value that is offset rows after the current row, and default if there is less than offset rows after the current row. |
|
Window function: returns the value that is the offsetth row of the window frame (counting from 1), and null if the size of window frame is less than offset rows. |
|
Window function: returns the ntile group id (from 1 to n inclusive) in an ordered window partition. |
Window function: returns the relative rank (i.e. |
|
|
Window function: returns the rank of rows within a window partition. |
Window function: returns a sequential number starting at 1 within a window partition. |
Sort Functions¶
|
Returns a sort expression based on the ascending order of the given column name. |
|
Returns a sort expression based on the ascending order of the given column name, and null values return before non-null values. |
|
Returns a sort expression based on the ascending order of the given column name, and null values appear after non-null values. |
|
Returns a sort expression based on the descending order of the given column name. |
|
Returns a sort expression based on the descending order of the given column name, and null values appear before non-null values. |
|
Returns a sort expression based on the descending order of the given column name, and null values appear after non-null values. |
String Functions¶
|
Computes the numeric value of the first character of the string column. |
|
Computes the BASE64 encoding of a binary column and returns it as a string column. |
|
Calculates the bit length for the specified string column. |
|
Concatenates multiple input string columns together into a single string column, using the given separator. |
|
Computes the first argument into a string from a binary using the provided character set (one of ‘US-ASCII’, ‘ISO-8859-1’, ‘UTF-8’, ‘UTF-16BE’, ‘UTF-16LE’, ‘UTF-16’). |
|
Computes the first argument into a binary from a string using the provided character set (one of ‘US-ASCII’, ‘ISO-8859-1’, ‘UTF-8’, ‘UTF-16BE’, ‘UTF-16LE’, ‘UTF-16’). |
|
Formats the number X to a format like ‘#,–#,–#.–’, rounded to d decimal places with HALF_EVEN round mode, and returns the result as a string. |
|
Formats the arguments in printf-style and returns the result as a string column. |
|
Translate the first letter of each word to upper case in the sentence. |
|
Locate the position of the first occurrence of substr column in the given string. |
|
Computes the character length of string data or number of bytes of binary data. |
|
Converts a string expression to lower case. |
|
Computes the Levenshtein distance of the two given strings. |
|
Locate the position of the first occurrence of substr in a string column, after position pos. |
|
Left-pad the string column to width len with pad. |
|
Trim the spaces from left end for the specified string value. |
|
Calculates the byte length for the specified string column. |
|
Extract a specific group matched by a Java regex, from the specified string column. |
|
Replace all substrings of the specified string value that match regexp with rep. |
|
Decodes a BASE64 encoded string column and returns it as a binary column. |
|
Right-pad the string column to width len with pad. |
|
Repeats a string column n times, and returns it as a new string column. |
|
Trim the spaces from right end for the specified string value. |
|
Returns the SoundEx encoding for a string |
|
Splits str around matches of the given pattern. |
|
Substring starts at pos and is of length len when str is String type or returns the slice of byte array that starts at pos in byte and is of length len when str is Binary type. |
|
Returns the substring from string str before count occurrences of the delimiter delim. |
|
Overlay the specified portion of src with replace, starting from byte position pos of src and proceeding for len bytes. |
|
Splits a string into arrays of sentences, where each sentence is an array of words. |
|
A function translate any character in the srcCol by a character in matching. |
|
Trim the spaces from both ends for the specified string column. |
|
Converts a string expression to upper case. |
UDF¶
|
Creates a pandas user defined function (a.k.a. |
|
Creates a user defined function (UDF). |
|
Unwrap UDT data type column into its underlying type. |
Misc Functions¶
|
Calculates the MD5 digest and returns the value as a 32 character hex string. |
|
Returns the hex string result of SHA-1. |
|
Returns the hex string result of SHA-2 family of hash functions (SHA-224, SHA-256, SHA-384, and SHA-512). |
|
Calculates the cyclic redundancy check value (CRC32) of a binary column and returns the value as a bigint. |
|
Calculates the hash code of given columns, and returns the result as an int column. |
|
Calculates the hash code of given columns using the 64-bit variant of the xxHash algorithm, and returns the result as a long column. |
|
Returns null if the input column is true; throws an exception with the provided error message otherwise. |
|
Throws an exception with the provided error message. |