2021-10-09

HQL函数大全(中英对照版,方便查询)

Aggregate

avg(col)
Returns the average of the elements in the group or the average of the distinct values of the column in the group.
返回组中元素的平均值或组中列的不同值的平均值。

collect_set(col)
Returns a set of objects with duplicate elements eliminated.
返回消除了重复元素的一组对象。

collect_list(col)
Returns a list of objects with duplicates. (As of Hive 0.13.0.)
返回具有重复项的对象列表。 (从Hive 0.13.0开始。)

corr(col1, col2)
Returns the Pearson coefficient of correlation of a pair of a numeric columns in the group.
返回组中一对数字列的皮尔逊相关系数。

count([DISTINCT] col)
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. Execution of this can be optimized with hive.optimize.distinct.rewrite.
count(*)-返回检索到的行总数,包括包含NULL值的行。
 count(expr)-返回为其提供的表达式为非NULL的行数。
 count(DISTINCT expr [,expr])-返回所提供表达式唯一且非NULL的行数。 
可以使用hive.optimize.distinct.rewrite优化执行。

covar_pop(col1, col2)
Returns the population covariance of a pair of numeric columns in the group.
返回组中一对数字列的总体协方差。

covar_samp(col1, col2)
Returns the sample covariance of a pair of a numeric columns in the group.
返回组中一对数字列的样本协方差。

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.
使用b个非均匀间隔的bin计算组中数字列的直方图。 输出是大小为b的双值(x,y)坐标数组,这些坐标表示箱的中心和高度。

max(col)
Returns the maximum value of the column in the group.
返回组中列的最大值。

min(col)
Returns the minimum of the column in the group.
返回组中列的最小值。

ntile(INT x)
Divides an ordered partition into x groups called buckets and assigns a bucket number to each row in the partition. This allows easy calculation of tertiles, quartiles, deciles, percentiles and other common summary statistics. (As of Hive 0.11.0.)
将有序分区划分为x个称为存储桶的组,并为该分区中的每一行分配存储桶编号。
 这样可以轻松计算三分位数,四分位数,十分位数,百分位数和其他常见的汇总统计信息。 (从Hive 0.11.0开始。)
 
percentile(BIGINT col, p), array<DOUBLE> percentile(BIGINT col, array(p1 [, p2]...))
Returns the exact pth percentile (or percentiles p1, p2, ..) of a column in the group (does not work with floating point types). p must be between 0 and 1. NOTE: A true percentile can only be computed for integer values. Use PERCENTILE_APPROX if your input is non-integral.
返回组中列的精确pth百分位数(或百分位数p1,p2,..)(不适用于浮点类型)。 
p必须在0到1之间。注意:只能为整数值计算真实的百分位数。 如果您输入的内容不是整数,请使用PERCENTILE_APPROX。

percentile_approx(DOUBLE col, p, [, B]), array<DOUBLE> percentile_approx(DOUBLE col, array(p1 [, p2]...), [, B])
Returns an approximate pth percentile (or percentiles p1, p2, ..) 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.
返回组中数字列(包括浮点类型)的近似pth百分位数(或百分位数p1,p2,..)。
 B参数控制近似精度,但以存储为代价。 值越高,近似值越好,默认值是10,000。 
当col中不同值的数量小于B时,这将给出一个精确的百分位数值。

regr_avgx(T independent, T dependent)
Equivalent to avg(dependent). As of Hive 2.2.0.
等效于avg(dependent)。 从Hive 2.2.0开始。

regr_avgy(T independent, T dependent)
Equivalent to avg(dependent). As of Hive 2.2.0.
等效于avg(dependent)。 从Hive 2.2.0开始。

regr_count(T independent, T dependent)
Returns the number of non-null pairs used to fit the linear regression line. As of Hive 2.2.0.
返回用于拟合线性回归线的非空对的数量。 从Hive 2.2.0开始。

regr_intercept(T independent, T dependent)
Returns the y-intercept of the linear regression line, i.e. the value of b in the equation dependent = a * independent + b. As of Hive 2.2.0.
返回线性回归线的y截距,即方程式dependent = a * Independent + b中的b值。 从Hive 2.2.0开始。

regr_r2(T independent, T dependent)
Returns the coefficient of determination for the regression. As of Hive 2.2.0.
返回回归的确定系数。 从Hive 2.2.0开始。

regr_slope(T independent, T dependent)
Returns the slope of the linear regression line, i.e. the value of a in the equation dependent = a * independent + b. As of Hive 2.2.0.
返回线性回归线的斜率,即方程式dependent = a * Independent + b中的a值。 从Hive 2.2.0开始。

regr_sxx(T independent, T dependent)
Equivalent to regr_count(independent, dependent) * var_pop(dependent). As of Hive 2.2.0.
等效于regr_count(独立,从属)* var_pop(独立)。 从Hive 2.2.0开始。

regr_sxy(T independent, T dependent)
Equivalent to regr_count(independent, dependent) * covar_pop(independent, dependent). As of Hive 2.2.0.
等效于regr_count(独立,从属)* covar_pop(独立,从属)。 从Hive 2.2.0开始。

regr_syy(T independent, T dependent)
Equivalent to regr_count(independent, dependent) * var_pop(independent). As of Hive 2.2.0.
等效于regr_count(独立,从属)* var_pop(独立)。 从Hive 2.2.0开始。

stddev_pop(col)
Returns the standard deviation of a numeric column in the group.
返回组中数字列的标准偏差。

stddev_samp(col)
Returns the unbiased sample standard deviation of a numeric column in the group.
返回组中数字列的无偏样本标准差。

sum(col)
Returns the sum of the elements in the group or the sum of the distinct values of the column in the group.
返回组中元素的总和或组中列的不同值的总和。

variance(col)
Returns the variance of a numeric column in the group.
返回组中数字列的方差。

var_pop(col)
Returns the variance of a numeric column in the group.
返回组中数字列的方差。

var_samp(col)
Returns the unbiased sample variance of a numeric column in the group.
返回组中数字列的无偏样本方差。

Analytic

 cume_dist()
无
dense_rank() OVER([partition_by_clause] order_by_clause)
Returns an ascending sequence of integers, starting with 1. The output sequence produces duplicate integers for duplicate values of the ORDER BY expressions.
返回从1开始的整数升序。输出序列为ORDER BY表达式的重复值生成重复的整数。

first_value(expr) OVER([partition_by_clause] order_by_clause [window_clause])
Returns the expression value from the first row in the window. The return value is NULL if the input expression is NULL.
从窗口的第一行返回表达式值。 如果输入表达式为NULL,则返回值为NULL。

lag(expr [, offset] [, default]) OVER ([partition_by_clause] order_by_clause)
This function returns the value of an expression using column values from a preceding row. You specify an integer offset, which designates a row position some number of rows previous to the current row. Any column references in the expression argument refer to column values from that prior row.
此函数使用前一行的列值返回表达式的值。 您指定一个整数偏移量,该偏移量指定行位置在当前行之前的一些行。 表达式参数中的任何列引用都引用该前一行的列值。

last_value(expr) OVER([partition_by_clause] order_by_clause [window_clause])
Returns the expression value from the last row in the window. The return value is NULL if the input expression is NULL.
从窗口的最后一行返回表达式值。 如果输入表达式为NULL,则返回值为NULL。

lead(expr [, offset] [, default]) OVER([partition_by_clause] order_by_clause)
This function returns the value of an expression using column values from a following row. You specify an integer offset, which designates a row position some number of rows after to the current row. Any column references in the expression argument refer to column values from that later row.
此函数使用下一行的列值返回表达式的值。 您指定一个整数偏移量,它指定一个行位置到当前行之后一定数量的行。 表达式参数中的任何列引用都引用该后一行中的列值。

ntile()
无

percent_rank()
无

rank() OVER([partition_by_clause] order_by_clause)
Returns an ascending sequence of integers, starting with 1. The output sequence produces duplicate integers for duplicate values of the ORDER BY expressions. After generating duplicate output values for the "tied" input values, the function increments the sequence by the number of tied values.
返回从1开始的整数升序。输出序列为ORDER BY表达式的重复值生成重复的整数。 在为“附加”输入值生成重复的输出值之后,该函数将顺序增加绑定值的数量。

row_number() OVER([partition_by_clause] order_by_clause)
Returns an ascending sequence of integers, starting with 1. Starts the sequence over for each group produced by the PARTITIONED BY clause. The output sequence includes different values for duplicate input values. Therefore, the sequence never contains any duplicates or gaps, regardless of duplicate input values.
返回以1开头的整数的升序序列。为PARTITIONED BY子句产生的每个组重新开始序列。 对于重复的输入值,输出序列包括不同的值。 因此,无论输入值是否重复,该序列都不会包含任何重复项或间隔。

Collection

array_contains(Array<T> a, val)
Returns TRUE if the array contains value.
如果数组包含值,则返回TRUE。

array<K.V> map_keys(Map<K.V> a)
Returns an unordered array containing the keys of the input map.
返回包含输入映射键的无序数组。

array<K.V> map_values(Map<K.V> a)
Returns an unordered array containing the values of the input map.
返回包含输入映射值的无序数组。

size(Map<K.V>|Array<T> a)
Returns the number of elements in the map or array type.
返回映射或数组类型中的元素数。

sort_array(Array<T> a)
Sorts the input array in ascending order according to the natural ordering of the array elements and returns it.
根据数组元素的自然顺序对输入数组进行升序排序并返回它。

Complex Type

array(val1, val2, ...)
Creates an array with the given elements.
用给定的元素创建一个数组。

create_union(tag, val1, val2, ...)
Creates a union type with the value that is being pointed to by the tag parameter.
用tag参数指向的值创建一个联合类型。

map(key1, value1, ...)
Creates a map with the given key/value pairs.
使用给定的键/值对创建一个映射。

named_struct(name1, val1, ...)
Creates a struct with the given field names and values.
使用给定的字段名称和值创建一个结构。

struct(val1, val2, ...)
Creates a struct with the given field values. Struct field names will be col1, col2, ....
用给定的字段值创建一个结构。 结构字段名称将为col1,col2,...。

Conditional

assert_true(BOOLEAN condition)
Throw an exception if 'condition' is not true, otherwise return null (as of Hive 0.8.0). For example, select assert_true (2<1).
如果'condition'不为true,则引发异常,否则返回null(从Hive 0.8.0开始)。 例如,选择assert_true(2 <1)。

coalesce(T v1, T v2, ...)
Returns the first v that is not NULL, or NULL if all v's are NULL.
返回第一个不为NULL的v,如果所有v均为NULL,则返回NULL。

if(BOOLEAN testCondition, T valueTrue, T valueFalseOrNull)
Returns valueTrue when testCondition is true, returns valueFalseOrNull otherwise.
当testCondition为true时返回valueTrue,否则返回valueFalseOrNull。

isnotnull(a)
Returns true if a is not NULL and false otherwise.
如果a不为NULL,则返回true,否则返回false。

isnull(a)
Returns true if a is NULL and false otherwise.
如果a为NULL,则返回true,否则返回false。

nullif(a, b)
Returns NULL if a=b; otherwise returns a (as of Hive 2.2.0).
如果a = b,则返回NULL;否则返回NULL。 否则返回一个(从Hive 2.2.0开始)。

nvl(T value, T default_value)
Returns default value if value is null else returns value (as of Hive 0.11).
如果value为null,则返回默认值,否则返回值(从Hive 0.11开始)。

Date

add_months(DATE|STRING|TIMESTAMP start_date, INT num_months)
Returns the date that is num_months after start_date (as of Hive 1.1.0). start_date is a string, date or timestamp. num_months is an integer. The time part of start_date is ignored. If start_date is the last day of the month or if the resulting month has fewer days than the day component of start_date, then the result is the last day of the resulting month. Otherwise, the result has the same day component as start_date.
返回起始日期之后num_months的日期(从Hive 1.1.0开始)。 start_date是字符串,日期或时间戳。 num_months是一个整数。 start_date的时间部分将被忽略。 如果start_date是该月的最后一天,或者如果结果月份的天数少于start_date的天部分,则结果是结果月份的最后一天。 否则,结果与start_date具有相同的日组成部分。

current_date
Returns the current date at the start of query evaluation (as of Hive 1.2.0). All calls of current_date within the same query return the same value.
返回查询评估开始时的当前日期(从Hive 1.2.0开始)。 同一查询中对current_date的所有调用均返回相同的值。

current_timestamp()
Returns the current timestamp at the start of query evaluation (as of Hive 1.2.0). All calls of current_timestamp within the same query return the same value.
返回查询评估开始时的当前时间戳(自Hive 1.2.0起)。 在同一查询中对current_timestamp的所有调用均返回相同的值。

datediff(STRING enddate, STRING startdate)
Returns the number of days from startdate to enddate: datediff('2009-03-01', '2009-02-27') = 2.
返回从开始日期到结束日期的天数:datediff('2009-03-01','2009-02-27')= 2。

date_add(DATE startdate, INT days)
Adds a number of days to startdate: date_add('2008-12-31', 1) = '2009-01-01'. T = pre 2.1.0: STRING, 2.1.0 on: DATE
添加开始日期的天数:date_add('2008-12-31',1)='2009-01-01'。 T = 2.1.0之前的版本:STRING,2.1.0,日期:DATE

date_format(DATE|TIMESTAMP|STRING ts, STRING fmt)
Converts a date/timestamp/string to a value of string in the format specified by the date format fmt (as of Hive 1.2.0). Supported formats are Java SimpleDateFormat formats – 
https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html. The second argument fmt should be constant. Example: date_format('2015-04-08', 'y') = '2015'.
将日期/时间戳记/字符串转换为日期格式fmt(从Hive 1.2.0开始)指定的格式的字符串值。 支持的格式是Java SimpleDateFormat格式–
https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html。 第二个参数fmt应该是常量。 示例:date_format('2015-04-08','y')='2015'。

date_sub(DATE startdate, INT days)
Subtracts a number of days to startdate: date_sub('2008-12-31', 1) = '2008-12-30'. T = pre 2.1.0: STRING, 2.1.0 on: DATE
减去开始日期的天数:date_sub('2008-12-31',1)='2008-12-30'。 T = 2.1.0之前的版本:STRING,2.1.0,日期:DATE

day(STRING date)
Returns the day part of a date or a timestamp string: day('1970-11-01 00:00:00') = 1, day('1970-11-01') = 1.
返回日期或时间戳字符串的日期部分:day('1970-11-01 00:00:00')= 1,day('1970-11-01')= 1。

dayofmonth(STRING date)
Returns the day part of a date or a timestamp string: dayofmonth('1970-11-01 00:00:00') = 1, dayofmonth('1970-11-01') = 1.
返回日期或时间戳字符串的日期部分:dayofmonth('1970-11-01 00:00:00')= 1,dayofmonth('1970-11-01')= 1。

extract(field FROM source)
Retrieve fields such as days or hours from source (as of Hive 2.2.0). Source must be a date, timestamp, interval or a string that can be converted into either a date or timestamp. Supported fields include: day, dayofweek, hour, minute, month, quarter, second, week and year.
从源中检索诸如天或小时之类的字段(自Hive 2.2.0起)。 源必须是日期,时间戳记,间隔或可以转换为日期或时间戳记的字符串。 支持的字段包括:日,星期几,小时,分钟,月,季度,秒,周和年。

from_unixtime(BIGINT unixtime [, STRING format])
Converts time string in format yyyy-MM-dd HH:mm:ss to Unix timestamp (in seconds), using the default timezone and the default locale, return 0 if fail: unix_timestamp('2009-03-20 11:30:01') = 1237573801
使用默认时区和默认语言环境将格式为yyyy-MM-dd HH:mm:ss的时间字符串转换为Unix时间戳(以秒为单位),如果失败则返回0:unix_timestamp('2009-03-20 11:30:01 ')= 1237573801

from_utc_timestamp(T a, STRING timezone)
Assumes given timestamp is UTC and converts to given timezone (as of Hive 0.8.0). For example, from_utc_timestamp('1970-01-01 08:00:00','PST') returns 1970-01-01 00:00:00
假定给定的时间戳为UTC并转换为给定的时区(从Hive 0.8.0开始)。 例如,from_utc_timestamp('1970-01-01 08:00:00','PST')返回1970-01-01 00:00:00

hour(STRING date)
Returns the hour of the timestamp: hour('2009-07-30 12:58:59') = 12, hour('12:58:59') = 12.
返回时间戳的小时:hour('2009-07-30 12:58:59')= 12,hour('12:58:59')= 12。

last_day(STRING date)
Returns the last day of the month which the date belongs to (as of Hive 1.1.0). date is a string in the format 'yyyy-MM-dd HH:mm:ss' or 'yyyy-MM-dd'. The time part of date is ignored.
返回日期所属月份的最后一天(从Hive 1.1.0开始)。 date是格式为“ yyyy-MM-dd HH:mm:ss”或“ yyyy-MM-dd”的字符串。 日期的时间部分将被忽略。

minute(STRING date)
Returns the minute of the timestamp.
返回时间戳的分钟。

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.
返回日期或时间戳字符串的月份部分:month('1970-11-01 00:00:00')= 11,month('1970-11-01')= 11。

months_between(DATE|TIMESTAMP|STRING date1, DATE|TIMESTAMP|STRING date2)
Returns number of months between dates date1 and date2 (as of Hive 1.2.0). If date1 is later than date2, then the result is positive. If date1 is earlier than date2, then the result is negative. If date1 and date2 are either the same days of the month or both last days of months, then the result is always an integer. Otherwise the UDF calculates the fractional portion of the result based on a 31-day month and considers the difference in time components date1 and date2. date1 and date2 type can be date, timestamp or string in the format 'yyyy-MM-dd' or 'yyyy-MM-dd HH:mm:ss'. The result is rounded to 8 decimal places. Example: months_between('1997-02-28 10:30:00', '1996-10-30') = 3.94959677
返回日期date1和date2之间的月份数(从Hive 1.2.0开始)。 如果date1晚于date2,则结果为正。 如果date1早于date2,则结果为负数。 如果date1和date2是月份的同一天或月份的最后几天,则结果始终是整数。 否则,UDF将基于31天的月份计算结果的小数部分,并考虑时间分量date1和date2的差异。 date1和date2类型可以是日期,时间戳或字符串,格式为“ yyyy-MM-dd”或“ yyyy-MM-dd HH:mm:ss”。 结果四舍五入到小数点后8位。 例如:months_between('1997-02-28 10:30:00','1996-10-30')= 3.94959677

next_day(STRING start_date, STRING day_of_week)
Returns the first date which is later than start_date and named as day_of_week (as of Hive 1.2.0). start_date is a string/date/timestamp. day_of_week is 2 letters, 3 letters or full name of the day of the week (e.g. Mo, tue, FRIDAY). The time part of start_date is ignored. Example: next_day('2015-01-14', 'TU') = 2015-01-20.
返回第一个日期,该日期晚于start_date并命名为day_of_week(从Hive 1.2.0开始)。 start_date是字符串/日期/时间戳。 day_of_week是2个字母,3个字母或一周中某天的全名(例如Mo,tue和FRIDAY)。 start_date的时间部分将被忽略。 例如:next_day('2015-01-14','TU')= 2015-01-20。

quarter(DATE|TIMESTAMP|STRING a)
Returns the quarter of the year for a date, timestamp, or string in the range 1 to 4. Example: quarter('2015-04-08') = 2.
返回日期,时间戳或字符串范围为1到4的一年的四分之一。例如:quarter('2015-04-08')= 2。

second(STRING date)
Returns the second of the timestamp.
返回时间戳的秒数。

to_date(STRING timestamp)
Returns the date part of a timestamp string, example to_date('1970-01-01 00:00:00'). T = pre 2.1.0: STRING 2.1.0 on: DATE
to_utc_timestamp(T a, STRING timezone)
Assumes given timestamp is in given timezone and converts to UTC (as of Hive 0.8.0). For example, to_utc_timestamp('1970-01-01 00:00:00','PST') returns 1970-01-01 08:00:00.
返回时间戳字符串的日期部分,例如to_date('1970-01-01 00:00:00')。 T = 2.1.0之前的版本:STRING 2.1.0,日期:DATE

trunc(STRING date, STRING format)
Returns date truncated to the unit specified by the format (as of Hive 1.2.0). Supported formats: MONTH/MON/MM, YEAR/YYYY/YY. Example: trunc('2015-03-17', 'MM') = 2015-03-01.
返回截断为格式指定单位的日期(从Hive 1.2.0开始)。 支持的格式:MONTH / MON / MM,YEAR / YYYY / YY。 示例:trunc('2015-03-17','MM')= 2015-03-01。

unix_timestamp([STRING date [, STRING pattern]])
Convert time string with given pattern to Unix time stamp (in seconds), return 0 if fail: unix_timestamp('2009-03-20', 'yyyy-MM-dd') = 1237532400.
将具有给定模式的时间字符串转换为Unix时间戳(以秒为单位),如果失败,则返回0:unix_timestamp('2009-03-20','yyyy-MM-dd')= 1237532400。

weekofyear(STRING date)
Returns the week number of a timestamp string: weekofyear('1970-11-01 00:00:00') = 44, weekofyear('1970-11-01') = 44.
返回时间戳字符串的星期数:weekofyear('1970-11-01 00:00:00')= 44,weekofyear('1970-11-01')= 44。

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
返回日期或时间戳字符串的年份部分:year('1970-01-01 00:00:00')= 1970,year('1970-01-01')= 1970

Mathematical

abs(DOUBLE a)
Returns the absolute value.
返回绝对值。

acos(DECIMAL|DOUBLE a)
Returns the arccosine of a if -1<=a<=1 or NULL otherwise.
如果-1 <= a <= 1,则返回a的反余弦,否则返回NULL。

asin(DECIMAL|DOUBLE a)
Returns the arc sin of a if -1<=a<=1 or NULL otherwise.
如果-1 <= a <= 1,则返回a的反正弦值,否则返回NULL。

atan(DECIMAL|DOUBLE a)
Returns the arctangent of a.
返回a的反正切值。

bin(BIGINT a)
Returns the number in binary format
以二进制格式返回数字

bround(DOUBLE a [, INT decimals])
Returns the rounded BIGINT value of a using HALF_EVEN rounding mode with optional decimal places d.
使用HALF_EVEN舍入模式返回a的舍入BIGINT值,并带有可选的小数位d。

cbft(DOUBLE a)
Returns the cube root of a double value.
返回双精度值的多维数据集根。

ceil(DOUBLE a)
Returns the minimum BIGINT value that is equal to or greater than a.
返回等于或大于a的最小BIGINT值。

ceiling(DOUBLE a)
Returns the minimum BIGINT value that is equal to or greater than a.
返回等于或大于a的最小BIGINT值。

conv(BIGINT|STRING a, INT from_base, INT to_base)
Converts a number from a given base to another
将数字从给定的基数转换为另一个

cos(DECIMAL|DOUBLE a)
Returns the cosine of a (a is in radians).
返回a的余弦(a以弧度表示)。

degrees(DECIMAL|DOUBLE a)
Converts value of a from radians to degrees.
将a的值从弧度转换为度。

e()
Returns the value of e.
返回e的值。

exp(DECIMAL|DOUBLE a)
Returns e^a where e is the base of the natural logarithm.
返回e ^ a,其中e是自然对数的底数。

factorial(INT a)
Returns the factorial of a. Valid a is [0..20].
返回a的阶乘。 有效a为[0..20]。

floor(DOUBLE a)
Returns the maximum BIGINT value that is equal to or less than a.
返回等于或小于a的最大BIGINT值。

greatest(T a1, T a2, ...)
Returns the greatest value of the list of values. Fixed to return NULL when one or more arguments are NULL, and strict type restriction relaxed, consistent with ">" operator.
返回值列表的最大值。 修复了当一个或多个参数为NULL并放宽严格类型限制(与“>”运算符一致)时返回NULL的问题。

hex(BIGINT|BINARY|STRING a)
If the argument is an INT or binary, hex returns the number as a STRING in hexadecimal format. Otherwise if the number is a STRING, it converts each character into its hexadecimal representation and returns the resulting STRING.
如果参数是INT或二进制,则十六进制以十六进制格式将数字作为STRING返回。 否则,如果数字为STRING,则它将每个字符转换为其十六进制表示形式,并返回结果STRING。

least(T a1, T a2, ...)
Returns the least value of the list of values. Fixed to return NULL when one or more arguments are NULL, and strict type restriction relaxed, consistent with "<" operator.
返回值列表中的最小值。 修复了当一个或多个参数为NULL并放宽严格类型限制(与“ <”运算符一致)时返回NULL的问题。

ln(DECIMAL|DOUBLE a)
Returns the natural logarithm of the argument a
返回参数a的自然对数

log(DECIMAL|DOUBLE base, DECIMAL|DOUBLE a)
Returns the base-base logarithm of the argument a.
返回参数a的基数对数。

log10(DECIMAL|DOUBLE a)
Returns the base-10 logarithm of the argument a.
返回参数a的以10为底的对数。

log2(DECIMAL|DOUBLE a)
Returns the base-2 logarithm of the argument a.
返回参数a的以2为底的对数。

negative(T<DOUBLE|INT> a)
Returns -a.
返回-a。

pi()
Returns the value of pi.
返回pi的值。

pmod(T<DOUBLE|INT> a, T b)
Returns the positive value of a mod b
返回mod b的正值

positive(T<DOUBLE|INT> a)
Returns a.
返回a。

pow(DOUBLE a, DOUBLE p)
Returns a^p
返回a ^ p

power(DOUBLE a, DOUBLE p)
Returns a^p
返回a ^ p

radians(DECIMAL|DOUBLE a)
Converts value of a from degrees to radians.
将a的值从度转换为弧度。

rand([INT seed])
Returns a random number (that changes from row to row) that is distributed uniformly from 0 to 1. Specifying the seed will make sure the generated random number sequence is deterministic.
返回从0到1均匀分布的随机数(逐行变化)。指定种子将确保所生成的随机数序列具有确定性。

round(DOUBLE a [, INT d])
Returns the rounded BIGINT value of a or a rounded to d decimal places.
返回a的四舍五入的BIGINT值或四舍五入到d的小数位。

shiftleft(T<BIGINT|INT|SMALLINT|TINYINT> a, INT b)
Bitwise left shift. Shifts a b positions to the left. Returns int for tinyint, smallint and int a. Returns bigint for bigint a.
按位左移。 将b位置向左移动。 为tinyint,smallint和int返回int。 为bigint a返回bigint。

shiftright(T<BIGINT|INT|SMALLINT|TINYINT> a, INT b)
Bitwise right shift. Shifts a b positions to the right. Returns int for tinyint, smallint and int a. Returns bigint for bigint a.
按位右移。 向右移动a b位置。 为tinyint,smallint和int返回int。 为bigint a返回bigint。

shiftrightunsigned(T<BIGINT|INT|SMALLINT|TINYINT> a, INT b)
Bitwise unsigned right shift. Shifts a b positions to the right. Returns int for tinyint, smallint and int a. Returns bigint for bigint a.
按位无符号右移。 向右移动a b位置。 为tinyint,smallint和int返回int。 为bigint a返回bigint。

sign(T<DOUBLE|INT> a)
Returns the sign of a as '1.0' (if a is positive) or '-1.0' (if a is negative), '0.0' otherwise. The decimal version returns INT instead of DOUBLE.
返回a的符号为“ 1.0”(如果a为正)或“ -1.0”(如果a为负),否则为“ 0.0”。 十进制版本返回INT而不是DOUBLE。

sin(DECIMAL|DOUBLE a)
Returns the sine of a (a is in radians).
返回a的正弦(a以弧度表示)。

sqrt(DECIMAL|DOUBLE a)
Returns the square root of a
返回a的平方根

tan(DECIMAL|DOUBLE a)
Returns the tangent of a (a is in radians).
返回a的切线(a以弧度表示)。

unhex(STRING a)
Inverse of hex. Interprets each pair of characters as a hexadecimal number and converts to the byte representation of the number.
十六进制的倒数。 将每对字符解释为十六进制数字,并转换为数字的字节表示形式。

width_bucket(NUMBER expr, NUMBER min_value, NUMBER max_value, INT num_buckets)
Returns an integer between 0 and num_buckets+1 by mapping expr into the ith equally sized bucket. Buckets are made by dividing [min_value, max_value] into equally sized regions. If expr < min_value, return 1, if expr > max_value return num_buckets+1. (as of Hive 3.0.0)
通过将expr映射到第i个大小相等的存储桶中,返回0到num_buckets + 1之间的整数。 通过将[min_value,max_value]划分为大小相等的区域来制作存储桶。 如果expr <min_value,则返回1,如果expr> max_value,则返回num_buckets + 1。 (自Hive 3.0.0起)       

Misc

aes_decrypt(BINARY input, STRING|BINARY key)
Decrypt input using AES (as of Hive 1.3.0). Key lengths of 128, 192 or 256 bits can be used. 192 and 256 bits keys can be used if Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files are installed. If either argument is NULL or the key length is not one of the permitted values, the return value is NULL. Example: aes_decrypt(unbase64('y6Ss+zCYObpCbgfWfyNWTw=='), '1234567890123456') = 'ABC'.
使用AES解密输入(自Hive 1.3.0起)。 可以使用128、192或256位的密钥长度。 如果安装了Java密码学扩展(JCE)无限强度管辖权策略文件,则可以使用192位和256位密钥。 如果任一参数为NULL或密钥长度不是允许的值之一,则返回值为NULL。 示例:aes_decrypt(unbase64('y6Ss + zCYObpCbgfWfyNWTw =='),'1234567890123456')='ABC'。

aes_encrypt(STRING|BINARY input, STRING|BINARY key)
Encrypt input using AES (as of Hive 1.3.0). Key lengths of 128, 192 or 256 bits can be used. 192 and 256 bits keys can be used if Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files are installed. If either argument is NULL or the key length is not one of the permitted values, the return value is NULL. Example: base64(aes_encrypt('ABC', '1234567890123456')) = 'y6Ss+zCYObpCbgfWfyNWTw=='.
使用AES加密输入(自Hive 1.3.0起)。 可以使用128、192或256位的密钥长度。 如果安装了Java密码学扩展(JCE)无限强度管辖权策略文件,则可以使用192位和256位密钥。 如果任一参数为NULL或密钥长度不是允许的值之一,则返回值为NULL。 示例:base64(aes_encrypt('ABC','1234567890123456'))='y6Ss + zCYObpCbgfWfyNWTw =='。

crc32(STRING|BINARY a)
Computes a cyclic redundancy check value for string or binary argument and returns bigint value (as of Hive 1.3.0). Example: crc32('ABC') = 2743272264.
计算字符串或二进制参数的循环冗余校验值,并返回bigint值(从Hive 1.3.0开始)。 例如:crc32('ABC')= 2743272264。

current_database()
Returns current database name (as of Hive 0.13.0).
返回当前数据库名称(从Hive 0.13.0开始)。

current_user()
Returns current user name (as of Hive 1.2.0).
返回当前用户名(从Hive 1.2.0开始)。

get_json_object(STRING json, STRING jsonPath)
A limited version of JSONPath is supported ($ : Root object, . : Child operator, [] : Subscript operator for array, * : Wildcard for []
支持JSONPath的受限版本($:根对象,。:子运算符,[]:数组的下标运算符,*:[]的通配符

hash(a1[, a2...])
Returns a hash value of the arguments. (As of Hive 0.4.)
返回参数的哈希值。 (从Hive 0.4开始。)

java_method(class, method[, arg1[, arg2..]])
Calls a Java method by matching the argument signature, using reflection. (As of Hive 0.9.0.)
通过使用反射匹配参数签名来调用Java方法。 (从Hive 0.9.0开始。)

logged_in_user()
Returns current user name from the session state (as of Hive 2.2.0). This is the username provided when connecting to Hive.
从会话状态返回当前的用户名(从Hive 2.2.0开始)。 这是连接到Hive时提供的用户名。

md5(STRING|BINARY a)
Calculates an MD5 128-bit checksum for the string or binary (as of Hive 1.3.0). The value is returned as a string of 32 hex digits, or NULL if the argument was NULL. Example: md5('ABC') = '902fbdd2b1df0c4f70b4a5d23525e932'.
计算字符串或二进制文件的MD5 128位校验和(从Hive 1.3.0开始)。 该值以32个十六进制数字的字符串形式返回,如果参数为NULL,则返回NULL。 例如:md5('ABC')='902fbdd2b1df0c4f70b4a5d23525e932'。

reflect(class, method[, arg1[, arg2..]])
Calls a Java method by matching the argument signature, using reflection. (As of Hive 0.7.0.)
通过使用反射匹配参数签名来调用Java方法。 (从Hive 0.7.0开始。)

sha(STRING|BINARY a)
Calculates the SHA-1 digest for string or binary and returns the value as a hex string (as of Hive 1.3.0). Example: sha1('ABC') = '3c01bdbb26f358bab27f267924aa2c9a03fcfdb8'.
计算字符串或二进制文件的SHA-1摘要,并以十六进制字符串形式返回值(从Hive 1.3.0开始)。 例如:sha1('ABC')='3c01bdbb26f358bab27f267924aa2c9a03fcfdb8'。

sha1(STRING|BINARY a)
Calculates the SHA-1 digest for string or binary and returns the value as a hex string (as of Hive 1.3.0). Example: sha1('ABC') = '3c01bdbb26f358bab27f267924aa2c9a03fcfdb8'.
计算字符串或二进制文件的SHA-1摘要,并以十六进制字符串形式返回值(从Hive 1.3.0开始)。 例如:sha1('ABC')='3c01bdbb26f358bab27f267924aa2c9a03fcfdb8'。

sha2(STRING|BINARY a, INT b)
Calculates the SHA-2 family of hash functions (SHA-224, SHA-256, SHA-384, and SHA-512) (as of Hive 1.3.0). The first argument is the string or binary to be hashed. The second argument indicates the desired bit length of the result, which must have a value of 224, 256, 384, 512, or 0 (which is equivalent to 256). SHA-224 is supported starting from Java 8. If either argument is NULL or the hash length is not one of the permitted values, the return value is NULL. Example: sha2('ABC', 256) = 'b5d4045c3f466fa91fe2cc6abe79232a1a57cdf104f7a26e716e0a1e2789df78'.
计算SHA-2系列哈希函数(SHA-224,SHA-256,SHA-384和SHA-512)(从Hive 1.3.0开始)。 第一个参数是要哈希的字符串或二进制。 第二个参数表示结果的所需位长,该位的长度必须为224、256、384、512或0(等于256)。 从Java 8开始支持SHA-224。如果任一参数为NULL或哈希长度不是允许的值之一,则返回值为NULL。 例如:sha2('ABC',256)='b5d4045c3f466fa91fe2cc6abe79232a1a57cdf104f7a26e716e0a1e2789df78'。

version()
Returns the Hive version (as of Hive 2.1.0). The string contains 2 fields, the first being a build number and the second being a build hash. Example: "select version();" might return "2.1.0.2.5.0.0-1245 r027527b9c5ce1a3d7d0b6d2e6de2378fb0c39232". Actual results will depend on your build.
返回Hive版本(从Hive 2.1.0开始)。 该字符串包含2个字段,第一个是内部版本号,第二个是内部散列。 示例:“ select version();” 可能会返回“ 2.1.0.2.5.0.0-1245 r027527b9c5ce1a3d7d0b6d2e6de2378fb0c39232”。 实际结果将取决于您的构建。

array<STRING> xpath(STRING xml, STRING xpath)
The xpath family of UDFs are wrappers around the Java XPath library javax.xml.xpath provided by the JDK. The library is based on the XPath 1.0 specification.
UDF的xpath家族是JDK提供的Java XPath库javax.xml.xpath的包装。 该库基于XPath 1.0规范。

xpath_boolean(STRING xml, STRING xpath)
The xpath family of UDFs are wrappers around the Java XPath library javax.xml.xpath provided by the JDK. The library is based on the XPath 1.0 specification.
UDF的xpath家族是JDK提供的Java XPath库javax.xml.xpath的包装。 该库基于XPath 1.0规范。

xpath_double(STRING xml, STRING xpath)
The xpath family of UDFs are wrappers around the Java XPath library javax.xml.xpath provided by the JDK. The library is based on the XPath 1.0 specification.
UDF的xpath家族是JDK提供的Java XPath库javax.xml.xpath的包装。 该库基于XPath 1.0规范。

xpath_float(STRING xml, STRING xpath)
The xpath family of UDFs are wrappers around the Java XPath library javax.xml.xpath provided by the JDK. The library is based on the XPath 1.0 specification.
UDF的xpath家族是JDK提供的Java XPath库javax.xml.xpath的包装。 该库基于XPath 1.0规范。

xpath_int(STRING xml, STRING xpath)
The xpath family of UDFs are wrappers around the Java XPath library javax.xml.xpath provided by the JDK. The library is based on the XPath 1.0 specification.
UDF的xpath家族是JDK提供的Java XPath库javax.xml.xpath的包装。 该库基于XPath 1.0规范。

xpath_long(STRING xml, STRING xpath)
The xpath family of UDFs are wrappers around the Java XPath library javax.xml.xpath provided by the JDK. The library is based on the XPath 1.0 specification.
UDF的xpath家族是JDK提供的Java XPath库javax.xml.xpath的包装。 该库基于XPath 1.0规范。

xpath_number(STRING xml, STRING xpath)
The xpath family of UDFs are wrappers around the Java XPath library javax.xml.xpath provided by the JDK. The library is based on the XPath 1.0 specification.
UDF的xpath家族是JDK提供的Java XPath库javax.xml.xpath的包装。 该库基于XPath 1.0规范。

xpath_short(STRING xml, STRING xpath)
The xpath family of UDFs are wrappers around the Java XPath library javax.xml.xpath provided by the JDK. The library is based on the XPath 1.0 specification.
UDF的xpath家族是JDK提供的Java XPath库javax.xml.xpath的包装。 该库基于XPath 1.0规范。

xpath_string(STRING xml, STRING xpath)
The xpath family of UDFs are wrappers around the Java XPath library javax.xml.xpath provided by the JDK. The library is based on the XPath 1.0 specification.
UDF的xpath家族是JDK提供的Java XPath库javax.xml.xpath的包装。 该库基于XPath 1.0规范。

String

ascii(STRING str)
Returns the numeric value of the first character of str.
返回str的第一个字符的数值。

base64(BINARY bin)
Converts the argument from binary to a base 64 string (as of Hive 0.12.0).
将参数从二进制转换为基本64字符串(从Hive 0.12.0开始)。

chr(BIGINT|DOUBLE a)
Returns the ASCII character having the binary equivalent to a (as of Hive 1.3.0 and 2.1.0). If a is larger than 256 the result is equivalent to chr(a % 256). Example: select chr(88); returns "X".
返回与a等效的ASCII字符(从Hive 1.3.0和2.1.0开始)。 如果a大于256,则结果等于chr(a%256)。 示例:选择chr(88); 返回“ X”。

char_length(STRING a)
Returns the number of UTF-8 characters contained in str (as of Hive 2.2.0). This is shorthand for character_length.
返回str中包含的UTF-8字符数(从Hive 2.2.0开始)。 这是character_length的简写。
character_length(STRING a)

Returns the number of UTF-8 characters contained in str (as of Hive 2.2.0). The function char_length is shorthand for this function.
返回str中包含的UTF-8字符数(从Hive 2.2.0开始)。 函数char_length是该函数的简写。

concat(STRING|BINARY a, STRING|BINARY b...)
Returns the string or bytes resulting from concatenating the strings or bytes passed in as parameters in order. For example, concat('foo', 'bar') results in 'foobar'. Note that this function can take any number of input strings.
返回按顺序串联作为参数传入的字符串或字节所得到的字符串。 例如,concat('foo','bar')的结果为'foobar'。 请注意,此函数可以接受任意数量的输入字符串。

concat_ws(STRING sep, STRING a, STRING b...), concat_ws(STRING sep, Array<STRING>)
Like concat(), but with custom separator SEP.
与concat()类似,但具有自定义分隔符SEP。

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".
给定字符串“ context”,从一组标记化语句返回前k个上下文N-gram。

decode(BINARY bin, STRING charset)
Decodes the first argument into a String using the provided character set (one of 'US-ASCII', 'ISO-8859-1', 'UTF-8', 'UTF-16BE', 'UTF-16LE', 'UTF-16'). If either argument is null, the result will also be null. (As of Hive 0.12.0.)
使用提供的字符集(“ US-ASCII”,“ ISO-8859-1”,“ UTF-8”,“ UTF-16BE”,“ UTF-16LE”,“ UTF- 16')。 如果任一参数为null,则结果也将为null。 (从Hive 0.12.0开始。)

elt(INT n, STRING str, STRING str1, ...])
Return string at index number. For example elt(2,'hello','world') returns 'world'. Returns NULL if N is less than 1 or greater than the number of arguments.
返回索引号处的字符串。 例如elt(2,'hello','world')返回'world'。 如果N小于1或大于参数个数,则返回NULL。

encode(STRING src, STRING charset)
Encodes the first argument into a BINARY using the provided character set (one of 'US-ASCII', 'ISO-8859-1', 'UTF-8', 'UTF-16BE', 'UTF-16LE', 'UTF-16'). If either argument is null, the result will also be null. (As of Hive 0.12.0.)
使用提供的字符集(“ US-ASCII”,“ ISO-8859-1”,“ UTF-8”,“ UTF-16BE”,“ UTF-16LE”,“ UTF- 16')。 如果任一参数为null,则结果也将为null。 (从Hive 0.12.0开始。)

field(T val, T val1, ...])
Returns the index of val in the val1,val2,val3,... list or 0 if not found. For example field('world','say','hello','world') returns 3. All primitive types are supported, arguments are compared using str.equals(x). If val is NULL, the return value is 0.
返回val1,val2,val3,...列表中val的索引;如果未找到,则返回0。 例如field('world','say','hello','world')返回3。支持所有原始类型,使用str.equals(x)比较参数。 如果val为NULL,则返回值为0。

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. For example, find_in_set('ab', 'abc,b,ab,c,def') returns 3.
返回str在strList中第一次出现的地方,其中strList是逗号分隔的字符串。 如果任一参数为null,则返回null。 如果第一个参数包含逗号,则返回0。 例如,find_in_set('ab','abc,b,ab,c,def')返回3。

format_number(NUMBER x, INT d)
Formats the number X to a format like '#,###,###.##', rounded to D decimal places, and returns the result as a string. If D is 0, the result has no decimal point or fractional part. (As of Hive 0.10.0; bug with float types fixed in Hive 0.14.0, decimal type support added in Hive 0.14.0)
将数字X格式化为'#,###,###。##'之类的格式,四舍五入到小数点后D位,然后将结果作为字符串返回。 如果D为0,则结果没有小数点或小数部分。 (从Hive 0.10.0开始;在Hive 0.14.0中修复了浮点类型的错误,在Hive 0.14.0中添加了小数类型支持)

get_json_object(STRING json_string, STRING path)
Extracts json object from a json string based on json path specified, and returns 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.
根据指定的json路径从json字符串中提取json对象,并返回提取的json对象的json字符串。 如果输入的json字符串无效,它将返回null。 注意:json路径只能包含字符[0-9a-z_],即不能包含大写或特殊字符。 另外,键*不能以数字开头。*这是由于对Hive列名的限制。

initcap(STRING a)
Returns string, with the first letter of each word in uppercase, all other letters in lowercase. Words are delimited by whitespace. (As of Hive 1.1.0.)
返回字符串,每个单词的首字母大写,所有其他字母小写。 单词由空格分隔。 (从Hive 1.1.0开始。)

instr(STRING str, STRING substr)
Returns the position of the first occurrence of substr in str. Returns null if either of the arguments are null and returns 0 if substr could not be found in str. Be aware that this is not zero based. The first character in str has index 1.
返回substr在str中第一次出现的位置。 如果其中一个参数为null,则返回null;如果在str中找不到substr,则返回0。 请注意,这不是基于零的。 str中的第一个字符的索引为1。

in_file(STRING str, STRING filename)
Returns true if the string str appears as an entire line in filename.
如果字符串str在文件名中显示为整行,则返回true。

length(STRING a)
Returns the length of the string.
返回字符串的长度。

levenshtein(STRING a, STRING b)
Returns the Levenshtein distance between two strings (as of Hive 1.2.0). For example, levenshtein('kitten', 'sitting') results in 3.
返回两个字符串之间的Levenshtein距离(从Hive 1.2.0开始)。 例如,levenshtein('kitten','sitting')得出3。

lcase(STRING a)
Returns the string resulting from converting all characters of B to lower case. For example, lcase('fOoBaR') results in 'foobar'.
返回将B的所有字符都转换为小写形式的字符串。 例如,lcase('fOoBaR')结果为'foobar'。

locate(STRING substr, STRING str [, INT pos])
Returns the position of the first occurrence of substr in str after position pos.
返回在位置pos之后的str中第一次出现substr的位置。

lower(STRING a)
Returns the string resulting from converting all characters of B to lower case. For example, lower('fOoBaR') results in 'foobar'.
返回将B的所有字符都转换为小写形式的字符串。 例如,lower('fOoBaR')的结果为'foobar'。

lpad(STRING str, INT len, STRING pad)
Returns str, left-padded with pad to a length of len.
返回str,左填充pad长度为len。

ltrim(STRING a)
Returns the string resulting from trimming spaces from the beginning(left hand side) of A. For example, ltrim(' foobar ') results in 'foobar '.
返回从A的开头(左侧)起修剪空格所得的字符串。例如,ltrim('foobar')的结果为'foobar'。

array<struct<STRING, DOUBLE>> ngrams(Array<Array<STRING>> a, 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.
从一组标记化的句子中返回前k个N-gram,例如句子()UDAF返回的句子。

octet_length(STRING a)
Returns the number of octets required to hold the string str in UTF-8 encoding (since Hive 2.2.0). Note that octet_length(str) can be larger than character_length(str).
返回以UTF-8编码保存字符串str所需的八位字节数(自Hive 2.2.0起)。 请注意,octet_length(str)可以大于character_length(str)。

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. For example, 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, for example, parse_url('http://facebook.com/path1/p.php?k1=v1&k2=v2#Ref1', 'QUERY', 'k1') returns 'v1'.
从URL返回指定的部分。 partToExtract的有效值包括HOST,PATH,QUERY,REF,PROTOCOL,AUTHORITY,FILE和USERINFO。 例如,parse_url('http://facebook.com/path1/p.php?k1=v1&k2=v2#Ref1','HOST')返回'facebook.com'。 通过将键作为第三个参数,也可以提取QUERY中特定键的值,例如parse_url('http://facebook.com/path1/p.php?k1=v1&k2=v2#Ref1', 'QUERY','k1')返回'v1'。

printf(STRING format, Obj... args)
Returns the input formatted according do printf-style format strings (as of Hive 0.9.0).
返回根据do printf样式格式字符串格式化的输入(从Hive 0.9.0开始)。
regexp_extract(STRING subject, STRING pattern, INT index)
Returns the string extracted using the pattern. For example, 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; '\\s' is necessary to match whitespace, etc. The 'index' parameter is the Java regex Matcher group() method index.
返回使用模式提取的字符串。 例如,regexp_extract('foothebar','foo(。*?)(bar)',2)返回'bar'。 请注意,使用预定义的字符类时必须格外小心:使用'\ s'作为第二个参数将与字母s匹配; '\\ s'是匹配空格等所必需的。'index'参数是Java regex Matcher group()方法的索引。

regexp_replace(STRING initial_string, STRING pattern, STRING replacement)
Returns the string resulting from replacing all substrings in INITIAL_STRING that match the java regular expression syntax defined in PATTERN with instances of REPLACEMENT. For example, 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; '\\s' is necessary to match whitespace, etc.
返回通过将INITIAL_STRING中所有与PATTERN中定义的Java正则表达式语法匹配的子字符串替换为REPLACEMENT的实例所产生的字符串。 例如,regexp_replace(“ foobar”,“ oo | ar”,“”)返回'fb'。 请注意,使用预定义的字符类时必须格外小心:使用'\ s'作为第二个参数将与字母s匹配; '\\ s'是匹配空格等所必需的。

repeat(STRING str, INT n)
Repeats str n times.
重复str n次。

replace(STRING a, STRING old, STRING new)
Returns the string a with all non-overlapping occurrences of old replaced with new (as of Hive 1.3.0 and 2.1.0). Example: select replace("ababab", "abab", "Z"); returns "Zab".
返回字符串a,其中所有不重复出现的旧替换为new(从Hive 1.3.0和2.1.0开始)。 示例:选择replace(“ ababab”,“ abab”,“ Z”); 返回“ Zab”。

reverse(STRING a)
Returns the reversed string.
返回反转的字符串。

rpad(STRING str, INT len, STRING pad)
Returns str, right-padded with pad to a length of len.
返回str,右用pad填充到len的长度。

rtrim(STRING a)
Returns the string resulting from trimming spaces from the end(right hand side) of A. For example, rtrim(' foobar ') results in ' foobar'.
返回从A的结尾(右侧)修剪空格所得到的字符串。例如,rtrim('foobar')结果为'foobar'。

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. For example, sentences('Hello there! How are you?') returns ( ("Hello", "there"), ("How", "are", "you") ).
将一串自然语言文本标记为单词和句子,其中每个句子在适当的句子边界处断开并作为单词数组返回。 “ lang”和“ locale”是可选参数。 例如,句子(“ Hello there!您好吗?”)返回((“ Hello”,“ there”),(“ How”,“ are”,“ you”)))。

soundex(STRING a)
Returns soundex code of the string (as of Hive 1.2.0). For example, soundex('Miller') results in M460.
返回字符串的soundex代码(从Hive 1.2.0开始)。 例如,soundex('Miller')生成M460。

space(INT n)
Returns a string of n spaces.
返回n个空格的字符串。

array<STRING> split(STRING str, STRING pat)
Splits str around pat (pat is a regular expression).
在pat周围拆分str(pat是一个正则表达式)。

map<STRING,STRING> str_to_map(STRING [, STRING delimiter1, STRING delimiter2])
Splits text into key-value pairs using two delimiters. Delimiter1 separates text into K-V pairs, and Delimiter2 splits each K-V pair. Default delimiters are ',' for delimiter1 and '=' for delimiter2.
使用两个定界符将文本分成键值对。 Delimiter1将文本分成K-V对,Delimiter2将每个K-V对分开。 默认分隔符为','(对于分隔符1)和'='(对于分隔符2)。

substr(STRING|BINARY A, INT start [, INT len])
Returns the substring or slice of the byte array of A starting from start position till the end of string A or with optional length len. For example, substr('foobar', 4) results in 'bar'
返回A的字节数组的子字符串或分片,该字符串从字符串的起始位置开始直到字符串A的末尾或长度为len。 例如,substr('foobar',4)的结果为'bar'

substring(STRING|BINARY a, INT start [, INT len])
Returns the substring or slice of the byte array of A starting from start position till the end of string A or with optional length len. For example, substr('foobar', 4) results in 'bar'
返回A的字节数组的子字符串或分片,该字符串从字符串的起始位置开始直到字符串A的末尾或长度为len。 例如,substr('foobar',4)的结果为'bar'

substring_index(STRING a, STRING delim, INT count)
Returns the substring from string A before count occurrences of the delimiter delim (as of Hive 1.3.0). If count is positive, everything to the left of the final delimiter (counting from the left) is returned. If count is negative, everything to the right of the final delimiter (counting from the right) is returned. Substring_index performs a case-sensitive match when searching for delim. Example: substring_index('www.apache.org', '.', 2) = 'www.apache'.
translate(STRING|CHAR|VARCHAR input, STRING|CHAR|VARCHAR from, STRING|CHAR|VARCHAR to)
Translates the input string by replacing the characters present in the from string with the corresponding characters in the to string. This is similar to the translate function in PostgreSQL. If any of the parameters to this UDF are NULL, the result is NULL as well. (Available as of Hive 0.10.0, for string types) Char/varchar support added as of Hive 0.14.0.
在计数出现定界符delim(从Hive 1.3.0开始)之前,从字符串A返回子字符串。 如果count为正,则返回最后定界符左侧的所有内容(从左侧开始计数)。 如果count为负,则返回最后定界符右边的所有内容(从右边开始计数)。 搜索delim时,Substring_index执行区分大小写的匹配。 例如:substring_index('www.apache.org','。',2)='www.apache'。
转换(STRING | CHAR | VARCHAR输入,STRING | CHAR | VARCHAR从,STRING | CHAR | VARCHAR到)
通过将from字符串中存在的字符替换为to字符串中的相应字符来翻译输入字符串。 这类似于PostgreSQL中的翻译功能。 如果此UDF的任何参数为NULL,则结果也为NULL。 (自Hive 0.10.0起,适用于字符串类型)自Hive 0.14.0起增加了对Char / varchar的支持。

trim(STRING a)
Returns the string resulting from trimming spaces from both ends of A. For example, trim(' foobar ') results in 'foobar'
返回由A两端的空格修剪产生的字符串。例如,trim('foobar')结果为'foobar'

ucase(STRING a)
Returns the string resulting from converting all characters of A to upper case. For example, ucase('fOoBaR') results in 'FOOBAR'.
返回将A的所有字符都转换为大写形式的字符串。 例如,ucase('fOoBaR')的结果为'FOOBAR'。

unbase64(STRING a)
Converts the argument from a base 64 string to BINARY. (As of Hive 0.12.0.)
将参数从基数为64的字符串转换为BINARY。 (从Hive 0.12.0开始。)

upper(STRING a)
Returns the string resulting from converting all characters of A to upper case. For example, upper('fOoBaR') results in 'FOOBAR'.
返回将A的所有字符都转换为大写形式的字符串。 例如,upper('fOoBaR')的结果为'FOOBAR'。

Data Masking

mask(STRING str [, STRING upper [, STRING lower [, STRING number]]])
Returns a masked version of str (as of Hive 2.1.0). By default, upper case letters are converted to "X", lower case letters are converted to "x" and numbers are converted to "n". For example mask("abcd-EFGH-8765-4321") results in xxxx-XXXX-nnnn-nnnn. You can override the characters used in the mask by supplying additional arguments: the second argument controls the mask character for upper case letters, the third argument for lower case letters and the fourth argument for numbers. For example, mask("abcd-EFGH-8765-4321", "U", "l", "#") results in llll-UUUU-####-####.
返回str的掩码版本(从Hive 2.1.0开始)。 默认情况下,大写字母转换为“ X”,小写字母转换为“ x”,数字转换为“ n”。 例如mask(“ abcd-EFGH-8765-4321”)的结果为xxxx-XXXX-nnnn-nnnn。 您可以通过提供其他参数来覆盖掩码中使用的字符:第二个参数控制大写字母的掩码字符,第三个参数控制小写字母的字符,第四个参数控制数字的字符。 例如,mask(“ abcd-EFGH-8765-4321”,“ U”,“ l”,“#”)生成llll-UUUU-####-####。

mask_first_n(STRING str [, INT n])
Returns a masked version of str with the first n values masked (as of Hive 2.1.0). Upper case letters are converted to "X", lower case letters are converted to "x" and numbers are converted to "n". For example, mask_first_n("1234-5678-8765-4321", 4) results in nnnn-5678-8765-4321.
返回带掩码的str的版本,其中前n个值被掩码(从Hive 2.1.0开始)。 大写字母转换为“ X”,小写字母转换为“ x”,数字转换为“ n”。 例如,mask_first_n(“ 1234-5678-8765-4321”,4)生成nnnn-5678-8765-4321。

mask_last_n(STRING str [, INT n])
Returns a masked version of str with the last n values masked (as of Hive 2.1.0). Upper case letters are converted to "X", lower case letters are converted to "x" and numbers are converted to "n". For example, mask_last_n("1234-5678-8765-4321", 4) results in 1234-5678-8765-nnnn.
返回带有掩码的最后一个n值的str的掩码版本(从Hive 2.1.0开始)。 大写字母转换为“ X”,小写字母转换为“ x”,数字转换为“ n”。 例如,mask_last_n(“ 1234-5678-8765-4321”,4)生成1234-5678-8765-nnnn。

mask_show_first_n(STRING str [, INT n])
Returns a masked version of str, showing the first n characters unmasked (as of Hive 2.1.0). Upper case letters are converted to "X", lower case letters are converted to "x" and numbers are converted to "n". For example, mask_show_first_n("1234-5678-8765-4321", 4) results in 1234-nnnn-nnnn-nnnn.
返回带掩码的str版本,显示未掩码的前n个字符(从Hive 2.1.0开始)。 大写字母转换为“ X”,小写字母转换为“ x”,数字转换为“ n”。 例如,mask_show_first_n(“ 1234-5678-8765-4321”,4)的结果为1234-nnnn-nnnn-nnnn。

mask_show_last_n(STRING str [, INT n])
Returns a masked version of str, showing the last n characters unmasked (as of Hive 2.1.0). Upper case letters are converted to "X", lower case letters are converted to "x" and numbers are converted to "n". For example, mask_show_last_n("1234-5678-8765-4321", 4) results in nnnn-nnnn-nnnn-4321.
返回带掩码的str版本,显示未掩码的最后n个字符(从Hive 2.1.0开始)。 大写字母转换为“ X”,小写字母转换为“ x”,数字转换为“ n”。 例如,mask_show_last_n(“ 1234-5678-8765-4321”,4)的结果为nnnn-nnnn-nnnn-4321。

mask_hash(STRING|CHAR|VARCHAR str)
Returns a hashed value based on str (as of Hive 2.1.0). The hash is consistent and can be used to join masked values together across tables. This function returns null for non-string types.
返回基于str的哈希值(从Hive 2.1.0开始)。 哈希是一致的,可用于将跨表的掩码值连接在一起。 对于非字符串类型,此函数返回null。

Table Generating

explode(Array|Array<T>|Map a)
无

inline(Array<Struct [, Struct]> a)
Explodes an array of structs into a table. (As of Hive 0.10.)
将结构数组分解为表。 (从Hive 0.10开始。)

json_tuple(STRING jsonStr, STRING k1, STRING k2, ...)
A new json_tuple() UDTF is introduced in Hive 0.7. It takes a set of names (keys) and a JSON string, and returns a tuple of values using one function. This is much more efficient than calling GET_JSON_OBJECT to retrieve more than one key from a single JSON string.
Hive 0.7中引入了新的json_tuple()UDTF。 它使用一组名称(键)和一个JSON字符串,并使用一个函数返回一个值的元组。 这比调用GET_JSON_OBJECT从单个JSON字符串中检索多个密钥要有效得多。

parse_url_tuple(STRING url, STRING p1, STRING p2, ...)
The parse_url_tuple() UDTF is similar to parse_url(), but can extract multiple parts of a given URL, returning the data in a tuple. Values for a particular key in QUERY can be extracted by appending a colon and the key to the partToExtract argument.
parse_url_tuple()UDTF与parse_url()类似,但是可以提取给定URL的多个部分,以元组形式返回数据。 可以通过将冒号和键附加到partToExtract参数中来提取QUERY中特定键的值。

posexplode(ARRAY)
posexplode() is similar to explode but instead of just returning the elements of the array it returns the element as well as its position in the original array.
posexplode()与explode类似,但它不仅返回数组的元素,还返回元素及其在原始数组中的位置。

stack(INT n, v1, v2, ..., vk)
Breaks up v1, v2, ..., vk into n rows. Each row will have k/n columns. n must be constant.
将v1,v2,...,vk分成n行。 每行将有k / n列。 n必须是常数。

Type Conversion

binary(BINARY|STRING a)
Casts the parameter into a binary.
将参数转换为二进制。

cast(a as T)
Converts the results of the expression expr to type T. For example, cast('1' as BIGINT) will convert the string '1' to its integral representation. A null is returned if the conversion does not succeed. If cast(expr as boolean) Hive returns true for a non-empty string.
将表达式expr的结果转换为T类型。例如,cast('1'as BIGINT)将字符串'1'转换为其整数表示。 如果转换不成功,则返回null。 如果cast(expr为boolean),则Hive对于非空字符串返回true。
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值