!
! expr -逻辑非
.
%
expr1 % expr2 -在expr1/expr2之后返回剩余的部分.
Examples:
-
> SELECT 2 % 1.8;
-
0.2
-
> SELECT MOD(2, 1.8);
-
0.2
&
expr1 & expr2 - 返回和expr1和expr2的结果.
Examples:
-
> SELECT 3 & 5;
-
1
*
expr1 * expr2 - Returns expr1
*expr2
.
Examples:
-
> SELECT 2 * 3;
-
6
+
expr1 + expr2 - Returns expr1
+expr2
.
Examples:
-
> SELECT 1 + 2;
-
3
-
expr1 - expr2 - Returns expr1
-expr2
.
Examples:
-
> SELECT 2 - 1;
-
1
/
expr1/expr2返回expr1/expr2。它总是执行浮点分。
Examples:
-
> SELECT 3 / 2;
-
1.5
-
> SELECT 2L / 2L;
-
1.0
<
expr1 < expr2 - 如果expr1小于expr2,则返回true。.
Arguments:
- expr1, expr2 - 这两个表达式必须是相同类型的,或者可以被一个普通类型的类型所使用,并且必须是一个可以被排序的类型。例如,映射类型不是可排序的,因此它不受支持。对于复杂类型的数组/结构体,字段的数据类型必须是可排序的.
Examples:
-
> SELECT 1 < 2;
-
true
-
> SELECT 1.1 < '1';
-
false
-
> SELECT to_date('2009-07-30 04:17:52') < to_date('2009-07-30 04:17:52');
-
false
-
> SELECT to_date('2009-07-30 04:17:52') < to_date('2009-08-01 04:17:52');
-
true
-
> SELECT 1 < NULL;
-
NULL
<=
expr1 <= expr2 - 如果expr1小于或等于expr2,则返回true.
Examples:
-
> SELECT 2 <= 2;
-
true
-
> SELECT 1.0 <= '1';
-
true
-
> SELECT to_date('2009-07-30 04:17:52') <= to_date('2009-07-30 04:17:52');
-
true
-
> SELECT to_date('2009-07-30 04:17:52') <= to_date('2009-08-01 04:17:52');
-
true
-
> SELECT 1 <= NULL;
-
NULL
<=>
expr1 <=> expr2 - 返回与非空操作数相等的(=)操作符相同的结果,但如果两者都是null,则返回true,如果其中一个为null,则返回false.
Examples:
-
> SELECT 2 <=> 2;
-
true
-
> SELECT 1 <=> '1';
-
true
-
> SELECT true <=> NULL;
-
false
-
> SELECT NULL <=> NULL;
-
true
=
expr1 = expr2 - 如果expr1等于expr2,则返回true,否则将返回false。
Examples:
-
> SELECT 2 = 2;
-
true
-
> SELECT 1 = '1';
-
true
-
> SELECT true = NULL;
-
NULL
-
> SELECT NULL = NULL;
-
NULL
==
expr1 == expr2 - 如果expr1等于expr2,则返回true,否则返回false.
Examples:
-
> SELECT 2 == 2;
-
true
-
> SELECT 1 == '1';
-
true
-
> SELECT true == NULL;
-
NULL
-
> SELECT NULL == NULL;
-
NULL
>
expr1 > expr2 - 如果expr1大于expr2,则返回true。
Examples:
-
> SELECT 2 > 1;
-
true
-
> SELECT 2 > '1.1';
-
true
-
> SELECT to_date('2009-07-30 04:17:52') > to_date('2009-07-30 04:17:52');
-
false
-
> SELECT to_date('2009-07-30 04:17:52') > to_date('2009-08-01 04:17:52');
-
false
-
> SELECT 1 > NULL;
-
NULL
>=
expr1 >= expr2 - 如果expr1大于或等于expr2,则返回true.
Examples:
-
> SELECT 2 >= 1;
-
true
-
> SELECT 2.0 >= '2.1';
-
false
-
> SELECT to_date('2009-07-30 04:17:52') >= to_date('2009-07-30 04:17:52');
-
true
-
> SELECT to_date('2009-07-30 04:17:52') >= to_date('2009-08-01 04:17:52');
-
false
-
> SELECT 1 >= NULL;
-
NULL
^
expr1 ^ expr2 -返回位或expr1或expr2的结果.
Examples:
-
> SELECT 3 ^ 5;
-
2
abs
abs(expr) - 返回数值的绝对值.
Examples:
-
> SELECT abs(-1);
-
1
acos
acos(expr) -如果-1小于=expr=1或NaN,则返回expr的反余弦(又称arccos).
Examples:
-
> SELECT acos(1);
-
0.0
-
> SELECT acos(2);
-
NaN
add_months
add_months(start_date, num_months) -返回开始日期后的num数月的日期.
Examples:
-
> SELECT add_months('2016-08-31', 1);
-
2016-09-30
Since: 1.5.0
and
expr1 and expr2 - 逻辑与.
approx_count_distinct
approx_count_distinct(expr[, relativeSD]) - 通过HyperLogLog++返回估计的基数。相对维定义了允许的最大估计误差
approx_percentile
approx_percentile(col, percentage [, accuracy]) - 根据给定百分比返回数值列的近似百分比值。百分比的值必须在0.0和1.0之间。精度参数(默认值:10000)是一个正数值,它控制着近似精度,在内存中。较高的精度能产生更好的精度,1.0/精度是近似的相对误差。当百分比是一个数组时,百分比数组的每个值必须在0.0和1.0之间。在本例中,返回给定百分比数组中列的大约百分比数组。
Examples:
-
> SELECT approx_percentile(10.0, array(0.5, 0.4, 0.1), 100);
-
[10.0,10.0,10.0]
-
> SELECT approx_percentile(10.0, 0.5, 100);
-
10.0
array
array(expr, ...) - 返回带有给定元素的数组.
Examples:
-
> SELECT array(1, 2, 3);
-
[1,2,3]
array_contains
array_contains(array, value) - Returns true if the array contains the value.
Examples:
-
> SELECT array_contains(array(1, 2, 3), 2);
-
true
ascii
ascii(str) - Returns the numeric value of the first character of str
.
Examples:
-
> SELECT ascii('222');
-
50
-
> SELECT ascii(2);
-
50
asin
asin(expr) - Returns the inverse sine (a.k.a. arcsine) the arc sin of expr
if -1<=expr
<=1 or NaN otherwise.
Examples:
-
> SELECT asin(0);
-
0.0
-
> SELECT asin(2);
-
NaN
assert_true
assert_true(expr) - Throws an exception if expr
is not true.
Examples:
-
> SELECT assert_true(0 < 1);
-
NULL
atan
atan(expr) - Returns the inverse tangent (a.k.a. arctangent).
Examples:
-
> SELECT atan(0);
-
0.0
atan2
atan2(expr1, expr2) - Returns the angle in radians between the positive x-axis of a plane and the point given by the coordinates (expr1
, expr2
).
Examples:
-
> SELECT atan2(0, 0);
-
0.0
avg
avg(expr) - Returns the mean calculated from values of a group.
base64
base64(bin) - Converts the argument from a binary bin
to a base 64 string.
Examples:
-
> SELECT base64('Spark SQL');
-
U3BhcmsgU1FM
bigint
bigint(expr) - Casts the value expr
to the target data type bigint
.
bin
bin(expr) - Returns the string representation of the long value expr
represented in binary.
Examples:
-
> SELECT bin(13);
-
1101
-
> SELECT bin(-13);
-
1111111111111111111111111111111111111111111111111111111111110011
-
> SELECT bin(13.3);
-
1101
binary
binary(expr) - Casts the value expr
to the target data type binary
.
bit_length
bit_length(expr) - Returns the bit length of string data or number of bits of binary data.
Examples:
-
> SELECT bit_length('Spark SQL');
-
72
boolean
boolean(expr) - Casts the value expr
to the target data type boolean
.
bround
bround(expr, d) - Returns expr
rounded to d
decimal places using HALF_EVEN rounding mode.
Examples:
-
> SELECT bround(2.5, 0);
-
2.0
cast
cast(expr AS type) - Casts the value expr
to the target data type type
.
Examples:
-
> SELECT cast('10' as int);
-
10
cbrt
cbrt(expr) - Returns the cube root of expr
.
Examples:
-
> SELECT cbrt(27.0);
-
3.0
ceil
ceil(expr) - Returns the smallest integer not smaller than expr
.
Examples:
-
> SELECT ceil(-0.1);
-
0
-
> SELECT ceil(5);
-
5
ceiling
ceiling(expr) - Returns the smallest integer not smaller than expr
.
Examples:
-
> SELECT ceiling(-0.1);
-
0
-
> SELECT ceiling(5);
-
5
char
char(expr) - Returns the ASCII character having the binary equivalent to expr
. If n is larger than 256 the result is equivalent to chr(n % 256)
Examples:
-
> SELECT char(65);
-
A
char_length
char_length(expr) - Returns the character length of string data or number of bytes of binary data. The length of string data includes the trailing spaces. The length of binary data includes binary zeros.
Examples:
-
> SELECT char_length('Spark SQL ');
-
10
-
> SELECT CHAR_LENGTH('Spark SQL ');
-
10
-
> SELECT CHARACTER_LENGTH('Spark SQL ');
-
10
character_length
character_length(expr) - Returns the character length of string data or number of bytes of binary data. The length of string data includes the trailing spaces. The length of binary data includes binary zeros.
Examples:
-
> SELECT character_length('Spark SQL ');
-
10
-
> SELECT CHAR_LENGTH('Spark SQL ');
-
10
-
> SELECT CHARACTER_LENGTH('Spark SQL ');
-
10
chr
chr(expr) - Returns the ASCII character having the binary equivalent to expr
. If n is larger than 256 the result is equivalent to chr(n % 256)
Examples:
-
> SELECT chr(65);
-
A
coalesce
coalesce(expr1, expr2, ...) - Returns the first non-null argument if exists. Otherwise, null.
Examples:
-
> SELECT coalesce(NULL, 1, NULL);
-
1
collect_list
collect_list(expr) - Collects and returns a list of non-unique elements.
collect_set
collect_set(expr) - Collects and returns a set of unique elements.
concat
concat(str1, str2, ..., strN) - Returns the concatenation of str1, str2, ..., strN.
Examples:
-
> SELECT concat('Spark', 'SQL');
-
SparkSQL
concat_ws
concat_ws(sep, [str | array(str)]+) - Returns the concatenation of the strings separated by sep
.
Examples:
-
> SELECT concat_ws(' ', 'Spark', 'SQL');
-
Spark SQL
conv
conv(num, from_base, to_base) - Convert num
from from_base
to to_base
.
Examples:
-
> SELECT conv('100', 2, 10);
-
4
-
> SELECT conv(-10, 16, -10);
-
-16
corr
corr(expr1, expr2) - Returns Pearson coefficient of correlation between a set of number pairs.
cos
cos(expr) - Returns the cosine of expr
.
Examples:
-
> SELECT cos(0);
-
1.0
cosh
cosh(expr) - Returns the hyperbolic cosine of expr
.
Examples:
-
> SELECT cosh(0);
-
1.0
cot
cot(expr) - Returns the cotangent of expr
.
Examples:
-
> SELECT cot(1);
-
0.6420926159343306
count
count(*) - Returns the total number of retrieved rows, including rows containing null.
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.
count_min_sketch
count_min_sketch(col, eps, confidence, seed) - Returns a count-min sketch of