# 增加X自然天
select 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 授权模型使用记录:
-- 创建角色,角色这个概念,是在Hive和Impala范围的
create role impala;
-- server1是一个默认的配置项
grant all on server server1 to role impala with grant option;
grant select on database p2plog to role impala ;
grant all on database p2plog to role impala;
-- 这个组对应到用户的LDAP所属组
grant role impala to group impala;
-- 查看授权
show roles;
show current roles;
show grant role bigdata_risk;
;
-- 表级别授权,撤回
grant select on table xxx_table_name to role role_name1;
grant ALL | ALTER | CREATE | DROP | INSERT | REFRESH | SELECT | SELECT(column_name) on xxx_table_name to role role_name1;
revoke update, select on table secured_table from role my_role;
show grant user user_name1 on table hive_table_name1;
show grant user user_name1 on all;
show grant on table hive_table_name1;