|
| 1 | +-- Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +-- or more contributor license agreements. See the NOTICE file |
| 3 | +-- distributed with this work for additional information |
| 4 | +-- regarding copyright ownership. The ASF licenses this file |
| 5 | +-- to you under the Apache License, Version 2.0 (the |
| 6 | +-- "License"); you may not use this file except in compliance |
| 7 | +-- with the License. You may obtain a copy of the License at |
| 8 | +-- |
| 9 | +-- http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +-- |
| 11 | +-- Unless required by applicable law or agreed to in writing, |
| 12 | +-- software distributed under the License is distributed on an |
| 13 | +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +-- KIND, either express or implied. See the License for the |
| 15 | +-- specific language governing permissions and limitations |
| 16 | +-- under the License. |
| 17 | + |
| 18 | +-- The queries of array_null_short_circuit.sql with ANSI off. A cast of a malformed string then |
| 19 | +-- returns NULL instead of raising, so the cast queries match Spark however the arguments are |
| 20 | +-- evaluated, and the native planner drops the guard for them. A start of 0 still makes slice raise, |
| 21 | +-- and a nondeterministic argument still advances on every row it sees, so those two shapes depend on |
| 22 | +-- skipping the rows whose array is NULL in every mode. |
| 23 | +-- https://github.com/apache/datafusion-comet/issues/6613 |
| 24 | + |
| 25 | +-- Config: spark.sql.ansi.enabled=false |
| 26 | + |
| 27 | +statement |
| 28 | +CREATE TABLE array_null_short_circuit_non_ansi(ai array<int>, s string, i string) USING parquet |
| 29 | + |
| 30 | +statement |
| 31 | +INSERT INTO array_null_short_circuit_non_ansi SELECT /*+ COALESCE(1) */ * FROM VALUES |
| 32 | + (NULL, 'bad', 'bad'), |
| 33 | + (array(1, 2), '2', '1'), |
| 34 | + (array(3), '7', '0'), |
| 35 | + (NULL, 'worse', 'worse'), |
| 36 | + (array(4, NULL, 5), '5', '2') |
| 37 | + AS v(ai, s, i) |
| 38 | + |
| 39 | +query expect_native(array_contains) |
| 40 | +SELECT array_contains(ai, CAST(s AS INT)) FROM array_null_short_circuit_non_ansi |
| 41 | + |
| 42 | +query expect_native(array_position) |
| 43 | +SELECT array_position(ai, CAST(s AS INT)) FROM array_null_short_circuit_non_ansi |
| 44 | + |
| 45 | +query expect_native(array_remove) |
| 46 | +SELECT array_remove(ai, CAST(s AS INT)) FROM array_null_short_circuit_non_ansi |
| 47 | + |
| 48 | +query expect_native(arrays_overlap) |
| 49 | +SELECT arrays_overlap(ai, array(CAST(s AS INT))) FROM array_null_short_circuit_non_ansi |
| 50 | + |
| 51 | +query expect_native(array_union) |
| 52 | +SELECT array_union(ai, array(CAST(s AS INT))) FROM array_null_short_circuit_non_ansi |
| 53 | + |
| 54 | +query expect_native(slice) |
| 55 | +SELECT slice(ai, CAST(s AS INT), 1), slice(ai, 1, CAST(i AS INT)) FROM array_null_short_circuit_non_ansi |
| 56 | + |
| 57 | +query expect_native(getarrayitem) |
| 58 | +SELECT ai[CAST(i AS INT)] FROM array_null_short_circuit_non_ansi |
| 59 | + |
| 60 | +-- A start of 0 makes slice raise in any mode, and only rows whose array is NULL have one |
| 61 | +query expect_native(array_union) |
| 62 | +SELECT array_union(ai, slice(array(1), IF(ai IS NULL, 0, 1), 1)) FROM array_null_short_circuit_non_ansi |
| 63 | + |
| 64 | +-- A nondeterministic argument sees the same rows as in Spark, so it returns the same values |
| 65 | +query expect_native(array_position) |
| 66 | +SELECT array_position(ai, CAST(rand(7L) * 3 AS INT)) FROM array_null_short_circuit_non_ansi |
0 commit comments