Apache spark explode和explode_的区别

Apache spark explode和explode_的区别,apache-spark,apache-spark-sql,Apache Spark,Apache Spark Sql,和之间有什么区别?两个函数的文档相同,两个函数的示例也相同: 选择分解(数组(10,20)); 10 20 及 选择explode_outer(数组(10,20)); 10 20 这表明这两种功能之间存在差异 表达式[Explode](“Explode”), 表达式GeneratorOuter[爆炸](“爆炸外部”) 但是与比较的效果如何?explode通过忽略数组中的空值或空值,为数组或映射列中的每个元素创建一行,而explode\u outer返回数组或映射中的所有值,包括空值或空值

和之间有什么区别?两个函数的文档相同,两个函数的示例也相同:

选择分解(数组(10,20));
10
20

选择explode_outer(数组(10,20));
10
20
这表明这两种功能之间存在差异

表达式[Explode](“Explode”),
表达式GeneratorOuter[爆炸](“爆炸外部”)

但是与比较的效果如何?

explode
通过忽略数组中的空值或空值,为数组或映射列中的每个元素创建一行,而
explode\u outer
返回数组或映射中的所有值,包括空值或空值

例如,对于以下数据帧-

id | name | likes
_______________________________
1  | Luke | [baseball, soccer]
2  | Lucy | null
explode
给出以下输出-

id | name | likes
_______________________________
1  | Luke | baseball
1  | Luke | soccer
id | name | likes
_______________________________
1  | Luke | baseball
1  | Luke | soccer
2  | Lucy | null
explode\u outer
给出以下输出-

id | name | likes
_______________________________
1  | Luke | baseball
1  | Luke | soccer
id | name | likes
_______________________________
1  | Luke | baseball
1  | Luke | soccer
2  | Lucy | null

从值(数组(10,20)),(null)中选择分解(col1)
返回

+---+
|上校|
+---+
| 10|
| 20|
+---+

从值(数组(10,20)),(null)中选择explode_outer(col1)
返回

+----+
|上校|
+----+
|  10|
|  20|
|空的|
+----+

explode
通过忽略数组中的null或空值,为数组或映射列中的每个元素创建一行,而
explode\u outer
返回数组或映射中的所有值,包括null或空值

例如,对于以下数据帧-

id | name | likes
_______________________________
1  | Luke | [baseball, soccer]
2  | Lucy | null
explode
给出以下输出-

id | name | likes
_______________________________
1  | Luke | baseball
1  | Luke | soccer
id | name | likes
_______________________________
1  | Luke | baseball
1  | Luke | soccer
2  | Lucy | null
explode\u outer
给出以下输出-

id | name | likes
_______________________________
1  | Luke | baseball
1  | Luke | soccer
id | name | likes
_______________________________
1  | Luke | baseball
1  | Luke | soccer
2  | Lucy | null

从值(数组(10,20)),(null)中选择分解(col1)
返回

+---+
|上校|
+---+
| 10|
| 20|
+---+

从值(数组(10,20)),(null)中选择explode_outer(col1)
返回

+----+
|上校|
+----+
|  10|
|  20|
|空的|
+----+

谢谢您的回答,但我仍然不理解其中的区别。例如
选择explode(数组(10,20,null))
(带有null的数组)也会为这两个函数提供相同的结果。你有函数返回不同结果的例子吗?当然有。我在回答中添加了一个示例。添加一个显示这些函数用法的查询/代码示例会更好。谢谢您的回答,但我仍然不理解其中的区别。例如
选择explode(数组(10,20,null))
(带有null的数组)也会为这两个函数提供相同的结果。你有函数返回不同结果的例子吗?当然有。我在答案中添加了一个示例。添加一个显示这些函数用法的查询/代码示例会更好。