sandeep-katta commented on code in PR #38874:
URL: https://github.com/apache/spark/pull/38874#discussion_r1045464676
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala:
##########
@@ -4600,3 +4600,30 @@ case class ArrayExcept(left: Expression, right:
Expression) extends ArrayBinaryL
override protected def withNewChildrenInternal(
newLeft: Expression, newRight: Expression): ArrayExcept = copy(left =
newLeft, right = newRight)
}
+
+@ExpressionDescription(
+ usage = "_FUNC_(array) - Removes null values from the array.",
+ examples = """
+ Examples:
+ > SELECT _FUNC_(array(1, 2, 3, null));
+ [1,2,3]
+ """,
+ group = "array_funcs",
+ since = "3.4.0")
+case class ArrayCompact(child: Expression)
+ extends RuntimeReplaceable with UnaryLike[Expression] with ExpectsInputTypes
with NullIntolerant {
Review Comment:
I tried to extend `InheritAnalysisRules` but my tests are failing with the
below exception, not sure what is the mistake I am doing here. Could you guide
me hear please ?
```
Max iterations (100) reached for batch Resolution, please set
'spark.sql.analyzer.maxIterations' to a larger value.
java.lang.RuntimeException: Max iterations (100) reached for batch
Resolution, please set 'spark.sql.analyzer.maxIterations' to a larger value.
```
Updated Code:
```
case class ArrayCompact(expr: Expression)
extends RuntimeReplaceable with InheritAnalysisRules {
lazy val isNotNull: Expression => Expression = x => IsNotNull(x)
lazy val lv =
UnresolvedNamedLambdaVariable(Seq(UnresolvedNamedLambdaVariable.freshVarName("x")))
lazy val lambda = LambdaFunction(isNotNull(lv), Seq(lv))
lazy override val replacement: Expression = ArrayFilter(expr, lambda)
override def parameters: Seq[Expression] = Seq(expr)
override def prettyName: String = "array_compact"
override protected def withNewChildInternal(newChild: Expression):
ArrayCompact =
copy(expr = newChild)
}
```
--
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]