sandeep-katta commented on code in PR #38874:
URL: https://github.com/apache/spark/pull/38874#discussion_r1047086983
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala:
##########
@@ -4600,3 +4600,40 @@ 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(expr: Expression, replacement: Expression)
+ extends RuntimeReplaceable with InheritAnalysisRules {
+
+ def this(expr: Expression) = this(expr,
+ ArrayFilter(expr, ArrayCompact.createLambdaExpr()))
+
+ override def parameters: Seq[Expression] = Seq.empty
Review Comment:
FYI, even with this suggested change we still get `Cannot resolve "filter(a,
lambdafunction((x_0 IS NOT NULL), x_0))"` error. The only difference I am
seeing is in `Project` node
Seq.empty
```
[DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE] Cannot resolve "filter(a,
lambdafunction((x_0 IS NOT NULL), x_0))" due to data type mismatch: Parameter 1
requires the "ARRAY" type, however "a" has the type "INT".;
'Project [unresolvedalias(array_compact(),
Some(org.apache.spark.sql.Column$$Lambda$1642/1906635841@124eb83d))]
+- Project [value#1 AS a#4]
+- LocalRelation [value#1]
```
Seq(expr)
```
[DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE] Cannot resolve "filter(a,
lambdafunction((x_0 IS NOT NULL), x_0))" due to data type mismatch: Parameter 1
requires the "ARRAY" type, however "a" has the type "INT".;
'Project [unresolvedalias(array_compact('a),
Some(org.apache.spark.sql.Column$$Lambda$1642/48143526@7741ae1b))]
+- Project [value#1 AS a#4]
+- LocalRelation [value#1]
```
--
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]