allisonwang-db commented on code in PR #42020:
URL: https://github.com/apache/spark/pull/42020#discussion_r1265639489
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/generators.scala:
##########
@@ -421,16 +435,60 @@ abstract class ExplodeBase extends UnaryExpression with
CollectionGenerator with
> SELECT _FUNC_(array(10, 20));
10
20
+ > SELECT _FUNC_(collection => array(10, 20));
+ 10
+ 20
""",
since = "1.0.0",
group = "generator_funcs")
// scalastyle:on line.size.limit
-case class Explode(child: Expression) extends ExplodeBase {
- override val position: Boolean = false
- override protected def withNewChildInternal(newChild: Expression): Explode =
- copy(child = newChild)
+object ExplodeExpressionBuilder extends ExpressionBuilder {
+ override def functionSignature: Option[FunctionSignature] =
+ Some(FunctionSignature(Seq(NamedArgument("collection"))))
+
+ override def build(funcName: String, expressions: Seq[Expression]) :
Expression =
+ Explode(expressions(0))
+}
+
+// scalastyle:off line.size.limit
+@ExpressionDescription(
+ usage = "_FUNC_(expr) - Separates the elements of array `expr` into multiple
rows, or the elements of map `expr` into multiple rows and columns. Unless
specified otherwise, uses the default column name `col` for elements of the
array or `key` and `value` for the elements of the map.",
+ examples = """
+ Examples:
+ > SELECT _FUNC_(array(10, 20));
+ 10
+ 20
+ > SELECT _FUNC_(collection => array(10, 20));
+ 10
+ 20
+ """,
+ since = "1.0.0",
+ group = "generator_funcs")
+// scalastyle:on line.size.limit
+object ExplodeGeneratorBuilder extends ExplodeGeneratorBuilderBase {
+ override def isOuter: Boolean = false
+}
+
+// scalastyle:off line.size.limit
+@ExpressionDescription(
+ usage = "_FUNC_(expr) - Separates the elements of array `expr` into multiple
rows, or the elements of map `expr` into multiple rows and columns. Unless
specified otherwise, uses the default column name `col` for elements of the
array or `key` and `value` for the elements of the map.",
+ examples = """
+ Examples:
+ > SELECT _FUNC_(array(10, 20));
+ 10
+ 20
+ > SELECT _FUNC_(collection => array(10, 20));
Review Comment:
Can we also add one example for `pos_explode`?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]