...
Constructor Function | Operands | Description |
---|---|---|
map | (key1, value1, key2, value2, ...) | Creates a map with the given key/value pairs |
struct | (val1, val2, val3, ...) | Creates a struct with the given field values. Struct field names will be col1, col2, ... |
named_struct | (name1, val1, name2, val2, ...) | Creates a struct with the given field names and values. |
array | (val1, val2, ...) | Creates an array with the given elements |
...
Operator | Operand types | Description | ||
---|---|---|---|---|
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="5437c8d36fff952b-0c7b4e39-413b4e21-afd9adfb-85c7f99ea818815a07926f07"><ac:plain-text-body><![CDATA[ | A[n] | A is an Array and n is an int | Returns the nth element in the array A. The first element has index 0 e.g. if A is an array comprising of ['foo', 'bar'] then A[0] returns 'foo' and A[1] returns 'bar' | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="4e9858dffa9e465d-f89d1a95-42764c7f-9f438e8c-5dbd749f261bca41dc2c87e5"><ac:plain-text-body><![CDATA[ | M[key] | M is a Map<K, V> and key has type K | Returns the value corresponding to the key in the map e.g. if M is a map comprising of {'f' -> 'foo', 'b' -> 'bar', 'all' -> 'foobar'} then M['all'] returns 'foobar' | ]]></ac:plain-text-body></ac:structured-macro> |
S.x | S is a struct | Returns the x field of S. e.g for struct foobar {int foo, int bar} foobar.foo returns the integer stored in the foo field of the struct. |
...
Return Type | Name(Signature) | Description | ||
---|---|---|---|---|
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="4c91a194e987d153-64500a6b-489d44e0-88388318-ebad9165635c98543a55c462"><ac:plain-text-body><![CDATA[ | string | from_unixtime(bigint unixtime[, string format]) | 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 format of "1970-01-01 00:00:00" | ]]></ac:plain-text-body></ac:structured-macro> |
bigint | unix_timestamp() | Gets current time stamp using the default time zone. | ||
bigint | unix_timestamp(string date) | Converts time string in format | ||
bigint | unix_timestamp(string date, string pattern) | Convert time string with given pattern (see [http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html]) to Unix time stamp, return 0 if fail: unix_timestamp('2009-03-20', 'yyyy-MM-dd') = 1237532400 | ||
string | to_date(string timestamp) | Returns the date part of a timestamp string: to_date("1970-01-01 00:00:00") = "1970-01-01" | ||
int | year(string date) | Returns the year part of a date or a timestamp string: year("1970-01-01 00:00:00") = 1970, year("1970-01-01") = 1970 | ||
int | month(string date) | Returns the month part of a date or a timestamp string: month("1970-11-01 00:00:00") = 11, month("1970-11-01") = 11 | ||
int | day(string date) dayofmonth(date) | Return the day part of a date or a timestamp string: day("1970-11-01 00:00:00") = 1, day("1970-11-01") = 1 | ||
int | hour(string date) | Returns the hour of the timestamp: hour('2009-07-30 12:58:59') = 12, hour('12:58:59') = 12 | ||
int | minute(string date) | Returns the minute of the timestamp | ||
int | second(string date) | Returns the second of the timestamp | ||
int | weekofyear(string date) | Return the week number of a timestamp string: weekofyear("1970-11-01 00:00:00") = 44, weekofyear("1970-11-01") = 44 | ||
int | datediff(string enddate, string startdate) | Return the number of days from startdate to enddate: datediff('2009-03-01', '2009-02-27') = 2 | ||
int | date_add(string startdate, int days) | Add a number of days to startdate: date_add('2008-12-31', 1) = '2009-01-01' | ||
int | date_sub(string startdate, int days) | Subtract a number of days to startdate: date_sub('2008-12-31', 1) = '2008-12-30' |
...
Return Type | Name(Signature) | Description | ||
---|---|---|---|---|
T | if(boolean testCondition, T valueTrue, T valueFalseOrNull) | Return valueTrue when testCondition is true, returns valueFalseOrNull otherwise | ||
T | COALESCE(T v1, T v2, ...) | Return the first v that is not NULL, or NULL if all v's are NULL | ||
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="758929c134cd6a66-2f6f0854-47f04f36-a912abef-c19ce3706bfe938309631101"><ac:plain-text-body><![CDATA[ | T | CASE a WHEN b THEN c [WHEN d THEN e]* [ELSE f] END | When a = b, returns c; when a = d, return e; else return f | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="949a38e30eaefc64-b7bc1739-4427450a-a5fcb9a6-b1ccdd1bf467577fecfc6b0e"><ac:plain-text-body><![CDATA[ | T | CASE WHEN a THEN b [WHEN c THEN d]* [ELSE e] END | When a = true, returns b; when c = true, return d; else return e | ]]></ac:plain-text-body></ac:structured-macro> |
...
Return Type | Name(Signature) | Description | ||
---|---|---|---|---|
int | length(string A) | Returns the length of the string | ||
string | reverse(string A) | Returns the reversed string | ||
string | concat(string A, string B...) | Returns the string resulting from concatenating the strings passed in as parameters in order. e.g. concat('foo', 'bar') results in 'foobar'. Note that this function can take any number of input strings. | ||
string | concat_ws(string SEP, string A, string B...) | Like concat() above, but with custom separator SEP. | ||
string | substr(string A, int start) substring(string A, int start) | Returns the substring of A starting from start position till the end of string A e.g. substr('foobar', 4) results in 'bar' (see [http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_substr]) | ||
string | substr(string A, int start, int len) substring(string A, int start, int len) | Returns the substring of A starting from start position with length len e.g. substr('foobar', 4, 1) results in 'b' (see [http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_substr]) | ||
string | upper(string A) ucase(string A) | Returns the string resulting from converting all characters of A to upper case e.g. upper('fOoBaR') results in 'FOOBAR' | ||
string | lower(string A) lcase(string A) | Returns the string resulting from converting all characters of B to lower case e.g. lower('fOoBaR') results in 'foobar' | ||
string | trim(string A) | Returns the string resulting from trimming spaces from both ends of A e.g. trim(' foobar ') results in 'foobar' | ||
string | ltrim(string A) | Returns the string resulting from trimming spaces from the beginning(left hand side) of A e.g. ltrim(' foobar ') results in 'foobar ' | ||
string | rtrim(string A) | Returns the string resulting from trimming spaces from the end(right hand side) of A e.g. rtrim(' foobar ') results in ' foobar' | ||
string | regexp_replace(string A, string B, string C) | Returns the string resulting from replacing all substrings in B that match the Java regular expression syntax(See Java regular expressions syntax) with C e.g. regexp_replace("foobar", "oo|ar", "") returns 'fb.' Note that some care is necessary in using predefined character classes: using '\s' as the second argument will match the letter s; ' | ||
string | regexp_extract(string subject, string pattern, int index) | Returns the string extracted using the pattern. e.g. regexp_extract('foothebar', 'foo(.*?)(bar)', 2) returns 'bar.' Note that some care is necessary in using predefined character classes: using '\s' as the second argument will match the letter s; ' | ||
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="c19e0553df1f0194-1b21c3ea-43ce4b03-842d985b-4e8b8c2c9a612a9f8c499171"><ac:plain-text-body><![CDATA[ | string | parse_url(string urlString, string partToExtract [, string keyToExtract]) | Returns the specified part from the URL. Valid values for partToExtract include HOST, PATH, QUERY, REF, PROTOCOL, AUTHORITY, FILE, and USERINFO. e.g. parse_url('http://facebook.com/path1/p.php?k1=v1&k2=v2#Ref1', 'HOST') returns 'facebook.com'. Also a value of a particular key in QUERY can be extracted by providing the key as the third argument, e.g. parse_url('http://facebook.com/path1/p.php?k1=v1&k2=v2#Ref1', 'QUERY', 'k1') returns 'v1'. | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="65cfc832b4598258-c70bf5a1-44be4702-8e09b0be-f290198a501c6033b5c68586"><ac:plain-text-body><![CDATA[ | string | get_json_object(string json_string, string path) | Extract json object from a json string based on json path specified, and return json string of the extracted json object. It will return null if the input json string is invalid. NOTE: The json path can only have the characters [0-9a-z_], i.e., no upper-case or special characters. Also, the keys *cannot start with numbers.* This is due to restrictions on Hive column names. | ]]></ac:plain-text-body></ac:structured-macro> |
string | space(int n) | Return a string of n spaces | ||
string | repeat(string str, int n) | Repeat str n times | ||
int | ascii(string str) | Returns the numeric value of the first character of str | ||
string | lpad(string str, int len, string pad) | Returns str, left-padded with pad to a length of len | ||
string | rpad(string str, int len, string pad) | Returns str, right-padded with pad to a length of len | ||
array | split(string str, string pat) | Split str around pat (pat is a regular expression) | ||
int | find_in_set(string str, string strList) | Returns the first occurance of str in strList where strList is a comma-delimited string. Returns null if either argument is null. Returns 0 if the first argument contains any commas. e.g. find_in_set('ab', 'abc,b,ab,c,def') returns 3 | ||
array<array<string>> | sentences(string str, string lang, string locale) | Tokenizes a string of natural language text into words and sentences, where each sentence is broken at the appropriate sentence boundary and returned as an array of words. The 'lang' and 'locale' are optional arguments. e.g. sentences('Hello there! How are you?') returns ( ("Hello", "there"), ("How", "are", "you") ) | ||
array<struct<string,double>> | ngrams(array<array<string>>, int N, int K, int pf) | Returns the top-k N-grams from a set of tokenized sentences, such as those returned by the sentences() UDAF. See StatisticsAndDataMining for more information. | ||
array<struct<string,double>> | context_ngrams(array<array<string>>, array<string>, int K, int pf) | Returns the top-k contextual N-grams from a set of tokenized sentences, given a string of "context". See StatisticsAndDataMining for more information. |
...
Return Type | Name(Signature) | Description | ||
---|---|---|---|---|
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="dec90864fe7808ab-0adb3ced-416c4f51-bb0f870f-f62645ecd24a873d264d20fc"><ac:plain-text-body><![CDATA[ | bigint | count(*), count(expr), count(DISTINCT expr[, expr_.]) | count(*) - Returns the total number of retrieved rows, including rows containing NULL values; count(expr) - Returns the number of rows for which the supplied expression is non-NULL; count(DISTINCT expr[, expr]) - Returns the number of rows for which the supplied expression(s) are unique and non-NULL. | ]]></ac:plain-text-body></ac:structured-macro> |
double | sum(col), sum(DISTINCT col) | Returns the sum of the elements in the group or the sum of the distinct values of the column in the group | ||
double | avg(col), avg(DISTINCT col) | Returns the average of the elements in the group or the average of the distinct values of the column in the group | ||
double | min(col) | Returns the minimum of the column in the group | ||
double | max(col) | Returns the maximum value of the column in the group | ||
double | var_pop(col) | Returns the variance of a numeric column in the group | ||
double | var_samp(col) | Returns the unbiased sample variance of a numeric column in the group | ||
double | stddev_pop(col) | Returns the standard deviation of a numeric column in the group | ||
double | stddev_samp(col) | Returns the unbiased sample standard deviation of a numeric column in the group | ||
double | covar_pop(col1, col2) | Returns the population covariance of a pair of numeric columns in the group | ||
double | covar_samp(col1, col2) | Returns the sample covariance of a pair of a numeric columns in the group | ||
double | corr(col1, col2) | Returns the Pearson coefficient of correlation of a pair of a numeric columns in the group | ||
double | percentile(col, p) | Returns the exact p^th^ percentile of an integer column in the group (does not work with floating point types). p must be between 0 and 1. | ||
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="34f40f885d4681ae-528e900c-44224935-9cb1983a-39fbf2b40049cda4abd3a755"><ac:plain-text-body><![CDATA[ | array<double> | percentile(col, array(p~1,, [, p,,2,,]...)) | Returns the exact percentiles p,,1,,, p,,2,,, ... of an integer column in the group (does not work with floating point types). p,,i~ must be between 0 and 1. | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="b114fa10b54424b6-74bb0985-4c8b4040-87918613-8dac76143a19afa2143250b9"><ac:plain-text-body><![CDATA[ | double | percentile_approx(col, p [, B]) | Returns an approximate p^th^ percentile of a numeric column (including floating point types) in the group. The B parameter controls approximation accuracy at the cost of memory. Higher values yield better approximations, and the default is 10,000. When the number of distinct values in col is smaller than B, this gives an exact percentile value. | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="1f4f7bb31d8cd0f1-38aa2b62-4b4940a9-b1e0b370-aa68c07f896f109ade0c981f"><ac:plain-text-body><![CDATA[ | array<double> | percentile_approx(col, array(p~1,, [, p,,2_]...) [, B]) | Same as above, but accepts and returns an array of percentile values instead of a single one. | ]]></ac:plain-text-body></ac:structured-macro> |
array<struct { | histogram_numeric(col, b) | Computes a histogram of a numeric column in the group using b non-uniformly spaced bins. The output is an array of size b of double-valued (x,y) coordinates that represent the bin centers and heights | ||
array | collect_set(col) | Returns a set of objects with duplicate elements eliminated |
...
Array<int> myCol | ||
---|---|---|
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="32e88b0742c54226-7a80f58a-4a6f4d2f-89b5b7b3-6d9a96c3622495d9f8610c56"><ac:plain-text-body><![CDATA[ | [1,2,3] | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="c42b8b3c2460b447-1f34f5c2-46554bfb-9358be2b-7cf2e40e3f0842d8767fe80b"><ac:plain-text-body><![CDATA[ | [4,5,6] | ]]></ac:plain-text-body></ac:structured-macro> |
...