fix: ArrayInsert evaluation for null source arrays#4726
Conversation
…o handle-null-array-insert
|
sorry let me fix the test error. |
|
Nice fix. The short-circuit logic matches Spark's One suggestion on test coverage. The new statement
INSERT INTO test_array_insert_short_circuit VALUES
(NULL, 0),
(array(1), 1),
(array(1), 2)
query
SELECT array_insert(arr, CAST(NULL AS INT), element_at(array(1), idx))
FROM test_array_insert_short_circuitHere |
Which issue does this PR close?
No issue for this, relate to: #4716
Rationale for this change
Comet previously evaluated all
ArrayInsertchildren for the full batch. This differed from Spark, which evaluates arguments left-to-right and does not evaluate the position or inserted item when the source array isNULL.What changes are included in this PR?
argument parsing logic in
array_insertbatch execution.How are these changes tested?
./mvnw test -Dsuites="org.apache.comet.CometSqlFileTestSuite array_prepend" -Dtest=none./mvnw test -Dsuites="org.apache.comet.CometSqlFileTestSuite array_insert" -Dtest=none