PySpark functions
This page provides a list of PySpark SQL functions available on Databricks with links to corresponding reference documentation.
Normal functions
Function | Description |
|---|---|
Marks a DataFrame as small enough for use in broadcast joins. | |
Call a SQL function. | |
Returns a Column based on the given column name. | |
Returns a Column based on the given column name. | |
Creates a Column of literal value. | |
Parses the expression string into the column that it represents |
Conditional functions
Function | Description |
|---|---|
Returns the first column that is not null. | |
Returns col2 if col1 is null, or col1 otherwise. | |
Returns col1 if it is not NaN, or col2 if col1 is NaN. | |
Returns null if col1 equals to col2, or col1 otherwise. | |
Returns null if col is equal to zero, or col otherwise. | |
Returns col2 if col1 is null, or col1 otherwise. | |
Returns col2 if col1 is not null, or col3 otherwise. | |
Evaluates a list of conditions and returns one of multiple possible result expressions. | |
Returns zero if col is null, or col otherwise. |
Pattern matching functions
Function | Description |
|---|---|
Returns same result as the EQUAL(=) operator for non-null operands, but returns true if both are null, false if one of them is null. | |
Returns true if str matches pattern with escape case-insensitively, null if any arguments are null, false otherwise. | |
An expression that returns true if the column is NaN. | |
Returns true if col is not null, or false otherwise. | |
An expression that returns true if the column is null. | |
Returns true if str matches pattern with escape, null if any arguments are null, false otherwise. | |
Returns true if str matches the Java regex regexp, or false otherwise. | |
Returns true if str matches the Java regex regexp, or false otherwise. | |
Returns true if str matches the Java regex regexp, or false otherwise. |
Sorting functions
Function | Description |
|---|---|
Returns a sort expression for the target column in ascending order. | |
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 for the target column in descending order. | |
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. |
Mathematical functions
Function | Description |
|---|---|
Computes the absolute value of the given column or expression. | |
Computes the inverse cosine (also known as arccosine) of the given column or expression. | |
Computes the inverse hyperbolic cosine (also known as arcosh) of the given column or expression. | |
Computes inverse sine of the input column. | |
Computes inverse hyperbolic sine of the input column. | |
Compute inverse tangent of the input column. | |
Compute the angle in radians between the positive x-axis of a plane and the point given by the coordinates | |
Computes inverse hyperbolic tangent of the input column. | |
Returns the string representation of the binary value of the given column. | |
Round the given value to scale decimal places using HALF_EVEN rounding mode if scale >= 0 or at integral part when scale < 0. | |
Computes the cube-root of the given value. | |
Computes the ceiling 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. | |
Converts an angle measured in radians to an approximately equivalent angle measured in degrees. | |
Returns Euler's number. | |
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. | |
Returns the greatest value of the list of column names, skipping null values. | |
Computes hex value of the given column, which could be StringType, BinaryType, IntegerType or LongType. | |
Computes | |
Returns the least value of the list of column names, skipping null values. | |
Returns the natural logarithm of the argument. | |
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 negative value. | |
Returns the negative value. | |
Returns Pi. | |
Returns the positive value of dividend mod divisor. | |
Returns the value. | |
Returns the value of the first argument raised to the power of the second argument. | |
Returns the value of the first argument raised to the power of the second argument. | |
Converts an angle measured in degrees to an approximately equivalent angle measured in radians. | |
Generates a random column with independent and identically distributed (i.i.d.) samples uniformly distributed in [0.0, 1.0). | |
Generates a random column with independent and identically distributed (i.i.d.) samples from the standard normal distribution. | |
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. | |
Computes secant of the input column. | |
Computes the signum of the given value. | |
Computes the signum of the given value. | |
Computes sine of the input column. | |
Computes hyperbolic sine of the input column. | |
Computes the square root of the specified float value. | |
Computes tangent of the input column. | |
Computes hyperbolic tangent of the input column. | |
Returns the sum of left and right and the result is null on overflow. | |
Returns dividend/divisor. | |
Returns the remainder after dividend/divisor. | |
Returns left multiplied by right and the result is null on overflow. | |
Returns left minus right and the result is null on overflow. | |
Inverse of hex. | |
Returns a random value with independent and identically distributed (i.i.d.) values with the specified range of numbers. | |
Returns the bucket number into which the value of this expression would fall after being evaluated. |
String functions
Function | Description |
|---|---|
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. | |
Remove the leading and trailing trim characters from str. | |
Returns the ASCII character having the binary equivalent to col. | |
Returns the character length of string data or number of bytes of binary data. | |
Returns the character length of string data or number of bytes of binary data. | |
Marks a given column with specified collation. | |
Returns the collation name of a given column. | |
Concatenates multiple input string columns together into a single string column, using the given separator. | |
Returns a boolean. | |
Computes the first argument into a string from a binary using the provided character set (one of | |
Returns the n-th input, e.g., returns input2 when n is 2. | |
Computes the first argument into a binary from a string using the provided character set (one of | |
Returns a boolean. | |
Returns the index (1-based) of the given string (str) in the comma-delimited list (strArray). | |
Formats the number X to a format like | |
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. | |
Returns true if the input is a valid UTF-8 string, otherwise returns false. | |
Returns str with all characters changed to lowercase. | |
Returns the leftmost len (len can be string type) characters from the string str, if len is less or equal than 0 the result is an empty string. | |
Computes the character length of string data or number of bytes of binary data. | |
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. | |
Converts a string expression to lower case. | |
Left-pad the string column to width len with pad. | |
Trim the spaces from left end for the specified string value. | |
Returns a new string in which all invalid UTF-8 byte sequences, if any, are replaced by the Unicode replacement character (U+FFFD). | |
Masks the given string value. | |
Calculates the byte length for the specified string column. | |
Overlay the specified portion of src with replace, starting from byte position pos of src and proceeding for len bytes. | |
Returns the position of the first occurrence of substr in str after position start. | |
Formats the arguments in printf-style and returns the result as a string column. | |
Returns a string of the specified length whose characters are chosen uniformly at random from the following pool of characters: 0-9, a-z, A-Z. | |
Returns a count of the number of times that the Java regex pattern regexp is matched in the string str. | |
Extract a specific group matched by the Java regex regexp, from the specified string column. | |
Extract all strings in the str that match the Java regex regexp and corresponding to the regex group index. | |
Returns the position of the first substring in the str that match the Java regex regexp and corresponding to the regex group index. | |
Replace all substrings of the specified string value that match regexp with replacement. | |
Returns the first substring that matches the Java regex regexp within the string str. | |
Repeats a string column n times, and returns it as a new string column. | |
Replaces all occurrences of search with replace. | |
Returns the rightmost len (len can be string type) characters from the string str, if len is less or equal than 0 the result is an empty string. | |
Right-pad the string column to width len with pad. | |
Trim the spaces from right end for the specified string value. | |
Splits a string into arrays of sentences, where each sentence is an array of words. | |
Returns the SoundEx encoding for a string | |
Splits str around matches of the given pattern. | |
Splits str by delimiter and return requested part of the split (1-based). | |
Returns a boolean. | |
Returns the substring of str that starts at pos and is of length len, or the slice of byte array that starts at pos and is of length len. | |
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. | |
Converts the input col to a binary value based on the supplied format. | |
Convert col to a string based on the format. | |
Convert string 'col' to a number based on the string format 'format'. | |
Convert col to a string based on the format. | |
Translate any character in the srcCol by a character in matching. | |
Trim the spaces from both ends for the specified string column. | |
Try to perform the | |
Convert string | |
Returns the input value if it corresponds to a valid UTF-8 string, or NULL otherwise. | |
Returns str with all characters changed to uppercase. | |
Decodes a BASE64 encoded string column and returns it as a binary column. | |
Converts a string expression to upper case. | |
Returns the input value if it corresponds to a valid UTF-8 string, or emits an error otherwise. |
Bitwise functions
Function | Description |
|---|---|
Returns the number of bits that are set in the argument expr as an unsigned 64-bit integer, or NULL if the argument is NULL. | |
Returns the value of the bit (0 or 1) at the specified position. | |
Computes bitwise not. | |
Returns the value of the bit (0 or 1) at the specified position. | |
Shift the given value numBits left. | |
(Signed) shift the given value numBits right. | |
Unsigned shift the given value numBits right. |
Date/time functions
Function | Description |
|---|---|
Returns the date that is months months after start. | |
Converts the timestamp without time zone sourceTs from the sourceTz time zone to targetTz. | |
Returns the current date at the start of query evaluation as a DateType column. | |
Returns the current date at the start of query evaluation as a DateType column. | |
Returns the current timestamp at the start of query evaluation as a TimestampType column. | |
Returns the current session local timezone. | |
Returns the date that is days days after start. | |
Returns the number of days from start to end. | |
Converts a date/timestamp/string to a value of string in the format specified by the date format given by the second argument. | |
Create date from the number of days since 1970-01-01. | |
Extracts a part of the date/timestamp or interval source. | |
Returns the date that is days days before start. | |
Returns timestamp truncated to the unit specified by the format. | |
Returns the date that is days days after start. | |
Returns the number of days from start to end. | |
Extracts a part of the date/timestamp or interval source. | |
Extract the day of the month of a given date/timestamp as integer. | |
Returns the three-letter abbreviated day name from the given date. | |
Extract the day of the month of a given date/timestamp as integer. | |
Extract the day of the week of a given date/timestamp as integer. | |
Extract the day of the year of a given date/timestamp as integer. | |
Extracts a part of the date/timestamp or interval source. | |
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. | |
This is a common function for databases supporting TIMESTAMP WITHOUT TIMEZONE. | |
Extract the hours of a given timestamp as integer. | |
Returns the last day of the month which the given date belongs to. | |
Returns the current timestamp without time zone at the start of query evaluation as a timestamp without time zone column. | |
Returns a column with a date built from the year, month and day columns. | |
Make DayTimeIntervalType duration from days, hours, mins and secs. | |
Make interval from years, months, weeks, days, hours, mins and secs. | |
Create timestamp from years, months, days, hours, mins, secs and timezone fields. | |
Create the current timestamp with local time zone from years, months, days, hours, mins, secs and timezone fields. | |
Create local date-time from years, months, days, hours, mins, secs fields. | |
Make year-month interval from years, months. | |
Extract the minutes of a given timestamp as integer. | |
Extract the month of a given date/timestamp as integer. | |
Returns the three-letter abbreviated month name from the given date. | |
Returns number of months between dates date1 and date2. | |
Returns the first date which is later than the value of the date column based on second week day argument. | |
Returns the current timestamp at the start of query evaluation. | |
Extract the quarter of a given date/timestamp as integer. | |
Extract the seconds of a given date as integer. | |
Generates session window given a timestamp specifying column. | |
Gets the difference between the timestamps in the specified units by truncating the fraction part. | |
Gets the difference between the timestamps in the specified units by truncating the fraction part. | |
Creates timestamp from the number of microseconds since UTC epoch. | |
Creates timestamp from the number of milliseconds since UTC epoch. | |
Converts the number of seconds from the Unix epoch (1970-01-01T00:00:00Z) to a timestamp. | |
Converts a Column into pyspark.sql.types.DateType using the optionally specified format. | |
Converts a Column into pyspark.sql.types.TimestampType using the optionally specified format. | |
Parses the timestamp with the format to a timestamp with time zone. | |
Parses the timestamp with the format to a timestamp without time zone. | |
Returns the UNIX timestamp of the given time. | |
This is a common function for databases supporting TIMESTAMP WITHOUT TIMEZONE. | |
Returns date truncated to the unit specified by the format. | |
Try to perform a | |
Try to create timestamp from years, months, days, hours, mins, secs and timezone fields. | |
Try to create the current timestamp with local time zone from years, months, days, hours, mins, secs and timezone fields. | |
Try to create local date-time from years, months, days, hours, mins, secs fields. | |
Parses the col with the format to a timestamp. | |
Returns the number of days since 1970-01-01. | |
Returns the number of microseconds since 1970-01-01 00:00:00 UTC. | |
Returns the number of milliseconds since 1970-01-01 00:00:00 UTC. | |
Returns the number of seconds since 1970-01-01 00:00:00 UTC. | |
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, returns null if failed. | |
Returns the day of the week for date/timestamp (0 = Monday, 1 = Tuesday, ..., 6 = Sunday). | |
Extract the week number of a given date as integer. | |
Bucketize rows into one or more time windows given a timestamp specifying column. | |
Computes the event time from a window column. | |
Extract the year of a given date/timestamp as integer. |
Hash functions
Function | Description |
|---|---|
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 MD5 digest and returns the value as a 32 character hex string. | |
Returns a sha1 hash value as a hex string of the col. | |
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 hash code of given columns using the 64-bit variant of the xxHash algorithm, and returns the result as a long column. |
Collection functions
Function | Description |
|---|---|
Applies a binary operator to an initial state and all elements in the array, and reduces this to a single state. | |
Sorts the input array in ascending order. | |
Returns the length of the array or map stored in the column. | |
Concatenates multiple input columns together into a single column. | |
Returns the element of array at the given (1-based) index. | |
Returns whether a predicate holds for one or more elements in the array. | |
Returns an array of elements for which a predicate holds in a given array. | |
Returns whether a predicate holds for every element in the array. | |
Returns a new map column whose key-value pairs satisfy a given predicate function. | |
Merges two given maps into a single map by applying a function to the key-value pairs. | |
Applies a binary operator to an initial state and all elements in the array, and reduces this to a single state. | |
Returns a reversed string or an array with elements in reverse order. | |
Returns the length of the array or map stored in the column. | |
Returns an array of elements after applying a transformation to each element in the input array. | |
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 element of array at given (1-based) index. | |
Merge two given arrays, element-wise, into a single array using a function. |
Array functions
Function | Description |
|---|---|
Creates a new array column from the input columns or column names. | |
Returns a new array column by appending value to the existing array col. | |
Removes null values from the array. | |
Returns a boolean indicating whether the array contains the given value: null if the array is null, true if the array contains the given value, and false otherwise. | |
Removes duplicate values from the array. | |
Returns a new array containing the elements present in col1 but not in col2, without duplicates. | |
Inserts an item into a given array at a specified array index. | |
Returns a new array containing the intersection of elements in col1 and col2, without duplicates. | |
Returns a string column by concatenating the elements of the input array column using the delimiter. | |
Returns the maximum value of the array. | |
Returns the minimum value of the array. | |
Locates the position of the first occurrence of the given value in the given array. | |
Returns an array containing the given element as the first element and the rest of the elements from the original array. | |
Remove all elements that equal to element from the given array. | |
Creates an array containing a column repeated count times. | |
Returns the total number of elements in the array. | |
Returns a new array containing the union of elements in col1 and col2, without duplicates. | |
Returns a boolean column indicating if the input arrays have common non-null elements, returning true if they do, null if the arrays do not contain any common elements but are not empty and at least one of them contains a null element, and false otherwise. | |
Returns a merged array of structs in which the N-th struct contains all N-th values of input arrays. | |
Creates a single array from an array of arrays. | |
Returns the element of an array at the given (0-based) index. | |
Generate a sequence of integers from start to stop, incrementing by step. | |
Generates a random permutation of the given array. | |
Returns a new array column by slicing the input array column from a start index to a specific length. | |
Sorts the input array in ascending or descending order according to the natural ordering of the array elements. |
Struct functions
Function | Description |
|---|---|
Creates a struct with the given field names and values. | |
Creates a new struct column. |
Map functions
Function | Description |
|---|---|
Creates a new map column from an even number of input columns or column references. | |
Returns the union of all given maps. | |
Returns true if the map contains the key. | |
Returns an unordered array of all entries in the given map. | |
Creates a new map from two arrays. | |
Transforms an array of key-value pair entries (structs with two fields) into a map. | |
Returns an unordered array containing the keys of the map. | |
Returns an unordered array containing the values of the map. | |
Converts a string into a map after splitting the text into key/value pairs using delimiters. |
Aggregate functions
Function | Description |
|---|---|
Returns some value of col for a group of rows. | |
Returns a new Column, which estimates the approximate distinct count of elements in a specified column or a group of columns. | |
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. | |
Returns a list of objects with duplicates. | |
Returns the average of the values in a group. | |
Returns the bitwise AND of all non-null input values, or null if none. | |
Returns the bitwise OR of all non-null input values, or null if none. | |
Returns the bitwise XOR of all non-null input values, or null if none. | |
Returns a bitmap with the positions of the bits set from all the values from the input column. | |
Returns a bitmap that is the bitwise OR of all of the bitmaps from the input column. | |
Returns true if all values of col are true. | |
Returns true if at least one value of col is true. | |
Collects the values from a column into a list, maintaining duplicates, and returns this list of objects. | |
Collects the values from a column into a set, eliminating duplicates, and returns this set of objects. | |
Returns a new Column for the Pearson Correlation Coefficient for col1 and col2. | |
Returns the number of items in a group. | |
Returns a new Column for distinct count of col or cols. | |
Returns the number of TRUE values for the col. | |
Returns a count-min sketch of a column with the given esp, confidence and seed. | |
Returns a new Column for the population covariance of col1 and col2. | |
Returns a new Column for the sample covariance of col1 and col2. | |
Returns true if all values of col are true. | |
Returns the first value in a group. | |
Returns the first value of col for a group of rows. | |
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. | |
Returns the level of grouping, equals to | |
Computes a histogram on numeric 'col' using nb bins. | |
Returns the updatable binary representation of the Datasketches HllSketch configured with lgConfigK arg. | |
Returns the updatable binary representation of the Datasketches HllSketch, generated by merging previously created Datasketches HllSketch instances via a Datasketches Union instance. | |
Returns the kurtosis of the values in a group. | |
Returns the last value in a group. | |
Returns the last value of col for a group of rows. | |
Returns the concatenation of non-null input values, separated by the delimiter. | |
Returns the concatenation of distinct non-null input values, separated by the delimiter. | |
Returns the maximum value of the expression in a group. | |
Returns the value from the col parameter that is associated with the maximum value from the ord parameter. | |
Returns the average of the values in a group. | |
Returns the median of the values in a group. | |
Returns the minimum value of the expression in a group. | |
Returns the value from the col parameter that is associated with the minimum value from the ord parameter. | |
Returns the most frequent value in a group. | |
Returns the exact percentile(s) of numeric column expr at the given percentage(s) with value range in [0.0, 1.0]. | |
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. | |
Returns the product of the values in a group. | |
Returns the average of the independent variable for non-null pairs in a group, where y is the dependent variable and x is the independent variable. | |
Returns the average of the dependent variable for non-null pairs in a group, where y is the dependent variable and x is the independent variable. | |
Returns the number of non-null number pairs in a group, where y is the dependent variable and x is the independent variable. | |
Returns the intercept of the univariate linear regression line for non-null pairs in a group, where y is the dependent variable and x is the independent variable. | |
Returns the coefficient of determination for non-null pairs in a group, where y is the dependent variable and x is the independent variable. | |
Returns the slope of the linear regression line for non-null pairs in a group, where y is the dependent variable and x is the independent variable. | |
Returns REGR_COUNT(y, x) * VAR_POP(x) for non-null pairs in a group, where y is the dependent variable and x is the independent variable. | |
Returns REGR_COUNT(y, x) * COVAR_POP(y, x) for non-null pairs in a group, where y is the dependent variable and x is the independent variable. | |
Returns REGR_COUNT(y, x) * VAR_POP(y) for non-null pairs in a group, where y is the dependent variable and x is the independent variable. | |
Returns the skewness of the values in a group. | |
Returns true if at least one value of col is true. | |
Alias for | |
Alias for | |
Returns population standard deviation of the expression in a group. | |
Returns the unbiased sample standard deviation of the expression in a group. | |
Returns the concatenation of non-null input values, separated by the delimiter. | |
Returns the concatenation of distinct non-null input values, separated by the delimiter. | |
Returns the sum of all values in the expression. | |
Returns the sum of distinct values in the expression. | |
Returns the mean calculated from values of a group and the result is null on overflow. | |
Returns the sum calculated from values of a group and the result is null on overflow. | |
Returns the population variance of the values in a group. | |
Returns the unbiased sample variance of the values in a group. | |
Alias for |
Window functions
Function | Description |
|---|---|
Returns the cumulative distribution of values within a window partition, i.e. the fraction of rows that are below the current row. | |
Returns the rank of rows within a window partition, without any gaps. | |
Returns the value that is offset rows before the current row, and default if there is less than offset rows before the current row. | |
Returns the value that is offset rows after the current row, and default if there is less than offset rows after the current row. | |
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. | |
Returns the ntile group id (from 1 to n inclusive) in an ordered window partition. | |
Returns the relative rank (i.e. | |
Returns the rank of rows within a window partition. | |
Returns a sequential number starting at 1 within a window partition. |
Generator functions
Function | Description |
|---|---|
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. | |
Explodes an array of structs into a table. | |
Explodes an array of structs into a table. | |
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. | |
Separates col1, ..., colk into n rows. |
Partition transformation functions
Function | Description |
|---|---|
A transform for timestamps and dates to partition data into years. | |
A transform for timestamps and dates to partition data into months. | |
A transform for timestamps and dates to partition data into days. | |
A transform for timestamps to partition data into hours. | |
A transform for any type that partitions by a hash of the input column. |
H3 geospatial functions (Databricks)
Function | Description |
|---|---|
Returns the boundary of an H3 cell in GeoJSON format | |
Returns the boundary of an H3 cell in WKB format | |
Returns the boundary of an H3 cell in WKT format | |
Returns the center of an H3 cell in GeoJSON format | |
Returns the center of an H3 cell in WKB format | |
Returns the center of an H3 cell in WKT format | |
Compacts the input set of H3 cell IDs as best as possible | |
Returns an array of cell IDs represented as long integers, corresponding to hexagons or pentagons of the specified resolution that minimally cover the input linear or areal geography | |
Returns an array of cell IDs represented as strings, corresponding to hexagons or pentagons of the specified resolution that minimally cover the input linear or areal geography | |
Returns the grid distance between two H3 cell IDs | |
Converts an H3 cell ID to a string representing the cell ID as a hexadecimal string | |
Returns an array of H3 cell IDs that form a hollow hexagonal ring centered at the origin H3 cell and that are at grid distance k from the origin H3 cell | |
Returns | |
Returns | |
Returns | |
Returns the H3 cell IDs that are within (grid) distance k of the origin cell ID | |
Returns all H3 cell IDs (represented as long integers or strings) within grid distance k from the origin H3 cell ID, along with their distance from the origin H3 cell ID | |
Returns the H3 cell ID (as a BIGINT) corresponding to the provided longitude and latitude at the specified resolution | |
Returns the H3 cell ID (as a string) corresponding to the provided longitude and latitude at the specified resolution | |
Returns the child of maximum value of the input H3 cell at the specified resolution | |
Returns the child of minimum value of the input H3 cell at the specified resolution | |
Returns the H3 cell ID (as a BIGINT) corresponding to the provided point at the specified resolution | |
Returns the H3 cell ID (as a string) corresponding to the provided point at the specified resolution | |
Returns an array of cell IDs represented as long integers, corresponding to hexagons or pentagons of the specified resolution that are contained by the input areal geography | |
Returns an array of cell IDs represented as strings, corresponding to hexagons or pentagons of the specified resolution that are contained by the input areal geography | |
Returns the resolution of the H3 cell ID | |
Converts the string representation H3 cell ID to its big integer representation | |
Returns an array of structs representing the chips covering geography at the specified resolution | |
Returns the children H3 cell IDs of the input H3 cell ID at the specified resolution | |
Returns the parent H3 cell ID of the input H3 cell ID at the specified resolution | |
Returns an array of cell IDs represented as long integers, corresponding to hexagons or pentagons of the specified resolution that minimally cover the input linear or areal geography | |
Returns an array of cell IDs represented as strings, corresponding to hexagons or pentagons of the specified resolution that minimally cover the input linear or areal geography | |
Returns the grid distance between two H3 cell IDs of the same resolution, or | |
Returns an array of cell IDs represented as long integers, corresponding to hexagons or pentagons of the specified resolution that are contained by the input areal geography | |
Returns an array of cell IDs represented as strings, corresponding to hexagons or pentagons of the specified resolution that are contained by the input areal geography | |
Returns an array of structs representing the chips covering geography at the specified resolution, or null if the geometry is invalid | |
Returns the input value if it is a valid H3 cell or None otherwise | |
Uncompacts the input set of H3 cell IDs to the specified resolution | |
Returns the input value if it is a valid H3 cell or emits an error otherwise |
ST geospatial functions (Databricks)
Function | Description |
|---|---|
Adds a new point to the n-th position in the input linestring Geography or Geometry | |
Returns the area of the input geography or geometry | |
Returns the input Geometry value in EWKB format | |
Returns the input Geography or Geometry value in EWKT format | |
Returns the input Geography or Geometry value in GeoJSON format | |
Returns the buffer of the input geometry using the specified radius | |
Returns the centroid of the input geometry as a 2D point geometry | |
Returns the concave hull of the input geometry as a geometry using the specified length ratio | |
Returns | |
Returns the convex hull of the input geometry as a geometry | |
Returns | |
Returns the point-set different of the two input geometries as a 2D geometry | |
Returns the topological dimension of the 2D projection of the input geometry | |
Returns | |
Returns the 2D Cartesian distance between the two input geometries | |
Returns the spherical distance (in meters) between two point geometries, measured on a sphere whose radius is the mean radius of the WGS84 ellipsoid | |
Returns the geodesic distance (in meters) between two point geometries on the WGS84 ellipsoid | |
Returns | |
Returns the last point of the input linestring, or | |
Returns the 2D Cartesian axis-aligned minimum bounding box (envelope) of the input non-empty geometry, as a geometry | |
Returns the envelope of all the geometries in the column, or | |
Returns | |
Returns the exterior ring (shell), as a linestring, of the input Geography or Geometry value representing a polygon | |
Swaps X and Y coordinates of the input geometry | |
Parses the GeoJSON description and returns the corresponding Geography value | |
Parses the WKT description and returns the corresponding Geography value | |
Parses the input WKB description and returns the corresponding Geography value | |
Parses the WKT description and returns the corresponding Geography value | |
Returns the geohash of the input Geometry | |
Returns the 1-based n-th element of the input multi geometry, or | |
Returns the type of the input Geography or Geometry value as a string | |
Parses the input EWKB description and returns the corresponding Geometry value | |
Returns the geohash grid box corresponding to the input geohash value as a 2D polygon geometry | |
Parses the GeoJSON description and returns the corresponding Geometry value | |
Parses the WKT description and returns the corresponding Geometry value | |
Parses the input WKB description and returns the corresponding Geometry value | |
Parses the WKT description and returns the corresponding Geometry value | |
Returns the point-set intersection of the two input geometries as a 2D geometry | |
Returns | |
Returns | |
Returns | |
Returns the length of the input geometry or geography value | |
Returns the M coordinate of the input point geometry, or | |
Returns a linestring geometry whose points are the non-empty points of the geometries in the input array of geometries, which are expected to be points, linestrings, or multipoints | |
Constructs a polygon from the input outer boundary and optional array of inner boundaries, represented as closed linestrings | |
Returns the input Geography or Geometry value as an equivalent multi geospatial value, keeping the original SRID | |
Returns the coordinate dimension of the input Geography or Geometry value | |
Returns the number of non-empty points in the input Geography or Geometry value | |
Returns the number of geometries in the input geometry | |
Returns the perimeter of the input geography or geometry | |
Returns a 2D point Geometry with the given x and y coordinates and SRID value | |
Returns the center of the geohash grid box corresponding to the input geohash value as a 2D point geometry | |
Returns the 1-based n-th point of the input linestring, or | |
Removes the n-th point from the input linestring Geography or Geometry | |
Reverses the order of vertices in the input Geography or Geometry value | |
Rotates the input geometry around the Z axis by the given rotation angle (in radians) | |
Scales the input geometry in the X, Y, and Z (optional) directions using the given factors | |
Sets the n-th point in the input linestring Geography or Geometry | |
Returns a new Geometry value whose SRID is the specified SRID value | |
Simplifies the input geometry using the Douglas-Peucker algorithm | |
Returns the SRID of the input geospatial value | |
Returns the first point of the input linestring, or | |
Returns | |
Transforms the X and Y coordinates of the input geometry to the coordinate reference system (CRS) described by the provided SRID value | |
Translates the input geometry in the X, Y, and Z (optional) directions using the provided offsets | |
Returns the point-set union of the two input geometries as a 2D geometry | |
Returns the point-wise union of all the geometries in the column, or | |
Returns | |
Returns the X coordinate of the input point geometry, or | |
Returns the maximum X coordinate of the input geometry, or | |
Returns the minimum X coordinate of the input geometry, or | |
Returns the Y coordinate of the input point geometry, or | |
Returns the maximum Y coordinate of the input geometry, or | |
Returns the minimum Y coordinate of the input geometry, or | |
Returns the Z coordinate of the input point geometry, or | |
Returns the maximum Z coordinate of the input geometry, or | |
Returns the minimum Z coordinate of the input geometry, or | |
Parses the input BINARY or string value and returns the corresponding Geography value | |
Parses the input BINARY or string value and returns the corresponding Geometry value | |
Parses the input BINARY or string value and returns the corresponding Geography value, or | |
Parses the input BINARY or string value and returns the corresponding Geometry value, or |
CSV functions
Function | Description |
|---|---|
Parses a column containing a CSV string into a row with the specified schema. | |
Parses a CSV string and infers its schema in DDL format. | |
Converts a column containing a StructType into a CSV string. |
JSON functions
Function | Description |
|---|---|
Parses a column containing a JSON string into a MapType with StringType as keys type, StructType or ArrayType with the specified schema. | |
Extracts json object from a json string based on json path specified, and returns json string of the extracted json object. | |
Returns the number of elements in the outermost JSON array. | |
Returns all the keys of the outermost JSON object as an array. | |
Creates a new row for a json column according to the given field names. | |
Parses a JSON string and infers its schema in DDL format. | |
Converts a column containing a StructType, ArrayType or a MapType into a JSON string. |
Variant functions
Function | Description |
|---|---|
Check if a variant value is a variant null. | |
Parses a column containing a JSON string into a VariantType. | |
Returns schema in the SQL format of a variant. | |
Returns the merged schema in the SQL format of a variant column. | |
Extracts a sub-variant from v according to path, and then cast the sub-variant to targetType. | |
Extracts a sub-variant from v according to path, and then cast the sub-variant to targetType. | |
Parses a column containing a JSON string into a VariantType. | |
Converts a column containing nested inputs (array/map/struct) into a variants where maps and structs are converted to variant objects which are unordered unlike SQL structs. |
XML functions
Function | Description |
|---|---|
Parses a column containing a XML string to a row with the specified schema. | |
Parses a XML string and infers its schema in DDL format. | |
Converts a column containing a StructType into a XML string. | |
Returns a string array of values within the nodes of xml that match the XPath expression. | |
Returns true if the XPath expression evaluates to true, or if a matching node is found. | |
Returns a double value, the value zero if no match is found, or NaN if a match is found but the value is non-numeric. | |
Returns a float value, the value zero if no match is found, or NaN if a match is found but the value is non-numeric. | |
Returns an integer value, or the value zero if no match is found, or a match is found but the value is non-numeric. | |
Returns a long integer value, or the value zero if no match is found, or a match is found but the value is non-numeric. | |
Returns a double value, the value zero if no match is found, or NaN if a match is found but the value is non-numeric. | |
Returns a short integer value, or the value zero if no match is found, or a match is found but the value is non-numeric. | |
Returns the text contents of the first xml node that matches the XPath expression. |
URL functions
Function | Description |
|---|---|
Extracts a specified part from a URL. | |
Try to perform the | |
Decodes a URL-encoded string in | |
Encodes a string into a URL-encoded string in 'application/x-www-form-urlencoded' format. | |
Try to perform the |
Miscellaneous functions
Function | Description |
|---|---|
Returns a decrypted value of input using AES in mode with padding. | |
Returns an encrypted value of input using AES in given mode with the specified padding. | |
Returns null if the input column is true; throws an exception with the provided error message otherwise. | |
Returns the bit position for the given input column. | |
Returns the bucket number for the given input column. | |
Returns the number of set bits in the input bitmap. | |
Returns the current catalog. | |
Returns the current database. | |
Returns the current schema. | |
Returns the current user. | |
Returns the estimated number of unique values given the binary representation of a Datasketches HllSketch. | |
Merges two binary representations of Datasketches HllSketch objects, using a Datasketches Union object. | |
Returns the length of the block being read, or -1 if not available. | |
Returns the start offset of the block being read, or -1 if not available. | |
Creates a string column for the file name of the current Spark task. | |
Calls a method with reflection. | |
A column that generates monotonically increasing 64-bit integers. | |
Throws an exception with the provided error message. | |
Calls a method with reflection. | |
Returns the user name of current execution context. | |
A column for partition ID. | |
Try to perform the | |
Try to perform a | |
Return DDL-formatted type string for the data type of the input. | |
Returns the current user. | |
Returns the Spark version. |
UDF, UDTF, UDT functions
Function | Description |
|---|---|
Call a user-defined function. | |
Creates a pandas user defined function (a.k.a. | |
Creates a user defined function (UDF). | |
Creates a user defined table function (UDTF). | |
Unwrap UDT data type column into its underlying type. |
Table-valued functions
Function | Description |
|---|---|
Get all of the Spark SQL string collations. | |
Returns a DataFrame containing a new row for each element in the given array or map. | |
Returns a DataFrame containing a new row for each element with position in the given array or map. | |
Explodes an array of structs into a table. | |
Explodes an array of structs into a table. | |
Creates a new row for a json column according to the given field names. | |
Returns a DataFrame containing a new row for each element with position in the given array or map. | |
Returns a DataFrame containing a new row for each element with position in the given array or map. | |
Create a DataFrame with single pyspark.sql.types.LongType column named id, containing elements in a range from start to end (exclusive) with step value step. | |
Get Spark SQL keywords. | |
Separates col1, ..., colk into n rows. | |
Separates a variant object/array into multiple rows containing its fields/elements. | |
Separates a variant object/array into multiple rows containing its fields/elements. |