|
| 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 | +-- Tests that str_to_map falls back to Spark when |
| 19 | +-- spark.sql.legacy.truncateForEmptyRegexSplit is enabled. In legacy mode Spark truncates trailing |
| 20 | +-- empty entries from the split result, which Comet's native str_to_map does not honour. |
| 21 | +-- See https://github.com/apache/datafusion-comet/issues/4477 |
| 22 | + |
| 23 | +-- Config: spark.sql.legacy.truncateForEmptyRegexSplit=true |
| 24 | + |
| 25 | +-- trailing pair delimiter: legacy mode truncates the trailing empty entry, so Comet must fall |
| 26 | +-- back to Spark |
| 27 | +query expect_fallback(truncateForEmptyRegexSplit) |
| 28 | +SELECT str_to_map('a:1,b:2,', ',', ':') |
| 29 | + |
| 30 | +-- column input also falls back |
| 31 | +statement |
| 32 | +CREATE TABLE test_str_to_map_legacy(s STRING, pair_delim STRING, key_value_delim STRING) USING parquet |
| 33 | + |
| 34 | +statement |
| 35 | +INSERT INTO test_str_to_map_legacy VALUES |
| 36 | + ('a:1,b:2,', ',', ':'), |
| 37 | + ('x:1;y:2;', ';', ':'), |
| 38 | + (NULL, ',', ':') |
| 39 | + |
| 40 | +query expect_fallback(truncateForEmptyRegexSplit) |
| 41 | +SELECT str_to_map(s, pair_delim, key_value_delim) FROM test_str_to_map_legacy |
0 commit comments