Spark版本号:2.4.3,Spark SQL命令行输入
show functions;
示例
> select abs(-10);
+------+
| _c0 |
+------+
| 10 |
+------+
> select acos(0.5);
+---------------------+
| _c0 |
+---------------------+
| 1.0471975511965979 |
+---------------------+
> select add_months('2016-02-29', 1);
+-------------+
| _c0 |
+-------------+
| 2016-03-31 |
+-------------+
aggregate
and
approx_count_distinct(expr[, relativeSD])
approx_percentile(col, percentage [, accuracy])
array(expr, …) - 返回给定值组成的数组。
> select array(1, 2 , 3, 4, 5, 6);
+----------------+
| _c0 |
+----------------+
| [1,2,3,4,5,6] |
+----------------+
> select array_contains(array(1, 2, 3, 4, 5, 6), 1);
+------------------------------------------+
|array_contains(array(1, 2, 3, 4, 5, 6), 1)|
+------------------------------------------+
| true|
+------------------------------------------+
> select array_distinct(array(1, 1, 3, 3));
+---------------------------------+
|array_distinct(array(1, 1, 3, 3))|
+---------------------------------+
| [1, 3]|
+---------------------------------+
> select array_except(array(1, 2, 3) , array(1));
+--------------------------------------+
|array_except(array(1, 2, 3), array(1))|
+--------------------------------------+
| [2, 3]|
+--------------------------------------+
> select array_intersect(array(1, 2, 3) , array(1, 2));
+--------------------------------------------+
|array_intersect(array(1, 2, 3), array(1, 2))|
+--------------------------------------------+
| [1, 2]|
+--------------------------------------------+
> select array_join(array('hello', null, 'world'), ',', 'null');
+--------------------------------------------------------------+
|array_join(array(hello, CAST(NULL AS STRING), world), ,, null)|
+--------------------------------------------------------------+
| hello,null,world|
+--------------------------------------------------------------+
第一个参数为:stirng的数组
第二个参数为:拼接字符串
第三个参数为:null替换为字符串
> select array_max(array(1, 2, 10, null, 3));
+------------------------------------------------+
|array_max(array(1, 2, 10, CAST(NULL AS INT), 3))|
+------------------------------------------------+
| 10|
+------------------------------------------------+
> select array_min(array(1, 2, 10, null, 3));
+------------------------------------------------+
|array_min(array(1, 2, 10, CAST(NULL AS INT), 3))|
+------------------------------------------------+
| 1|
+------------------------------------------------+
> select array_position(array(1, 3, 4, 1), 1);
+------------------------------------+
|array_position(array(1, 3, 4, 1), 1)|
+------------------------------------+
| 1|
+------------------------------------+
> select array_remove(array(1, 3, 4, 1, 1), 1);
+-------------------------------------+
|array_remove(array(1, 3, 4, 1, 1), 1)|
+-------------------------------------+
| [3, 4]|
+-------------------------------------+
> select array_repeat('1', 2);
+------------------+
|array_repeat(1, 2)|
+------------------+
| [1, 1]|
+------------------+
> select array_sort(array(3, 4, 1, null, 0));
+------------------------------------------------+
|array_sort(array(3, 4, 1, CAST(NULL AS INT), 0))|
+------------------------------------------------+
| [0, 1, 3, 4,]|
+------------------------------------------------+
> select array_union(array(1, 2, 3), array(1, 3, 5));
+-------------------------------------------+
|array_union(array(1, 2, 3), array(1, 3, 5))|
+-------------------------------------------+
| [1, 2, 3, 5]|
+-------------------------------------------+
> select arrays_overlap(array(1, 2, 3), array(3, 4, 5));
+----------------------------------------------+
|arrays_overlap(array(1, 2, 3), array(3, 4, 5))|
+----------------------------------------------+
| true|
+----------------------------------------------+
> select arrays_zip(array(1, 2), array(2, 3));
+------------------------------------+
|arrays_zip(array(1, 2), array(2, 3))|
+------------------------------------+
| [[1, 2], [2, 3]]|
+------------------------------------+
> select ascii('China 100');
+----------------+
|ascii(China 100)|
+----------------+
| 67|
+----------------+
> select ascii('0.5');
+----------+
|ascii(0.5)|
+----------+
| 48|
+----------+
> select assert_true(0 < 1);
+--------------------+
|assert_true((0 < 1))|
+--------------------+
| null|
+--------------------+
> select atan(0.5);
spark.sql("select atan(0.5)").show();
+-------------------------+
|ATAN(CAST(0.5 AS DOUBLE))|
+-------------------------+
| 0.4636476090008061|
+-------------------------+
> select atan2(1, 1);
+-------------------------------------------+
|ATAN2(CAST(1 AS DOUBLE), CAST(1 AS DOUBLE))|
+-------------------------------------------+
| 0.7853981633974483|
+-------------------------------------------+
> select base64('hello world');
+-----------------------------------+
|base64(CAST(hello world AS BINARY))|
+-----------------------------------+
| aGVsbG8gd29ybGQ=|
+-----------------------------------+
> select bigint('121');
+-------------------+
|CAST(121 AS BIGINT)|
+-------------------+
| 121|
+-------------------+
> select bin(100);
+------------------------+
|bin(CAST(100 AS BIGINT))|
+------------------------+
| 1100100|
+------------------------+
> select binary(bin(100));
+----------------------------------------+
|CAST(bin(CAST(100 AS BIGINT)) AS BINARY)|
+----------------------------------------+
| [31 31 30 30 31 3...|
+----------------------------------------+
> select bit_length(binary(bin(100)));
+----------------------------------------------------+
|bit_length(CAST(bin(CAST(100 AS BIGINT)) AS BINARY))|
+----------------------------------------------------+
| 56|
+----------------------------------------------------+
> select bit_length('hello world');
+-----------------------+
|bit_length(hello world)|
+-----------------------+
| 88|
+-----------------------+
> select boolean(0);
+------------------+
|CAST(0 AS BOOLEAN)|
+------------------+
| false|
+------------------+
> select bround(3.1415926, 2);
+--------------------+
|bround(3.1415926, 2)|
+--------------------+
| 3.14|
+--------------------+
> select cast('10' as integer);
+---------------+
|CAST(10 AS INT)|
+---------------+
| 10|
+---------------+
> select cbrt(8);
+-----------------------+
|CBRT(CAST(8 AS DOUBLE))|
+-----------------------+
| 2.0|
+-----------------------+
> select ceil(-3.1415926);
+----------------+
|CEIL(-3.1415926)|
+----------------+
| -3|
+----------------+
> select ceiling(-3.1415926);
+----------------+
|CEIL(-3.1415926)|
+----------------+
| -3|
+----------------+
> select char(100);
+------------------------+
|chr(CAST(100 AS BIGINT))|
+------------------------+
| d|
+------------------------+
> select char_length('hello world');
+-------------------+
|length(hello world)|
+-------------------+
| 11|
+-------------------+
> select character_length('hello world');
+-------------------+
|length(hello world)|
+-------------------+
| 11|
+-------------------+
> select chr(100);
+------------------------+
|chr(CAST(100 AS BIGINT))|
+------------------------+
| d|
+------------------------+
> select coalesce(null, 1, null, 2);
+----------------------------------------------------+
|coalesce(CAST(NULL AS INT), 1, CAST(NULL AS INT), 2)|
+----------------------------------------------------+
| 1|
+----------------------------------------------------+
> select collect_list(carstate) from gps_car;
+----------------------+
|collect_list(carstate)|
+----------------------+
| [2.0, 2.0, 2.0, 2...|
+----------------------+
> select collect_set(carstate) from gps_car;
+---------------------+
|collect_set(carstate)|
+---------------------+
| [2.0, 0.0, 1.0]|
+---------------------+
> select concat('hello', 'world');
+--------------------+
|concat(hello, world)|
+--------------------+
| helloworld|
+--------------------+
> select concat_ws(' ', 'hello', 'world');
+--------------------------+
|concat_ws( , hello, world)|
+--------------------------+
| hello world|
+--------------------------+
> select concat_ws(' ', array('hello', 'world'));
+---------------------------------+
|concat_ws( , array(hello, world))|
+---------------------------------+
| hello world|
+---------------------------------+
> select conv(100, 2, 10);
+--------------------------------+
|conv(CAST(100 AS STRING), 2, 10)|
+--------------------------------+
| 4|
+--------------------------------+
> select cos(0.5);
+------------------------+
|COS(CAST(0.5 AS DOUBLE))|
+------------------------+
| 0.8775825618903728|
+------------------------+
> select cosh(0);
+-----------------------+
|COSH(CAST(0 AS DOUBLE))|
+-----------------------+
| 1.0|
+-----------------------+
> select cot(1);
+----------------------+
|COT(CAST(1 AS DOUBLE))|
+----------------------+
| 0.6420926159343306|
+----------------------+
> select current_database();
+------------------+
|current_database()|
+------------------+
| default|
+------------------+
> select current_date();
+--------------+
|current_date()|
+--------------+
| 2020-03-11|
+--------------+
> select current_timestamp();
+--------------------+
| current_timestamp()|
+--------------------+
|2020-03-11 04:26:...|
+--------------------+
> select date('2010-10-10');
+------------------------+
|CAST(2010-10-10 AS DATE)|
+------------------------+
| 2010-10-10|
+------------------------+
> select date_add('2010-10-10', 1);
+-------------------------------------+
|date_add(CAST(2010-10-10 AS DATE), 1)|
+-------------------------------------+
| 2010-10-11|
+-------------------------------------+
> select date_format('2010-10-10', 'yyyy');
+------------------------------------------------+
|date_format(CAST(2010-10-10 AS TIMESTAMP), yyyy)|
+------------------------------------------------+
| 2010|
+------------------------------------------------+
> select date_sub('2020-10-10', 1);
+-------------------------------------+
|date_sub(CAST(2020-10-10 AS DATE), 1)|
+-------------------------------------+
| 2020-10-09|
+-------------------------------------+
> select date_trunc('yyyy', '2011-11-11 11:11:11.111');
+------------------------------------------------------------+
|date_trunc(yyyy, CAST(2011-11-11 11:11:11.111 AS TIMESTAMP))|
+------------------------------------------------------------+
| 2011-01-01 00:00:00|
+------------------------------------------------------------+
> select date_trunc('month', '2011-11-11 11:11:11.111');
+-------------------------------------------------------------+
|date_trunc(month, CAST(2011-11-11 11:11:11.111 AS TIMESTAMP))|
+-------------------------------------------------------------+
| 2011-11-01 00:00:00|
+-------------------------------------------------------------+
> select date_trunc('day', '2011-11-11 11:11:11.111');
+-----------------------------------------------------------+
|date_trunc(day, CAST(2011-11-11 11:11:11.111 AS TIMESTAMP))|
+-----------------------------------------------------------+
| 2011-11-11 00:00:00|
+-----------------------------------------------------------+
> select datediff('2011-11-11', '2011-11-10');
+------------------------------------------------------------+
|datediff(CAST(2011-11-11 AS DATE), CAST(2011-11-10 AS DATE))|
+------------------------------------------------------------+
| 1|
+------------------------------------------------------------+
> select day('2020-2-11');
+-----------------------------------+
|dayofmonth(CAST(2020-2-11 AS DATE))|
+-----------------------------------+
| 11|
+-----------------------------------+
> select dayofmonth('2020-2-11');
+-----------------------------------+
|dayofmonth(CAST(2020-2-11 AS DATE))|
+-----------------------------------+
| 11|
+-----------------------------------+
> select dayofmonth('2020-2-11');
+-----------------------------------+
|dayofmonth(CAST(2020-2-11 AS DATE))|
+-----------------------------------+
| 11|
+-----------------------------------+
> select dayofyear('2020-2-11');
+----------------------------------+
|dayofyear(CAST(2020-2-11 AS DATE))|
+----------------------------------+
| 42|
+----------------------------------+
> select decimal(1.0);
+--------------------------+
|CAST(1.0 AS DECIMAL(10,0))|
+--------------------------+
| 1|
+--------------------------+
> select decode('abcd', 'utf-8');
+-----------------------------------+
|decode(CAST(abcd AS BINARY), utf-8)|
+-----------------------------------+
| abcd|
+-----------------------------------+
> select double(1);
+-----------------+
|CAST(1 AS DOUBLE)|
+-----------------+
| 1.0|
+-----------------+
> select e();
+-----------------+
| E()|
+-----------------+
|2.718281828459045|
+-----------------+
> select elt(2, 'java', 'php', 'R');
+--------------------+
|elt(2, java, php, R)|
+--------------------+
| php|
+--------------------+
> select encode('abcd', 'utf-8');
+-------------------+
|encode(abcd, utf-8)|
+-------------------+
| [61 62 63 64]|
+-------------------+
> select explode(array(1, 3, 5));
+---+
|col|
+---+
| 1|
| 3|
| 5|
+---+
> select explode_outer(array(1, 3, 5));
+---+
|col|
+---+
| 1|
| 3|
| 5|
+---+
> select factorial(5);
+------------+
|factorial(5)|
+------------+
| 120|
+------------+
> select find_in_set('ab','abc,b,ab,c,def');
+-------------------------------+
|find_in_set(ab, abc,b,ab,c,def)|
+-------------------------------+
| 3|
+-------------------------------+
> select float(1);
+----------------+
|CAST(1 AS FLOAT)|
+----------------+
| 1.0|
+----------------+
> select floor(-0.1);
+-----------+
|FLOOR(-0.1)|
+-----------+
| -1|
+-----------+
> select format_number(3141.5926, 3);
+---------------------------+
|format_number(3141.5926, 3)|
+---------------------------+
| 3,141.593|
+---------------------------+
> select format_string('Hello World %d %s', 100, 'days');
+-------------------------------------------+
|format_string(Hello World %d %s, 100, days)|
+-------------------------------------------+
| Hello World 100 days|
+-------------------------------------------+
> select from_json("{'id': 1, 'name': 'zhangsan'}", "id int, name string");
+--------------------------------------------+
|jsontostructs({'id': 1, 'name': 'zhangsan'})|
+--------------------------------------------+
| [1, zhangsan]|
+--------------------------------------------+
> select from_unixtime(1583888136, 'yyyy-MM-dd HH:mm:ss');
+--------------------------------------------------------------+
|from_unixtime(CAST(1583888136 AS BIGINT), yyyy-MM-dd HH:mm:ss)|
+--------------------------------------------------------------+
| 2020-03-11 08:55:36|
+--------------------------------------------------------------+
> select from_utc_timestamp('2020-01-01', 'Asia/Seoul');
+-------------------------------------------------------------+
|from_utc_timestamp(CAST(2020-01-01 AS TIMESTAMP), Asia/Seoul)|
+-------------------------------------------------------------+
| 2020-01-01 09:00:00|
+-------------------------------------------------------------+
> select greatest(1, 3, 4, 10);
+---------------------+
|greatest(1, 3, 4, 10)|
+---------------------+
| 10|
+---------------------+
> select hash('hello', 'world');
+------------------+
|hash(hello, world)|
+------------------+
| -165041762|
+------------------+
> select hex('hello world');
+--------------------+
| hex(hello world)|
+--------------------+
|68656C6C6F20776F7...|
+--------------------+
> select hour('2020-11-11 11:11:11');
+--------------------------------------------+
|hour(CAST(2020-11-11 11:11:11 AS TIMESTAMP))|
+--------------------------------------------+
| 11|
+--------------------------------------------+
sqrt(expr^2 + expr2^2)
> select hypot(3, 4);
+-------------------------------------------+
|HYPOT(CAST(3 AS DOUBLE), CAST(4 AS DOUBLE))|
+-------------------------------------------+
| 5.0|
+-------------------------------------------+
> select if(1 > 2, '1', '2');
+-------------------+
|(IF((1 > 2), 1, 2))|
+-------------------+
| 2|
+-------------------+
> select ifnull(null, 'expr2');
+---------------------+
|ifnull(NULL, 'expr2')|
+---------------------+
| expr2|
+---------------------+
> select 1 in(1, 3, 4);
+----------------+
|(1 IN (1, 3, 4))|
+----------------+
| true|
+----------------+
> select initcap('hello world');
+--------------------+
|initcap(hello world)|
+--------------------+
| Hello World|
+--------------------+
> select inline(array(struct(1, 'a'), struct(2, 'b')));
+----+----+
|col1|col2|
+----+----+
| 1| a|
| 2| b|
+----+----+
> select inline_outer(array(struct(1, 'a'), struct(2, 'b')));
+----+----+
|col1|col2|
+----+----+
| 1| a|
| 2| b|
+----+----+
> select instr('hello world', 'world');
+-------------------------+
|instr(hello world, world)|
+-------------------------+
| 7|
+-------------------------+
> select int(3.14);
+-----------------+
|CAST(3.14 AS INT)|
+-----------------+
| 3|
+-----------------+
> select isnotnull(1);
+---------------+
|(1 IS NOT NULL)|
+---------------+
| true|
+---------------+
> select isnull(null);
+--------------+
|(NULL IS NULL)|
+--------------+
| true|
+--------------+
> select java_method('java.util.UUID', 'randomUUID');
+-----------------------------------+
|reflect(java.util.UUID, randomUUID)|
+-----------------------------------+
| 3aaebaa8-6335-440...|
+-----------------------------------+
> select last(array(1, 3, null, 5));
+----------------------------------------------+
|last(array(1, 3, CAST(NULL AS INT), 5), false)|
+----------------------------------------------+
| [1, 3,, 5]|
+----------------------------------------------+
> select last_day('2020-02-01');
+----------------------------------+
|last_day(CAST(2020-02-01 AS DATE))|
+----------------------------------+
| 2020-02-29|
+----------------------------------+
> select lcase('Hello World');
+------------------+
|lower(Hello World)|
+------------------+
| hello world|
+------------------+
> select least(null, 10, 3, 4);
+----------------------------------+
|least(CAST(NULL AS INT), 10, 3, 4)|
+----------------------------------+
| 3|
+----------------------------------+
> select left('hello world', 3);
+----------------------+
|left('hello world', 3)|
+----------------------+
| hel|
+----------------------+
> select length('hello world');
+-------------------+
|length(hello world)|
+-------------------+
| 11|
+-------------------+
> select lower('Hello World');
+------------------+
|lower(Hello World)|
+------------------+
| hello world|
+------------------+
> select ltrim('ha', 'haHello worldha');
+--------------------------+
|ltrim(haHello worldha, ha)|
+--------------------------+
| Hello worldha|
+--------------------------+
> select map(1.0, '2', 3.0, '4');
+--------------------+
| map(1.0, 2, 3.0, 4)|
+--------------------+
|[1.0 -> 2, 3.0 -> 4]|
+--------------------+
> select map_concat(map(1, 'a', 2, 'b'), map(2, 'c', 3, 'd'));
+--------------------------------------------+
|map_concat(map(1, a, 2, b), map(2, c, 3, d))|
+--------------------------------------------+
| [1 -> a, 2 -> b, ...|
+--------------------------------------------+
> select map_from_arrays(array(1.0, 3.0), array('2', '4'));
+---------------------------------------------+
|map_from_arrays(array(1.0, 3.0), array(2, 4))|
+---------------------------------------------+
| [1.0 -> 2, 3.0 -> 4]|
+---------------------------------------------+
> select map_from_entries(array(struct(1, 'a'), struct(2, 'b')));
+---------------------------------------------------------------------------------------+
|map_from_entries(array(named_struct(col1, 1, col2, a), named_struct(col1, 2, col2, b)))|
+---------------------------------------------------------------------------------------+
| [1 -> a, 2 -> b]|
+---------------------------------------------------------------------------------------+
> select map_keys(map(1, 'a', 2, 'b'));
+-------------------------+
|map_keys(map(1, a, 2, b))|
+-------------------------+
| [1, 2]|
+-------------------------+
> select map_values(map(1, 'a', 2, 'b'));
+---------------------------+
|map_values(map(1, a, 2, b))|
+---------------------------+
| [a, b]|
+---------------------------+
> select md5('hello world');
+--------------------------------+
|md5(CAST(hello world AS BINARY))|
+--------------------------------+
| 5eb63bbbe01eeed09...|
+--------------------------------+
> select minute('2011-11-11 11:11:11');
+----------------------------------------------+
|minute(CAST(2011-11-11 11:11:11 AS TIMESTAMP))|
+----------------------------------------------+
| 11|
+----------------------------------------------+
> select mod(11, 2);
+--------+
|(11 % 2)|
+--------+
| 1|
+--------+
> select month('2011-11-11');
+-------------------------------+
|month(CAST(2011-11-11 AS DATE))|
+-------------------------------+
| 11|
+-------------------------------+
> select months_between('2000-10-1', '2000-11-2');
+--------------------------------------------------------------------------------+
|months_between(CAST(2000-10-1 AS TIMESTAMP), CAST(2000-11-2 AS TIMESTAMP), true)|
+--------------------------------------------------------------------------------+
| -1.03225806|
+--------------------------------------------------------------------------------+
> select named_struct('a', 1, 'b', 2, 'c', 3);
+------------------------------+
|named_struct(a, 1, b, 2, c, 3)|
+------------------------------+
| [1, 2, 3]|
+------------------------------+
> select negative(100);
+-------+
|(- 100)|
+-------+
| -100|
+-------+
> select next_day('2020-03-11', 'FRI');
+---------------------------------------+
|next_day(CAST(2020-03-11 AS DATE), FRI)|
+---------------------------------------+
| 2020-03-13|
+---------------------------------------+
> select now();
+--------------------+
| current_timestamp()|
+--------------------+
|2020-03-11 23:07:...|
+--------------------+
> select nvl(null, 'hello');
+------------------+
|nvl(NULL, 'hello')|
+------------------+
| hello|
+------------------+
> select octet_length('hello world');
+-------------------------+
|octet_length(hello world)|
+-------------------------+
| 11|
+-------------------------+
> select pi();
+-----------------+
| PI()|
+-----------------+
|3.141592653589793|
+-----------------+
> select posexplode(array(1, 3, 4));
+---+---+
|pos|col|
+---+---+
| 0| 1|
| 1| 3|
| 2| 4|
+---+---+
> select posexplode_outer(array(1, 3, 4));
+---+---+
|pos|col|
+---+---+
| 0| 1|
| 1| 3|
| 2| 4|
+---+---+
> select position('he', 'world hello', 1);
+--------------------------+
|locate(he, world hello, 1)|
+--------------------------+
| 7|
+--------------------------+
> select pow(2, 4);
+-------------------------------------------+
|POWER(CAST(2 AS DOUBLE), CAST(4 AS DOUBLE))|
+-------------------------------------------+
| 16.0|
+-------------------------------------------+
> select power(2, 4);
+-------------------------------------------+
|POWER(CAST(2 AS DOUBLE), CAST(4 AS DOUBLE))|
+-------------------------------------------+
| 16.0|
+-------------------------------------------+
> select printf('Hello World %d %s', 100, 'days');
+-------------------------------------------+
|format_string(Hello World %d %s, 100, days)|
+-------------------------------------------+
| Hello World 100 days|
+-------------------------------------------+
> select quarter('2020-11-11');
+---------------------------------+
|quarter(CAST(2020-11-11 AS DATE))|
+---------------------------------+
| 4|
+---------------------------------+
> select radians(180);
+----------------------------+
|RADIANS(CAST(180 AS DOUBLE))|
+----------------------------+
| 3.141592653589793|
+----------------------------+
> select rand();
+-------------------------+
|rand(7896507467301193574)|
+-------------------------+
| 0.1643759947938076|
+-------------------------+
> select randn();
+---------------------------+
|randn(-2498753337637632801)|
+---------------------------+
| -0.4827279803917336|
+---------------------------+
> select reflect('java.util.UUID', 'randomUUID');
+-----------------------------------+
|reflect(java.util.UUID, randomUUID)|
+-----------------------------------+
| 3930dab2-d5e0-49e...|
+-----------------------------------+
> select repeat('ha', 4);
+-------------+
|repeat(ha, 4)|
+-------------+
| hahahaha|
+-------------+
> select replace('hello world', 'lo', 'ol');
+----------------------------+
|replace(hello world, lo, ol)|
+----------------------------+
| helol world|
+----------------------------+
> select reverse('hello world');
+--------------------+
|reverse(hello world)|
+--------------------+
| dlrow olleh|
+--------------------+
> select right('hello world', 3);
+-----------------------+
|right('hello world', 3)|
+-----------------------+
| rld|
+-----------------------+
> select rint(3.14159);
+------------------------------+
|ROUND(CAST(3.14159 AS DOUBLE))|
+------------------------------+
| 3.0|
+------------------------------+
> select round(2.5, 0);
+-------------+
|round(2.5, 0)|
+-------------+
| 3|
+-------------+
> select rtrim('ha', 'hahello worldha');
+--------------------------+
|rtrim(hahello worldha, ha)|
+--------------------------+
| hahello world|
+--------------------------+
> select second('2011-11-11 11:11:11');
+----------------------------------------------+
|second(CAST(2011-11-11 11:11:11 AS TIMESTAMP))|
+----------------------------------------------+
| 11|
+----------------------------------------------+
> select sentences('hello world!my dreams');
+------------------------------------+
|sentences(hello world!my dreams, , )|
+------------------------------------+
| [[hello, world], ...|
+------------------------------------+
> select sha('hello world');
+---------------------------------+
|sha1(CAST(hello world AS BINARY))|
+---------------------------------+
| 2aae6c35c94fcfb41...|
+---------------------------------+
> select sha1('hello world');
+---------------------------------+
|sha1(CAST(hello world AS BINARY))|
+---------------------------------+
| 2aae6c35c94fcfb41...|
+---------------------------------+
> select sha2('hello world', 256);
+--------------------------------------+
|sha2(CAST(hello world AS BINARY), 256)|
+--------------------------------------+
| b94d27b9934d3e08a...|
+--------------------------------------+
> select sin(0);
+----------------------+
|SIN(CAST(0 AS DOUBLE))|
+----------------------+
| 0.0|
+----------------------+
> select size(array(1, 2, 3));
+--------------------+
|size(array(1, 2, 3))|
+--------------------+
| 3|
+--------------------+
> select smallint(100);
+---------------------+
|CAST(100 AS SMALLINT)|
+---------------------+
| 100|
+---------------------+
> select sort_array(array(2, 3, 1, 0), true);
+-----------------------------------+
|sort_array(array(2, 3, 1, 0), true)|
+-----------------------------------+
| [0, 1, 2, 3]|
+-----------------------------------+
> select split('hehahehahehaa', 'ha');
+------------------------+
|split(hehahehahehaa, ha)|
+------------------------+
| [he, he, he, a]|
+------------------------+
> select sqrt(9);
+-----------------------+
|SQRT(CAST(9 AS DOUBLE))|
+-----------------------+
| 3.0|
+-----------------------+
> select str_to_map('a:1,b:2,c:3', ',', ':');
+-----------------------------+
|str_to_map(a:1,b:2,c:3, ,, :)|
+-----------------------------+
| [a -> 1, b -> 2, ...|
+-----------------------------+
> select struct(1, 3, 4);
+---------------------------------------+
|named_struct(col1, 1, col2, 3, col3, 4)|
+---------------------------------------+
| [1, 3, 4]|
+---------------------------------------+
> select substr('hello world', 5, 1);
+----------------------------+
|substring(hello world, 5, 1)|
+----------------------------+
| o|
+----------------------------+
> select substring('hello world', 5, 1);
+----------------------------+
|substring(hello world, 5, 1)|
+----------------------------+
| o|
+----------------------------+
> select tan(0);
+----------------------+
|TAN(CAST(0 AS DOUBLE))|
+----------------------+
| 0.0|
+----------------------+
> select to_date('2011-11-11 11:11:11');
+------------------------------+
|to_date('2011-11-11 11:11:11')|
+------------------------------+
| 2011-11-11|
+------------------------------+
> select to_json(named_struct('a', 1, 'b', 2));
+---------------------------------------+
|structstojson(named_struct(a, 1, b, 2))|
+---------------------------------------+
| {"a":1,"b":2}|
+---------------------------------------+
> select to_timestamp('2011-11-11 11:11:11', 'yyyy-MM-dd HH:mm:ss');
+----------------------------------------------------------+
|to_timestamp('2011-11-11 11:11:11', 'yyyy-MM-dd HH:mm:ss')|
+----------------------------------------------------------+
| 2011-11-11 11:11:11|
+----------------------------------------------------------+
> select to_unix_timestamp('2011-11-11 11:11:11', 'yyyy-MM-dd HH:mm:ss');
+-----------------------------------------------------------+
|to_unix_timestamp(2011-11-11 11:11:11, yyyy-MM-dd HH:mm:ss)|
+-----------------------------------------------------------+
| 1320981071|
+-----------------------------------------------------------+
> select to_utc_timestamp('2011-11-11 11:11:11', 'Asia/Seoul');
+--------------------------------------------------------------------+
|to_utc_timestamp(CAST(2011-11-11 11:11:11 AS TIMESTAMP), Asia/Seoul)|
+--------------------------------------------------------------------+
| 2011-11-11 02:11:11|
+--------------------------------------------------------------------+
> select trim('ha', 'hahello worldha');
+-------------------------+
|trim(hahello worldha, ha)|
+-------------------------+
| ello world|
+-------------------------+
> select trunc('2011-11-11 02:11:11', 'yyyy');
+----------------------------------------------+
|trunc(CAST(2011-11-11 02:11:11 AS DATE), yyyy)|
+----------------------------------------------+
| 2011-01-01|
+----------------------------------------------+
> select ucase('hello world');
+------------------+
|upper(hello world)|
+------------------+
| HELLO WORLD|
+------------------+
> select unbase64('aGVsbG8gd29ybGQ=');
+--------------------------+
|unbase64(aGVsbG8gd29ybGQ=)|
+--------------------------+
| [68 65 6C 6C 6F 2...|
+--------------------------+
> select unhex('68656C6C6F');
+-----------------+
|unhex(68656C6C6F)|
+-----------------+
| [68 65 6C 6C 6F]|
+-----------------+
> select unix_timestamp('2020-01-01', 'yyyy-MM-dd');
+--------------------------------------+
|unix_timestamp(2020-01-01, yyyy-MM-dd)|
+--------------------------------------+
| 1577808000|
+--------------------------------------+
> select upper('hello world');
+------------------+
|upper(hello world)|
+------------------+
| HELLO WORLD|
+------------------+
> select uuid();
+--------------------+
| uuid()|
+--------------------+
|bd8aa547-9d08-46c...|
+--------------------+
> select weekofyear('2011-11-11');
+------------------------------------+
|weekofyear(CAST(2011-11-11 AS DATE))|
+------------------------------------+
| 45|
+------------------------------------+
> select case when 1 > 0 then 1 when 2 > 0 then 2.0 else 1.2 end;
+--------------------------------------------------------------------------------------------------------------------------------+
|CASE WHEN (1 > 0) THEN CAST(1 AS DECIMAL(11,1)) WHEN (2 > 0) THEN CAST(2.0 AS DECIMAL(11,1)) ELSE CAST(1.2 AS DECIMAL(11,1)) END|
+--------------------------------------------------------------------------------------------------------------------------------+
| 1.0|
+--------------------------------------------------------------------------------------------------------------------------------+
> select year('2011-11-11');
+------------------------------+
|year(CAST(2011-11-11 AS DATE))|
+------------------------------+
| 2011|
+------------------------------+