问题描述
爆炸和 explode_outer ?这两个函数的文档是相同的,并且两个函数的示例是相同的:
What is the difference between explode and explode_outer? The documentation for both functions is the same and also the examples for both functions are identical:
SELECT explode(array(10, 20));
10
20
和
SELECT explode_outer(array(10, 20));
10
20
火花源表明这两个功能之间存在差异
The Spark source suggests that there is a difference between the two functions
expression[Explode]("explode"),
expressionGeneratorOuter[Explode]("explode_outer")
但是 expressionGeneratorOuter 与表达式?
推荐答案
爆炸
通过忽略数组中的空值或空值为数组或映射列中的每个元素创建一行,而 explode_outer
返回数组或映射中的所有值,包括null或空.
explode
creates a row for each element in the array or map column by ignoring null or empty values in array whereas explode_outer
returns all values in array or map including null or empty.
例如,对于以下数据框-
For example, for the following dataframe-
id | name | likes
_______________________________
1 | Luke | [baseball, soccer]
2 | Lucy | null
爆炸
提供以下输出-
id | name | likes
_______________________________
1 | Luke | baseball
1 | Luke | soccer
explode_outer
提供以下输出-
id | name | likes
_______________________________
1 | Luke | baseball
1 | Luke | soccer
2 | Lucy | null
SELECT explode(col1) from values (array(10,20)), (null)
返回
+---+
|col|
+---+
| 10|
| 20|
+---+
同时
SELECT explode_outer(col1) from values (array(10,20)), (null)
返回
+----+
| col|
+----+
| 10|
| 20|
|null|
+----+
这篇关于explode和explode_outer之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!