This topic describes the functions and operators that are supported in the Structured Query Language (SQL) and Simple Log Service Processing Language (SPL).
Functions and operators
You can view the usage of functions and operators based on the features and languages that you want to use. In the following tables, ticks (√) indicate supported, and crosses (×) indicate not supported.
SQL is a widely used query and analysis language. You can use SQL in analysis scenarios such as filtering, transformation, statistics collection, and aggregation of structured data. You can use SQL statements to query and analyze logs in Simple Log Service.
SPL is a pipeline query and processing language. You can use SPL in scenarios such as scan-based query and streaming consumption. You can use SPL statements to preprocess and query data.
Aggregate functions
Function | Description | Supported in SQL | Supported in SPL |
Returns a random, non-null value of the x field. | √ | × | |
Calculates the average of the values in the x field. | √ | × | |
Returns the result of the bitwise AND operation on the values in the x field. | √ | × | |
Returns the result of the bitwise OR operation on the values in the x field. | √ | × | |
Checks whether all logs meet the specified condition. If yes, the function returns true. This function is equivalent to the every function. | √ | × | |
Checks whether a log that meets the specified condition exists. If yes, the function returns true. | √ | × | |
Calculates the checksum of the values in the x field. | √ | × | |
Counts the number of logs. | √ | × | |
Counts the number of logs. This function is equivalent to the count(*) function. | √ | × | |
Counts the number of logs whose value of the x field is not NULL. | √ | × | |
Counts the number of logs that meet the specified condition. | √ | × | |
Checks whether all logs meet the specified condition. If yes, the function returns true. This function is equivalent to the bool_and function. | √ | × | |
Calculates the geometric mean of the values in the x field. | √ | × | |
Calculates the kurtosis of the values in the x field. | √ | × | |
Returns the result of the union operation on the specified maps. If a key exists in multiple input maps, the function randomly returns one of the values of the key. | √ | × | |
Queries the largest value of the x field. | √ | × | |
Queries the n largest values in the x field. The function returns an array. | √ | × | |
Queries the value of x that is associated with the largest value of the y field. | √ | × | |
Queries the values in x that are associated with the n largest values in the y field. The function returns an array. | √ | × | |
Queries the smallest value of the x field. | √ | × | |
Queries the n smallest values in the x field. The function returns an array. | √ | × | |
Queries the value of x that is associated with the smallest value of the y field. | √ | × | |
Queries the values in x that are associated with the n smallest values in the y field. The function returns an array. | √ | × | |
Calculates the skewness of the values in the x field. | √ | × | |
Calculates the sum of the values in the x field. | √ | × |
String functions
Function | Description | Supported in SQL | Supported in SPL |
Converts an ASCII code to characters. | √ | √ | |
Converts characters to an ASCII code. | √ | √ | |
Concatenates multiple strings into one string. | √ | √ | |
Decodes a binary string into a UTF-8-encoded string. Invalid UTF-8 sequences are replaced with the default replacement character U+FFFD. | √ | √ | |
Decodes a binary string into a UTF-8 encoded string. Invalid UTF-8 sequences are replaced with a custom string. | √ | √ | |
Returns the length of a string. | √ | √ | |
Returns the minimum edit distance between x and y. | √ | × | |
Converts the characters in a string to lowercase letters. | √ | √ | |
Left pads a string to a specified length by using a specified character and returns the result string. | √ | √ | |
Removes spaces from the start of a string. | √ | √ | |
Transforms a string by using the NFC normalization form. | √ | × | |
Returns the position of a specified substring in a string. | √ | × | |
Replaces the matched characters in a string with specified characters. | √ | √ | |
Removes the matched characters from a string. | √ | √ | |
Returns a string in reverse order. | √ | √ | |
Right pads a string to a specified length by using a specified character and returns the result string. | √ | √ | |
Removes spaces from the end of a string. | √ | √ | |
Splits a string by using a specified delimiter and returns a set of substrings. | √ | √ | |
Splits a string by using a specified delimiter and returns a set of substrings. The number of substrings that can be generated is specified by limit. | √ | √ | |
Splits a string by using a specified delimiter and returns the substring at a specified position. | √ | √ | |
Splits a string by using the first specified delimiter, and then splits the string by using the second specified delimiter. | √ | √ | |
Returns the position of a specified substring in a string. This function is equivalent to the position(sub_string in x) function. | √ | √ | |
Returns the substring at a specified position in a string. The length of the substring is specified. | √ | √ | |
Returns the substring at a specified position in a string. | √ | √ | |
Converts a string to a UTF-8 representation. | √ | √ | |
Removes spaces from the start and end of a string. | √ | √ | |
Converts the characters in a string to uppercase letters. | √ | √ |
Date and time functions
Function | Description | Supported in SQL | Supported in SPL |
Returns the current date. | √ | × | |
Returns the current time and time zone. | √ | × | |
Returns the current date, time, and time zone. | √ | × | |
Returns the current time zone. | √ | × | |
Returns the date part of a datetime expression. | √ | × | |
Converts a datetime expression that can return a timestamp value to a datetime expression in a specified format. | √ | √ | |
Converts a datetime string to a datetime expression that can return a timestamp value and is in a specified format. | √ | √ | |
Converts a date expression in the ISO 8601 format to a date expression that can return a date value. | √ | × | |
Converts a datetime expression in the ISO 8601 format to a datetime expression that can return a timestamp value. | √ | × | |
Converts a UNIX timestamp to a datetime expression that can return a timestamp value and does not contain a time zone. | √ | √ | |
Converts a UNIX timestamp to a datetime expression that can return a timestamp value and contains a time zone. | √ | × | |
Converts a UNIX timestamp to a datetime expression that can return a timestamp value and contains a time zone. In the datetime expression, the values for hours and minutes indicate the offset of the time zone. | √ | × | |
Returns the local time. | √ | × | |
Returns the local date and time. | √ | × | |
Returns the current date and time. This function is equivalent to the current_timestamp function. | √ | × | |
Converts a datetime expression that can return a date or timestamp value to a datetime expression in the ISO 8601 format. | √ | × | |
Converts a datetime expression that can return a timestamp value to a UNIX timestamp. | √ | √ | |
Returns the day of the month from a datetime expression. This function is equivalent to the day_of_month function. | √ | × | |
Returns the day of the month from a datetime expression. This function is equivalent to the day function. | √ | × | |
Returns the day of the week from a datetime expression. This function is equivalent to the dow function. | √ | √ | |
Returns the day of the year from a datetime expression. This function is equivalent to the doy function. | √ | √ | |
Returns the day of the week from a datetime expression. This function is equivalent to the day_of_week function. | √ | √ | |
Returns the day of the year from a datetime expression. This function is equivalent to the day_of_year function. | √ | √ | |
Returns the specified field from a datetime expression. The field can be a date or time. | √ | × | |
Returns the hour of the day from a datetime expression. The 24-hour clock is used. | √ | √ | |
Returns the minute of the hour from a datetime expression. | √ | √ | |
Returns the month of the year from a datetime expression. | √ | √ | |
Returns the quarter of the year on which a specified date falls. | √ | √ | |
Returns the second of the minute from a datetime expression. | √ | √ | |
Returns the offset of the time zone in hours. | √ | × | |
Returns the offset of the time zone in minutes. | √ | × | |
Returns the week of the year on which a specified date falls. This function is equivalent to the week_of_year function. | √ | × | |
Returns the week of the year on which a specified date falls. This function is equivalent to the week function. | √ | × | |
Returns the year of a specified date. | √ | √ | |
Returns the year on which a specified date falls in the ISO week date system. This function is equivalent to the yow function. | √ | √ | |
Returns the year on which a specified date falls in the ISO week date system. This function is equivalent to the year_of_week function. | √ | √ | |
Truncates a datetime expression based on the time unit that you specify. The expression can be truncated based on the millisecond, second, minute, hour, day, month, or year. | √ | × | |
Adds N to the value of the x field based on the unit that you specify. | √ | √ | |
Returns the difference between two time expressions. For example, you can calculate the difference between x and y based on the time unit that you specify. | √ | √ | |
Adds a value to the field that has no value returned in the specified time window. | √ | × |
JSON functions
Function | Description | Supported in SQL | Supported in SPL |
Checks whether a JSON array contains a specified value. | √ | √ | |
Obtains the element that corresponds to an index in a JSON array. | √ | × | |
Obtains the number of elements in a JSON array. | √ | √ | |
Obtains a set of JSON values from a JSON object or a JSON array. The JSON values can be of the array or object type. | √ | √ | |
Obtains a set of scalar values from a JSON object or a JSON array. The scalar values can be of the string, integer, or Boolean type. This function is similar to the json_extract function. | √ | √ | |
Converts JSON data to a string. | √ | √ | |
Converts a string to JSON data. | √ | √ | |
Obtains the number of elements in a JSON object or a JSON array. | √ | √ |
Regular expression functions
Function | Description | Supported in SQL | Supported in SPL |
Extracts the substrings that match a specified regular expression from a specified string and returns an array of all matched substrings. | √ | × | |
Extracts the substrings that match a specified regular expression from a specified string and returns an array of substrings that match the nth capturing group in the regular expression. | √ | × | |
Extracts the first substring that matches a specified regular expression from a specified string and returns the substring. | √ | √ | |
Extracts the substrings that match a specified regular expression from a specified string and returns the first substring that matches the nth capturing group in the regular expression. | √ | √ | |
Checks whether a specified string matches a specified regular expression. | √ | √ | |
Deletes the substrings that match a specified regular expression from a specified string and returns the substrings that remain. | √ | √ | |
Replaces the substrings that match a specified regular expression in a specified string and returns the result string. | √ | √ | |
Splits a specified string into multiple substrings by using a specified regular expression and returns an array of the substrings. | √ | × |
Interval-valued comparison and periodicity-valued comparison functions
Function | Description | Supported in SQL | Supported in SPL |
Compares the calculation result of the current time period with the calculation result of a time period n seconds before. | √ | × | |
Compares the calculation result of the current time period with the calculation results of multiple time periods n1, n2, and n3 seconds before. | √ | × | |
Compares the calculation result of the current time period with the calculation result of a time period n seconds before. Important The query and analysis results of the ts_compare function must be grouped by the time column by using the GROUP BY clause. | √ | × | |
Compares the calculation result of the current time period with the calculation results of multiple time periods n1, n2, and n3 seconds before. | √ | × |
Array functions and operators
Function | Description | Supported in SQL | Supported in SPL |
Returns the element whose index is x in an array. | √ | × | |
Returns an array that consists of all values in the x field. | √ | × | |
Removes duplicate elements from an array. | √ | √ | |
Calculates the difference of two arrays. | √ | √ | |
Calculates the intersection of two arrays. | √ | √ | |
Concatenates the elements of an array into a string by using a specified delimiter. If the array contains a null element, the null element is ignored. | √ | √ | |
Concatenates the elements of an array into a string by using a specified delimiter. If the array contains a null element, the null element is replaced with the value of the null_replacement parameter. | √ | √ | |
Returns the maximum value in an array. | √ | √ | |
Returns the minimum value in an array. | √ | √ | |
Returns the index of a specified element in an array. The index starts from 1. If the specified element does not exist, the function returns 0. | √ | √ | |
Removes a specified element from an array. | √ | √ | |
Sorts the elements in an array in ascending order. If the array contains a null element, the null element is placed at the end. | √ | √ | |
Transposes a matrix and returns a new two-dimensional array that consists of the elements in the matrix. The elements are located by using the same indexes. | √ | × | |
Calculates the union of two arrays. | √ | × | |
Counts the number of elements in an array. | √ | √ | |
Concatenates multiple arrays into one array. | √ | × | |
Checks whether an array contains a specified element. If the array contains the specified element, the function returns true. | √ | × | |
Returns the element whose index is y in an array. | √ | × | |
Filters elements in an array based on a lambda expression and returns elements that match the lambda expression. | √ | √ | |
Transforms a two-dimensional array into a one-dimensional array. | √ | × | |
Returns the sum of the elements in an array based on a lambda expression. | √ | √ | |
Reverses the elements in an array. | √ | √ | |
Returns an array of elements within a specified range. The elements are consecutive and incremental. The incremental step is 1, which is the default value. | √ | √ | |
Returns an array of elements within a specified range. The elements are consecutive and incremental. The incremental step is a custom value. | √ | √ | |
Shuffles the elements in an array. | √ | √ | |
Returns a subset of an array. | √ | √ | |
Transforms each element in an array by using a lambda expression. | √ | √ | |
Merges multiple arrays into a two-dimensional array. Elements that have the same index in the input arrays form a new array in the two-dimensional array. | √ | √ | |
Merges two arrays into one array by using a lambda expression. | √ | × |
Map functions and operators
Function | Description | Supported in SQL | Supported in SPL |
Retrieves the value of a key from a map. | √ | × | |
Returns the size of a map. | √ | × | |
Returns the value of a key in a map. | √ | × | |
Groups query and analysis results and returns data in the JSON format. | √ | × | |
Groups query and analysis results and returns data in multiple rows and multiple columns. | √ | × | |
Returns an empty map. | √ | × | |
Returns a map that is created by using two arrays. | √ | × | |
Returns a map that is created by using x and y. x is the key in the map. y is the value of the key in the map. If y has multiple values, a random value is extracted as the value of the key. | √ | × | |
Returns the union of multiple maps. | √ | × | |
Filters elements in a map based on a lambda expression and returns a new map. | √ | × | |
Returns an array that consists of all the keys of a map. | √ | × | |
Returns an array that consists of all the values of a map. | √ | × | |
Returns a multimap that is created by using x and y. x is the key in the multimap. y is the value of the key in the multimap, and the value is of the array type. If y has multiple values, all the values are extracted as the values of the key. | √ | × |
Mathematical calculation functions
Function | Description | Supported in SQL | Supported in SPL |
Calculates the absolute value of x. | √ | √ | |
Calculates the arc cosine of x. | √ | √ | |
Calculates the arc sine of x. | √ | √ | |
Calculates the arc tangent of x. | √ | √ | |
Calculates the arc tangent of x divided by y. | √ | √ | |
Calculates the cube root of x. | √ | √ | |
Rounds x up to the nearest integer. This function is an alias of the ceiling function. | √ | √ | |
Rounds x up to the nearest integer. | √ | √ | |
Calculates the cosine of x. | √ | √ | |
Calculates the hyperbolic cosine of x. | √ | √ | |
Calculates the cosine similarity between x and y. | √ | × | |
Converts an angle in radians to its equivalent in degrees. | √ | √ | |
Returns the value of e, which is the base of the natural logarithm. | √ | √ | |
Raises e to the power of x. | √ | × | |
Rounds x down to the nearest integer. | √ | √ | |
Converts x to a base-y number. | √ | √ | |
Calculates the natural logarithm of x. | √ | √ | |
Returns a value that represents positive infinity. | √ | √ | |
Determines whether x is Not a Number (NaN). | √ | √ | |
Calculates the base-2 logarithm of x. | √ | √ | |
Calculates the base-10 logarithm of x. | √ | √ | |
Calculates the base-y logarithm of x. | √ | × | |
Calculates the remainder of x divided by y. | √ | √ | |
Returns a value that is NaN. | √ | √ | |
Returns the value of π to 15 decimal places. | √ | √ | |
Raises x to the power of y. This function is an alias of the power function. | √ | √ | |
Raises x to the power of y. | √ | √ | |
Converts an angle in degrees to its equivalent in radians. | √ | √ | |
Returns a random number. | √ | √ | |
Returns a random number in the range [0,1). | √ | √ | |
Returns a random number in the range [0,x). | √ | √ | |
Rounds x to the nearest integer. | √ | √ | |
Rounds x to the nearest decimal with n decimal places. | √ | √ | |
Returns the sign of x. Valid values: 1, 0, and -1. | √ | × | |
Calculates the sine of x. | √ | √ | |
Calculates the square root of x. | √ | √ | |
Calculates the tangent of x. | √ | √ | |
Calculates the hyperbolic tangent of x. | √ | √ | |
Converts x to a base-y string. | √ | × | |
Removes the fractional part of x. | √ | √ | |
Divides a numeric range into buckets of equal width and returns the bucket number of x. | √ | × | |
Returns the bucket number of x in the range of buckets that are specified by an array. | √ | × |
Mathematical statistics functions
Function | Description | Supported in SQL | Supported in SPL |
Returns the coefficient of correlation between x and y. The return value is in the range of [0,1]. | √ | × | |
Returns the population covariance of x and y. | √ | × | |
Returns the sample covariance of x and y. | √ | × | |
Returns the sample standard deviation of x. This function is equivalent to the stddev_samp function. | √ | × | |
Returns the sample standard deviation of x. | √ | × | |
Returns the population standard deviation of x. | √ | × | |
Returns the sample variance of x. This function is equivalent to the var_samp function. | √ | × | |
Returns the sample variance of x. | √ | × | |
Returns the population variance of x. | √ | × | |
Returns the y-intercept of the line for the linear equation that is determined by the | √ | × | |
Returns the slope of the line for the linear equation that is determined by the | √ | × | |
Returns a value for the beta distribution. The function uses the following formula: P(N <= v; α, β) where α and β are parameters for the beta CDF. | √ | × | |
Returns a value for the binomial distribution. The function uses the following formula: P(N <= v; x, y) where x indicates the number of trials, and y indicates the probability of success (POS) of a trial. | √ | × | |
Returns a value for the Cauchy distribution. The function uses the following formula: P(N <= v; x, y) where x is the location parameter indicating the peak of the distribution, and y is the scale parameter. | √ | × | |
Returns a value for the chi-square distribution. The function uses the following formula: P(N <= v; k) where k indicates the degree of freedom. | √ | × | |
Returns a value for the inverse of the beta distribution. p indicates the result of the beta CDF, which uses the P(N <= v; α, β) formula. The inverse inverse_beta_cdf function calculates v. | √ | × | |
Returns a value for the inverse of the binomial distribution. p indicates the result of the binomial CDF, which uses the P(N <= v; x, y) formula. The inverse inverse_binomial_cdf function calculates v. | √ | × | |
Returns a value for the inverse of the Cauchy distribution. p indicates the result of the Cauchy CDF, which uses the P(N <= v; x, y) formula. The inverse inverse_cauchy_cdf function calculates v. | √ | × | |
Returns a value for the inverse of the chi-square distribution. p indicates the result of the chi-square CDF, which uses the P(N <= v; k) formula. The inverse inverse_chi_squared_cdf function calculates v. | √ | × | |
Returns a value for the inverse of the Laplace distribution. p indicates the result of the Laplace CDF, which uses the P(N <= v; μ, b) formula. The inverse inverse_laplace_cdf function calculates v. | √ | × | |
Returns a value for the inverse of the normal distribution. p indicates the result of the normal CDF, which uses the P(N < v; x, y) formula. The inverse inverse_normal_cdf function calculates v. | √ | × | |
Returns a value for the inverse of the Poisson distribution. p indicates the result of the Poisson CDF, which uses the P(N <= v; λ) formula. The inverse inverse_poisson_cdf function calculates v. | √ | × | |
Returns a value for the inverse of the Weibull distribution. p indicates the result of the Weibull CDF, which uses the P(N <= v; x, y) formula. The inverse inverse_weibull_cdf function calculates v. | √ | × | |
Returns a value for the Laplace distribution. The function uses the following formula: P(N <= v; μ, b) where μ is the location parameter, and b is the scale parameter. | √ | × | |
Returns a value for the normal distribution. The function uses the following formula: P(N < v; x, y) where x indicates the mean value for the normal distribution, and y indicates the standard deviation for the normal distribution. | √ | × | |
Returns a value for the Poisson distribution. The function uses the following formula: P(N <= v; λ) where λ indicates the average probability of random events. | √ | × | |
Returns a value for the Weibull distribution. The function uses the following formula: P(N <= v; x, y) where x is the scale parameter, and y is the shape parameter. | √ | × |
Type conversion functions
Function | Description | Supported in SQL | Supported in SPL |
Converts the values in the x field to a specified data type. If the cast function fails to convert a value, the query statement that uses this function fails. | √ | √ | |
Converts the values in the x field to a specified data type. If the try_cast function fails to convert a value, the function returns NULL. The query statement that uses this function skips the value and continues to run. Note Logs may contain dirty data. When you query logs, we recommend that you use the try_cast function. This way, conversion failures will not cause your query statement to fail. | √ | × | |
Returns the data type of the x field. | √ | × |
Window functions
Function | Description | Supported in SQL | Supported in SPL |
You can use all aggregate functions in window functions. For more information, see Aggregate functions. | √ | × | |
Calculates the cumulative distribution of each value in a partition. The result is obtained by using division. The numerator is the number of rows whose field values are less than or equal to the field value of the specified row. The specified row is also counted. The denominator is the total number of rows in the partition. The calculation is based on the order of the rows in the partition. The return value is in the range of (0,1]. | √ | × | |
Calculates the rank of each value of a specified field in a partition. If two values are the same, the values are assigned the same rank. The ranks are consecutive. For example, if two values are the same and assigned the same rank of 1, the next rank is 2. | √ | × | |
Divides the rows in each partition into n groups based on a specifeid order. | √ | × | |
Calculates the percentage rank of each row in a partition. | √ | × | |
Calculates the rank of each value of a specified field in a partition. If two values are the same, the values are assigned the same rank. The ranks are not consecutive. For example, if two values are the same and assigned the same rank of 1, the next rank is 3. | √ | × | |
Calculates the rank of each value of a specified field in a partition. Each value is assigned a unique rank. The ranks start from 1. For example, if three values are the same, the values are assigned the ranks of 1, 2, and 3. | √ | × | |
Returns the value of a specified field in the first row of each partition. | √ | × | |
Returns the value of a specified field in the last row of each partition. | √ | × | |
Returns the value of a specified field in the row that is at the specified offset before the current row in a partition. If no row exists at the specified offset before the current row, the value that is specified by the default_value parameter is returned. | √ | × | |
Returns the value of a specified field in the row that is at the specified offset after the current row in a partition. If no row exists at the specified offset after the current row, the value that is specified by the default_value parameter is returned. | √ | × | |
Returns the value of a specified field in the row that is at the specified offset from the beginning of a partition. | √ | × |
IP functions
Function | Description | Supported in SQL | Supported in SPL |
Identifies the city to which an IP address belongs. The function returns the Chinese name of a city. | √ | × | |
Identifies the city to which an IP address belongs. The function returns the administrative division code of a city. | √ | × | |
Identifies the longitude and latitude of the city to which an IP address belongs. The function returns the longitude and latitude of a city. Each city has only one set of coordinates. | √ | × | |
Identifies the country or region to which an IP address belongs. The function returns the Chinese name of a country or region. | √ | × | |
Identifies the country or region to which an IP address belongs. The function returns the code of a country or region. | √ | × | |
Identifies the country or region to which an IP address belongs. The function returns the code of a country or region. | √ | × | |
Checks whether an IP address is a private or public address. | √ | × | |
Identifies the longitude and latitude of the location of an IP address. | √ | × | |
Identifies the Internet service provider (ISP) of an IP address. | √ | × | |
Identifies the state to which an IP address belongs. The function returns the Chinese name of a state. | √ | × | |
Identifies the state to which an IP address belongs. The function returns the administrative division code of a state. | √ | × | |
Returns the prefix of an IP address. | √ | × | |
Checks whether a CIDR block is a subnet of a specified CIDR block. | √ | × | |
Checks whether an IP address is in a specified CIDR block. | √ | × | |
Returns the largest IP address in a CIDR block. | √ | × | |
Returns the smallest IP address in a CIDR block. | √ | × | |
Returns the range of a CIDR block. | √ | × | |
Identifies the city to which an IPv6 address belongs. | √ | × | |
Identifies the administrative division code of the city to which an IPv6 address belongs. | √ | × | |
Identifies the longitude and latitude of the city to which an IPv6 address belongs. | √ | × | |
Identifies the country or region to which an IPv6 address belongs. | √ | × | |
Identifies the code of the country or region to which an IPv6 address belongs. | √ | × | |
Checks whether an IPv6 address is a private or public address. | √ | × | |
Identifies the ISP of an IPv6 address. | √ | × | |
Identifies the province to which an IPv6 address belongs. | √ | × | |
Identifies the administrative division code of the province to which an IPv6 address belongs. | √ | × |
URL functions
Function | Description | Supported in SQL | Supported in SPL |
Encodes a URL. | √ | √ | |
Decodes a URL. | √ | √ | |
Extracts the fragment from a URL. | √ | √ | |
Extracts the host from a URL. | √ | √ | |
Extracts the value of a specified parameter in the query string from a URL. | √ | √ | |
Extracts the path from a URL. | √ | √ | |
Extracts the port number from a URL. | √ | √ | |
Extracts the protocol from a URL. | √ | √ | |
Extracts the query string from a URL. | √ | √ |
Approximate functions
Function | Description | Supported in SQL | Supported in SPL |
Estimates the number of distinct values in x. The default standard error is 2.3%. | √ | × | |
Estimates the number of distinct values in x. You can specify a custom standard error. | √ | × | |
Sorts the values in x in ascending order, and returns the value at the approximate position specified by percentage. | √ | × | |
Sorts the values in x in ascending order, and returns the values at the approximate positions specified by percentage01 and percentage02. | √ | × | |
Sorts the values in x in ascending order based on the products of the values in x and the weight, and returns the value at the approximate position specified by percentage. | √ | × | |
Sorts the values in x in ascending order based on the products of the values in x and the weight, and returns the values at the approximate positions specified by percentage01 and percentage02. | √ | × | |
Sorts the values in x in ascending order based on the products of the values in x and the weight, and returns the value at the approximate position specified by percentage. You can specify the accuracy of the return value. | √ | × | |
Returns the estimated histogram of x based on the number of histogram columns. The number is specified by bucket. The return value is of the JSON type. | √ | × | |
Returns the estimated histogram of x based on the number of histogram columns. The number is specified by bucket. The return value is of the JSON type. You can specify a weight for the values in x. | √ | × | |
Returns the estimated histogram of x based on the number of histogram columns. The number is specified by bucket. The return value contains multiple rows and columns. | √ | × |
Binary functions
Function | Description | Supported in SQL | Supported in SPL |
Decodes a Base64-encoded string into a binary number. | √ | √ | |
Decodes a Base64-encoded string into a binary number by using URL reserved characters. | √ | × | |
Decodes a binary number in big endian into a bigint value. | √ | × | |
Decodes a hexadecimal number into a binary number. | √ | √ | |
Returns the length of a binary number. | √ | × | |
Computes the MD5 hash value for a binary number. | √ | √ | |
Encodes a binary number into a Base64 string representation. | √ | ||
Encodes a binary number into a Base64 string representation by using URL reserved characters. | √ | × | |
Encodes a binary number into a hexadecimal number. | √ | √ | |
Encodes a bigint value into a binary number in big endian. | √ | × | |
Computes the SHA-1 hash value for a binary number. | √ | √ | |
Computes the SHA-256 hash value for a binary number. | √ | √ | |
Computes the SHA-512 hash value for a binary number. | √ | √ | |
Computes the xxhash64 hash value for a binary number. | √ | √ |
Bitwise functions
Function | Description | Supported in SQL | Supported in SPL |
Returns the number of bits 1 in x in binary representation. | √ | √ | |
Returns the result of the bitwise AND operation on x and y in binary representation. | √ | √ | |
Returns the result of the bitwise NOT operation on x in binary representation. | √ | √ | |
Returns the result of the bitwise OR operation on x and y in binary representation. | √ | √ | |
Returns the result of the bitwise XOR operation on x and y in binary representation. | √ | √ |
Geospatial functions
Function | Description | Supported in SQL | Supported in SPL |
Returns the WKT representation of a geometry. | √ | × | |
Returns the closure of the combinatorial boundary of a geometry. | √ | × | |
Returns a geometry that represents all points whose distance from the specified geometry is less than or equal to the specified distance. | √ | × | |
Returns a geometry that represents the point set difference of two specified geometries. | √ | × | |
Returns the bounding rectangular polygon of a geometry. | √ | × | |
Returns a line string that represents the exterior ring of a geometry. | √ | × | |
Returns a geometry that represents the point set intersection of two specified geometries. | √ | × | |
Returns a geometry that represents the point set symmetric difference of two specified geometries. | √ | × | |
Returns true if no points of the second geometry lie in the exterior of the first geometry and at least one point of the interior of the first geometry lies in the interior of the second geometry. | √ | × | |
Returns true if two specified geometries have several interior points in common. | √ | × | |
Returns true if two specified geometries do not share any portion of two-dimensional space. | √ | × | |
Returns true if two specified geometries represent the same geometry. | √ | × | |
Returns true if two specified geometries share a portion of two-dimensional space. | √ | × | |
Returns true if two specified geometries share space and have the same dimension but are not completely contained by each other. | √ | × | |
Returns true if two specified geometries have a spatial relationship. | √ | × | |
Returns true if two specified geometries have at least one point in common but their interiors do not intersect. | √ | × | |
Returns true if the first geometry is completely inside the second geometry. | √ | × | |
Calculates the projected area of a geometry on a two-dimensional plane by using the Euclidean distance method. | √ | × | |
Returns the point value that represents the mathematical centroid of a geometry. | √ | × | |
Returns the coordinate dimension of a geometry. | √ | × | |
Returns the inherent dimension of a geometry. The inherent dimension must be less than or equal to the coordinate dimension. | √ | × | |
Returns the minimum distance between two geometries. | √ | × | |
Returns the last point of a line string. | √ | × | |
Returns true if the start point of a line string coincides with the end point. | √ | × | |
Returns true if a geometry is empty. | √ | × | |
Returns true if a line string is closed and simple. | √ | × | |
Calculates the projected length of a line string on a two-dimensional plane by using the Euclidean distance method. If multiple line strings exist, the function returns the sum of the lengths of the multiple line strings. | √ | × | |
Returns the number of points in a geometry. | √ | × | |
Returns the number of interior rings in a geometry. | √ | × | |
Returns the first point of a line string. | √ | × | |
Returns the X-coordinate of a specified point. | √ | × | |
Returns the maximum first X-coordinate of a geometry. | √ | × | |
Returns the minimum first X-coordinate of a geometry. | √ | × | |
Returns the Y-coordinate of a specified point. | √ | × | |
Returns the maximum first Y-coordinate of a geometry. | √ | × | |
Returns the minimum first Y-coordinate of a geometry. | √ | × | |
Returns a Bing tile based on the X-coordinate, Y-coordinate, and zoom level. | √ | × | |
Returns a Bing tile based on the quadtree key. | √ | × | |
Returns a Bing tile based on the latitude, longitude, and zoom level. | √ | × | |
Returns the X- and Y-coordinates of a Bing tile. | √ | × | |
Returns the polygon format of a Bing tile. | √ | × | |
Returns the quadtree key of a Bing tile. | √ | × | |
Returns the zoom level of a Bing tile. | √ | × |
Geo function
Function | Description | Supported in SQL | Supported in SPL |
Encodes latitudes and longitudes by using the Geohash algorithm. | √ | × |
Color functions
Function | Description | Supported in SQL | Supported in SPL |
Returns a part of an ANSI bar chart. You can configure the width parameter to specify the width of the ANSI bar chart. However, you cannot configure the high_color or low_color parameter to specify the colors for the chart. The default values of the high_color and low_color parameters are used. The default value of the low_color parameter is red, and the default value of the high_color parameter is green. In addition, you can configure x to specify the length of the part that is returned by the function. | √ | × | |
Returns a part of an ANSI bar chart. You can configure the width parameter to specify the width of the ANSI bar chart. You can also configure the high_color and low_color parameters to specify custom colors for the chart. In addition, you can configure x to specify the length of the part that is returned by the function. | √ | × | |
Converts a color string to a color type. | √ | × | |
Returns a color between high_color and low_color based on the portions of high_color and low_color. The portions are determined by the proportion of x between high and low. | √ | × | |
Returns a color between high_color and low_color based on the portions of high_color and low_color. The portions are determined by y. | √ | × | |
Returns results by using color rendering. If the Boolean expression evaluates to true, the function returns a green tick. If the Boolean expression evaluates to false, the function returns a red cross. | √ | × | |
Returns results by using custom color rendering. | √ | × | |
Returns a color value based on an RGB value. | √ | × |
HyperLogLog functions
Function | Description | Supported in SQL | Supported in SPL |
Estimates the number of distinct values in the x field. The maximum standard error is 0.01625, which is the default value. | √ | × | |
Converts HyperLogLog data to bigint data. | √ | × | |
Returns a null value of the HyperLogLog type. The maximum standard error is 0.01625, which is the default value. | √ | × | |
Aggregates all HyperLogLog values. | √ | × |
Comparison operators
Operator | Description | Supported in SQL | Supported in SPL |
Compares x and y. If the condition is met, true is returned. | √ | √ | |
If x meets all conditions, true is returned. | √ | × | |
If x meets one of the conditions, true is returned. | √ | × | |
If x is between y and z, true is returned. | √ | √ | |
x IS DISTINCT FROM y: If x is not equal to y, true is returned. | √ | × | |
x IS NOT DISTINCT FROM y: If x is equal to y, true is returned. | √ | × | |
Matches a specified character pattern in a string. The string is case-sensitive. | √ | √ | |
If x meets one of the conditions, true is returned. | √ | × | |
Obtains the greater value of x and y. | √ | × | |
Obtains the smaller value of x and y. | √ | × | |
x IS NULL: If x is null, true is returned. | √ | × | |
x IS NOT NULL: If x is not null, true is returned. | √ | × |
Logical operators
Operator | Description | Supported in SQL | Supported in SPL |
If both x and y evaluate to true, true is returned. | √ | √ | |
If either x or y evaluates to true, true is returned. | √ | √ | |
If x evaluates to false, true is returned. | √ | √ |
Unit conversion functions
Function | Description | Supported in SQL | Supported in SPL |
Converts a measurement from the current unit to the optimal unit. The system automatically determines the optimal unit and returns a measurement in the optimal unit. The returned result is of the string type. For example, you can convert 1,024 KB to 1 MB and 1,024 MB to 1 GB. | √ | × | |
Converts a measurement from the current unit to a specified unit. The returned result is of the string type. | √ | × | |
Converts a measurement in byte to a measurement in a specified unit. The returned result is of the string type. | √ | × | |
Converts a measurement from the current unit to a measurement in byte. The returned result is of the decimal type. | √ | × | |
Converts a measurement from the current unit to a measurement in byte. The returned result is of the double type. | √ | × | |
Converts a measurement from the current unit to a measurement in KB. The returned result is of the double type. | √ | × | |
Converts a measurement from the current unit to a measurement in MB. The returned result is of the double type. | √ | × | |
Converts a measurement from the current unit to a measurement in GB. The returned result is of the double type. | √ | × | |
Converts a measurement from the current unit to a measurement in TB. The returned result is of the double type. | √ | × | |
Converts a measurement from the current unit to a measurement in PB. The returned result is of the double type. | √ | × | |
Converts a time interval in seconds to a readable string. | √ | × | |
Converts a time interval to a time interval in the | √ | × | |
Converts a time interval to a time interval in days. | √ | × | |
Converts a time interval to a time interval in hours. | √ | × | |
Converts a time interval to a time interval in microseconds. | √ | × | |
Converts a time interval to a time interval in milliseconds. | √ | × | |
Converts a time interval to a time interval in minutes. | √ | × | |
Converts a time interval from the current unit to the optimal unit. The system automatically determines the optimal unit and returns a time interval in the optimal unit. | √ | × | |
Converts a time interval to a time interval in nanoseconds. | √ | × | |
Converts a time interval to a time interval in seconds. | √ | × |
Window funnel function
Function | Description | Supported in SQL | Supported in SPL |
Searches for an event chain in a sliding time window and counts the maximum number of consecutive events in the event chain. | √ | × |
Lambda expressions
Simple Log Service allows you to define a lambda expression in an SQL statement or an SPL statement and pass the expression to a specified function. For more information, see Lambda expressions.
Conditional expressions
Expression | Description | Supported in SQL | Supported in SPL |
Classifies data based on specified conditions. | √ | √ | |
Classifies data based on specified conditions. | √ | √ | |
Returns the first non-null value of multiple expressions. | √ | √ | |
Evaluates whether the values of two expressions are the same. If the values are the same, null is returned. Otherwise, the value of the first expression is returned. | √ | × | |
Captures errors that occur during the invocation of an expression and ensures that Simple Log Service can continue to query and analyze data even if errors occur. | √ | √ |
Vector calculation functions
Function | Description | Supported in SQL | Supported in SPL |
Calculates the cosine similarity of two vectors. Valid values of the cosine similarity: [-1, 1].
| √ | × | |
Calculates the inner product of two vectors. | √ | × | |
Calculates the Euclidean distance between two vectors. | √ | × | |
Calculates the norm of a vector. The norm of a vector is equivalent to the magnitude of the vector. | √ | × | |
Calculates the sum of all elements of a vector. | √ | × | |
Calculates the mean of a vector. | √ | × | |
Calculates the variance of a vector. Variance measures the dispersion of the elements of a vector. Variance is the average of the squared distances from each element of the vector to the mean. | √ | × | |
Calculates the standard deviation of a vector. The standard deviation of a vector is the positive square root of its variance. Variance measures how far each data point in a dataset is from the mean. A high variance value indicates that the data points are significantly spread out from the mean. A low variance value indicates that the data points are close to the mean. | √ | × | |
Calculates the sum of two vectors. You can perform arbitrary linear transformation based on vector addition, vector subtraction, and vector scaling functions. | √ | × | |
Calculates the difference between two vectors. You can perform arbitrary linear transformation based on vector addition, vector subtraction, and vector scaling functions. | √ | × | |
Calculates the result of vector scaling. You can perform arbitrary linear transformation based on vector addition, vector subtraction, and vector scaling functions. | √ | × |