hive 的条件判断(if、coalesce、case)
来源:互联网 发布:厦门威尔软件 编辑:程序博客网 时间:2024/06/05 20:12
CONDITIONAL FUNCTIONS IN HIVE
Hive supports three types of conditional functions. These functions are listed below:
1. IF( Test Condition, True Value, False Value )
The IF condition evaluates the “Test Condition” and if the “Test Condition” is true, then it returns the “True Value”. Otherwise, it returns the False Value.Example: IF(1=1, 'working', 'not working') returns 'working'
2. COALESCE( value1,value2,… )
The COALESCE function returns the fist not NULL value from the list of values. If all the values in the list are NULL, then it returns NULL.Example: COALESCE(NULL,NULL,5,NULL,4) returns 5
3. CASE Statement
The syntax for the case statement is:CASE [ expression ] WHEN condition1 THEN result1 WHEN condition2 THEN result2 ... WHEN conditionn THEN resultn ELSE resultENDHere expression is optional. It is the value that you are comparing to the list of conditions. (ie: condition1, condition2, ... conditionn).All the conditions must be of same datatype. Conditions are evaluated in the order listed. Once a condition is found to be true, the case statement will return the result and not evaluate the conditions any further.All the results must be of same datatype. This is the value returned once a condition is found to be true.IF no condition is found to be true, then the case statement will return the value in the ELSE clause. If the ELSE clause is omitted and no condition is found to be true, then the case statement will return NULLExample: CASE Fruit WHEN 'APPLE' THEN 'The owner is APPLE' WHEN 'ORANGE' THEN 'The owner is ORANGE' ELSE 'It is another Fruit'ENDThe other form of CASE isCASE WHEN Fruit = 'APPLE' THEN 'The owner is APPLE' WHEN Fruit = 'ORANGE' THEN 'The owner is ORANGE' ELSE 'It is another Fruit'END
转自:http://blog.csdn.net/longerandlonger/article/details/8755395
0 0
- hive 的条件判断(if、coalesce、case)
- hive 的条件判断(if、coalesce、case)
- hive 的条件判断(if、coalesce、case)
- hive 的判断条件(if、coalesce、case)
- hive 的条件判断(if、coalesce、case)
- hive中使用case、if:一个region统计业务(hive条件函数case、if、COALESCE语法介绍:CONDITIONAL FUNCTIONS IN HIVE)
- hive中if和coalesce 去除null值,case when
- hive中if和coalesce 去除null值,case when
- 条件判断if 和 case...esac 判断(相当于switch)
- shell条件判断二 (if、case)
- hive的条件函数case
- shell script 学习(四)条件判断式的使用:if..then ..fi和 case...esac语句
- Erlang笔记(05) - Erlang条件判断: if, case, when
- MySql查询IF和CASE条件判断使用
- 实现1+2+3...+n,要求不能使用乘除法、循环、条件判断、选择相关的关键字(for、while、if、else、switch、case)。
- 数据库sql判断语句(case,IF)
- mysql 中的判断语句(case、if)
- IF条件判断,判断条件
- 居家旅行必备的Android网络ADB调试功能+Google插件Vysor
- [数据结构]第六章-树
- 第十四周-项目一 验证算法(2)
- request.getParameterMap().entrySet().iterator()遍历
- 用内连接组合表
- hive 的条件判断(if、coalesce、case)
- usb驱动程序设计
- hook(钩子)技术
- Linux操作命令之ipmitool命令参数详解(中文翻译总结)
- 第十四周 验证分块查找算法
- 第十三周 项目1最小生成树的普里姆算法
- c#二叉排序树实现
- Android检查调试器
- this.class.getClassLoader().getResourceAsStream