|
| 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 | +-- ConfigMatrix: parquet.enable.dictionary=false,true |
| 19 | + |
| 20 | +-- TODO: replace map_from_arrays with map whenever map is supported in Comet |
| 21 | + |
| 22 | +-- Basic integer key tests with map literals |
| 23 | +query |
| 24 | +select map_contains_key(map_from_arrays(array(1, 2), array('a', 'b')), 5) |
| 25 | + |
| 26 | +query |
| 27 | +select map_contains_key(map_from_arrays(array(1, 2), array('a', 'b')), 1) |
| 28 | + |
| 29 | +-- Decimal type coercion tests |
| 30 | +-- TODO: requires map cast to be supported in Comet |
| 31 | +query spark_answer_only |
| 32 | +select map_contains_key(map_from_arrays(array(1, 2), array('a', 'b')), 5.0) |
| 33 | + |
| 34 | +query spark_answer_only |
| 35 | +select map_contains_key(map_from_arrays(array(1, 2), array('a', 'b')), 1.0) |
| 36 | + |
| 37 | +query spark_answer_only |
| 38 | +select map_contains_key(map_from_arrays(array(1.0, 2), array('a', 'b')), 5) |
| 39 | + |
| 40 | +query spark_answer_only |
| 41 | +select map_contains_key(map_from_arrays(array(1.0, 2), array('a', 'b')), 1) |
| 42 | + |
| 43 | +-- Empty map tests |
| 44 | +-- TODO: requires casting from NullType to be supported in Comet |
| 45 | +query spark_answer_only |
| 46 | +select map_contains_key(map_from_arrays(array(), array()), 0) |
| 47 | + |
| 48 | +-- Test with table data |
| 49 | +statement |
| 50 | +CREATE TABLE test_map_contains_key(m map<string, int>) USING parquet |
| 51 | + |
| 52 | +statement |
| 53 | +INSERT INTO test_map_contains_key VALUES (map_from_arrays(array('a', 'b', 'c'), array(1, 2, 3))), (map_from_arrays(array('x'), array(10))), (map_from_arrays(array(), array())), (NULL) |
| 54 | + |
| 55 | +query |
| 56 | +SELECT map_contains_key(m, 'a') FROM test_map_contains_key |
| 57 | + |
| 58 | +query |
| 59 | +SELECT map_contains_key(m, 'x') FROM test_map_contains_key |
| 60 | + |
| 61 | +query |
| 62 | +SELECT map_contains_key(m, 'missing') FROM test_map_contains_key |
| 63 | + |
| 64 | +-- Test with integer key map |
| 65 | +statement |
| 66 | +CREATE TABLE test_map_int_key(m map<int, string>) USING parquet |
| 67 | + |
| 68 | +statement |
| 69 | +INSERT INTO test_map_int_key VALUES (map_from_arrays(array(1, 2), array('a', 'b'))), (map_from_arrays(array(), array())), (NULL) |
| 70 | + |
| 71 | +query |
| 72 | +SELECT map_contains_key(m, 1) FROM test_map_int_key |
| 73 | + |
| 74 | +query |
| 75 | +SELECT map_contains_key(m, 5) FROM test_map_int_key |
0 commit comments