Skip to content

Commit 9052f2b

Browse files
authored
chore: reenable array_remove tests (#3917)
1 parent 4afd042 commit 9052f2b

File tree

5 files changed

+6
-41
lines changed

5 files changed

+6
-41
lines changed

docs/source/user-guide/latest/compatibility.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ the [Comet Supported Expressions Guide](expressions.md) for more information on
6060

6161
### Array Expressions
6262

63-
- **ArrayRemove**: Returns null when the element to remove is null, instead of removing null elements from the array.
64-
[#3173](https://github.com/apache/datafusion-comet/issues/3173)
6563
- **ArraysOverlap**: Inconsistent behavior when arrays contain NULL values.
6664
[#3645](https://github.com/apache/datafusion-comet/issues/3645),
6765
[#2036](https://github.com/apache/datafusion-comet/issues/2036)

docs/source/user-guide/latest/expressions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ Comet supports using the following aggregate functions within window contexts wi
243243
| ArrayJoin | No | |
244244
| ArrayMax | Yes | |
245245
| ArrayMin | Yes | |
246-
| ArrayRemove | No | Returns null when element is null instead of removing null elements ([#3173](https://github.com/apache/datafusion-comet/issues/3173)) |
246+
| ArrayRemove | Yes | |
247247
| ArrayRepeat | No | |
248248
| ArrayUnion | No | Behaves differently than spark. Comet sorts the input arrays before performing the union, while Spark preserves the order of the first array and appends unique elements from the second. |
249249
| ArraysOverlap | No | |

spark/src/main/scala/org/apache/comet/serde/arrays.scala

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ object CometArrayRemove
3535
with CometExprShim
3636
with ArraysBase {
3737

38-
override def getSupportLevel(expr: ArrayRemove): SupportLevel =
39-
Incompatible(
40-
Some(
41-
"Returns null when element is null instead of removing null elements" +
42-
" (https://github.com/apache/datafusion-comet/issues/3173)"))
43-
4438
override def convert(
4539
expr: ArrayRemove,
4640
inputs: Seq[Attribute],
@@ -55,34 +49,7 @@ object CometArrayRemove
5549
val arrayExprProto = exprToProto(expr.left, inputs, binding)
5650
val keyExprProto = exprToProto(expr.right, inputs, binding)
5751

58-
val arrayRemoveScalarExpr =
59-
scalarFunctionExprToProto("array_remove_all", arrayExprProto, keyExprProto)
60-
61-
val isNotNullExpr = createUnaryExpr(
62-
expr,
63-
expr.right,
64-
inputs,
65-
binding,
66-
(builder, unaryExpr) => builder.setIsNotNull(unaryExpr))
67-
68-
val nullLiteralProto = exprToProto(Literal(null, expr.right.dataType), Seq.empty)
69-
70-
if (arrayRemoveScalarExpr.isDefined && isNotNullExpr.isDefined && nullLiteralProto.isDefined) {
71-
val caseWhenExpr = ExprOuterClass.CaseWhen
72-
.newBuilder()
73-
.addWhen(isNotNullExpr.get)
74-
.addThen(arrayRemoveScalarExpr.get)
75-
.setElseExpr(nullLiteralProto.get)
76-
.build()
77-
Some(
78-
ExprOuterClass.Expr
79-
.newBuilder()
80-
.setCaseWhen(caseWhenExpr)
81-
.build())
82-
} else {
83-
withInfo(expr, expr.children: _*)
84-
None
85-
}
52+
scalarFunctionExprToProto("array_remove_all", arrayExprProto, keyExprProto)
8653
}
8754
}
8855

spark/src/test/resources/sql-tests/expressions/array/array_remove.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ CREATE TABLE test_array_remove(arr array<int>, val int) USING parquet
2424
statement
2525
INSERT INTO test_array_remove VALUES (array(1, 2, 3, 2), 2), (array(1, 2, 3), 4), (array(), 1), (NULL, 1), (array(1, NULL, 3), NULL)
2626

27-
query spark_answer_only
27+
query
2828
SELECT array_remove(arr, val) FROM test_array_remove
2929

3030
-- column + literal
31-
query spark_answer_only
31+
query
3232
SELECT array_remove(arr, 2) FROM test_array_remove
3333

3434
-- literal + column
35-
query spark_answer_only
35+
query
3636
SELECT array_remove(array(1, 2, 3, 2), val) FROM test_array_remove
3737

3838
-- literal + literal

spark/src/test/scala/org/apache/comet/CometArrayExpressionSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class CometArrayExpressionSuite extends CometTestBase with AdaptiveSparkPlanHelp
137137
sql("SELECT array(struct(_1, _2)) as a, struct(_1, _2) as b FROM t1")
138138
.createOrReplaceTempView("t2")
139139
val expectedFallbackReason =
140-
"is not fully compatible with Spark"
140+
"data type not supported"
141141
checkSparkAnswerAndFallbackReason(
142142
sql("SELECT array_remove(a, b) FROM t2"),
143143
expectedFallbackReason)

0 commit comments

Comments
 (0)