HyukjinKwon commented on a change in pull request #26279: [SPARK-28382][SQL]
Add array function - unnest
URL: https://github.com/apache/spark/pull/26279#discussion_r343881978
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/generators.scala
##########
@@ -343,6 +343,63 @@ abstract class ExplodeBase extends UnaryExpression with
CollectionGenerator with
}
}
+@ExpressionDescription(
+ usage = "_FUNC_(expr) - Separates the elements of array `expr` into multiple
rows recursively.",
+ examples = """
+ Examples:
+ > SELECT _FUNC_(array(10, 20));
+ 10
+ 20
+ > SELECT _FUNC_(a) FROM VALUES (array(1,2)), (array(3,4)) AS v1(a);
+ 1
+ 2
+ 3
+ 4
Review comment:
@yaooqinn given this examples, yes looks equivalent. How are they different
in this PR?
Can we reuse it or deduplicate the same logic?
```scala
scala> sql("select unnest(a) FROM VALUES (array(1,2)), (array(3,4)) AS
v1(a)").show()
+------+
|unnest|
+------+
| 1|
| 2|
| 3|
| 4|
+------+
scala> sql("select unnest(array(10, 20))").show()
+------+
|unnest|
+------+
| 10|
| 20|
+------+
scala> sql("select explode(a) FROM VALUES (array(1,2)), (array(3,4)) AS
v1(a)").show()
+---+
|col|
+---+
| 1|
| 2|
| 3|
| 4|
+---+
scala> sql("select explode(array(10, 20))").show()
+---+
|col|
+---+
| 10|
| 20|
+---+
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]