hive 函数

Last updated on November 22, 2024 pm

🧙 Questions

hive在DML中常用的函数

☄️ Ideas

创建dual表
create table dual (dummy string);
insert into dual values ('1 x 1');
空判断
-- isnull(val) --> boolean
select isnull(NULL) from dual;
-- result: true
非空判断
-- isnotnull(val) --> boolean
select isnotnull(NULL) from dual;
-- result: false
正则表达式替换
-- regexp_replace('INITIAL_STRING','PATTERN','REPLACEMENT') --> string
select regexp_replace(dummy,'x','y') from dual; 
-- result: 1 y 1
字符串切割
-- substring('A', int start, int len) --> string
select substring(dummy,0,2) from dual;
-- result: 1
条件函数
select
  (case
    when dummy = 'x'  then 5
    when (dummy = '1 x 1') then 6 
  end) 
from dual;
-- result: 6

hive 函数
https://ispong.isxcode.com/hadoop/hive/hive 函数/
Author
ispong
Posted on
April 12, 2022
Licensed under