Lateral View用法 与 Hive UDTF explode
来源:互联网 发布:163邮箱smtp端口号 编辑:程序博客网 时间:2024/05/19 22:50
Lateral View是Hive中提供给UDTF的conjunction,它可以解决UDTF不能添加额外的select列的问题。
1. Why we need Lateral View?
提示语法分析错误,UDTF不支持函数之外的select 语句,真无语。。。
如果我们想支持怎么办呢?接下来就是Lateral View 登场的时候了。
2. Lateral View explain
2.1 单个Lateral View
Lateral view is used in conjunction with user-defined table generatingfunctions such as explode()
. As mentioned in Built-in Table-Generating Functions, a UDTF generates zero or more output rows foreach input row. A lateral view first applies the UDTF to each row of base tableand then joins resulting output rows to the input rows to form a virtual tablehaving the supplied table alias.
Lateral view 其实就是用来和像类似explode这种UDTF函数联用的。lateral view 会将UDTF生成的结果放到一个虚拟表中,然后这个虚拟表会和输入行即每个game_id进行join 来达到连接UDTF外的select字段的目的。
Lateral View Syntax
1. 在udtf前面用
2. 在from baseTable后面用
举个例子:
1. 先创建一个文件,里面2列用\t分割,game_id和user_ids
下面使用lateral_view
2.2 多个Lateral View
Array<int> col1
Array<string> col2
[1, 2]
[a", "b", "c"]
[3, 4]
[d", "e", "f"]
转换目标:int myCol1
string myCol2
1
"a"
1
"b"
1
"c"
2
"a"
2
"b"
2
"c"
3
"d"
3
"e"
3
"f"
4
"d"
4
"e"
4
"f"
3. Outer Lateral View
4.总结:
- Lateral View用法 与 Hive UDTF explode
- Lateral View用法 与 Hive UDTF explode
- Lateral View用法 与 Hive UDTF explode
- hive:explode() 与 lateral view
- hive常用UDF and UDTF函数介绍-lateral view explode()
- hive行转列lateral view explode用法
- hive lateral view 与 explode详解
- hive lateral view 与 explode详解
- hive lateral view 与 explode详解
- hive lateral view explode 使用
- hive sql 中lateral view explode/json_tuple的使用
- hive collect_set,lateral view,explode 实现行列转换
- SQL 之 lateral view explode()
- 行转多列lateral view explode详解
- hive中的lateral view 用法详解上篇
- hive中的lateral view 用法详解下篇
- Hive--行转列(Lateral View explode())和列转行(collect_set() 去重)
- Hive Lateral view介绍
- 有趣的算法问题10——最后一个单词的长度
- TCP首部的URG与PSH及其区别
- 酷我音乐前端面试
- 【HDU】3586 Information Disturbing 二分+树形dp
- git备忘录
- Lateral View用法 与 Hive UDTF explode
- hibernate对象的三种状态以及他们之间的转换
- org.apache.hadoop.mapred.YarnChild: GC overhead limit
- bzoj 3208: 花神的秒题计划Ⅰ
- 从源码编译Cloudera CDH 5.7.1的Spark2.1.1
- [并查集]BZOJ 1050——[HAOI2006]旅行comf
- Spring MVC通过CROS协议解决跨域问题
- 学习一门语言的三个技巧
- PAT (Advanced Level) Practise 1103 Integer Factorization (30)