1# 增加X自然天 2select days_add(now(),2)
字符串转Timestamp
select to_timestamp('2019-10-14 20:00:01', 'yyyy-MM-dd HH:mm:ss');
注意,Impala的timestamp的标准是 ISO 8601 参考:https://en.wikipedia.org/wiki/ISO_8601
两个时间戳比较,粒度是天。否则就自己用2个timestamp相减。
select datediff(to_timestamp('2019-10-14', 'yyyy-MM-dd'), to_timestamp('2019-10-10', 'yyyy-MM-dd'));
Timestamp转字符串函数
FROM_TIMESTAMP(TIMESTAMP datetime, STRING pattern), FROM_TIMESTAMP(STRING datetime, STRING pattern)
Purpose: Converts a TIMESTAMP value into a string representing the same value.
Return type: STRING
select FROM_TIMESTAMP(now(),'yyyy-MM-dd HH:mm:ss') ;
regexp_replace, 使用正则匹配,剔除非中文字符
select regexp_replace('abcd1234中文你好','[^u4e00-u9fa5]+','') ;
Impala split_part函数
select split_part('a,b,c,d',',', 1) ; -- => a
Impala 授权模型使用记录:
1-- 创建角色,角色这个概念,是在Hive和Impala范围的 2create role impala; 3-- server1是一个默认的配置项 4grant all on server server1 to role impala with grant option; 5 6grant select on database p2plog to role impala ; 7grant all on database p2plog to role impala; 8 9-- 这个组对应到用户的LDAP所属组 10grant role impala to group impala; 11 12-- 查看授权 13show roles; 14show current roles; 15show grant role bigdata_risk; 16; 17 18-- 表级别授权,撤回 19grant select on table xxx_table_name to role role_name1; 20grant ALL | ALTER | CREATE | DROP | INSERT | REFRESH | SELECT | SELECT(column_name) on xxx_table_name to role role_name1; 21revoke update, select on table secured_table from role my_role; 22 23show grant user user_name1 on table hive_table_name1; 24show grant user user_name1 on all; 25show grant on table hive_table_name1;