This is an automated email from the ASF dual-hosted git repository.
Mryange pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 60b0d46dbe3 [fix](function) fix map_contains_entry runtime error when
TIMESTAMPTZ is map key or value (#63124)
60b0d46dbe3 is described below
commit 60b0d46dbe3f875939a7132bd354c22fcfb3133f
Author: Mryange <[email protected]>
AuthorDate: Fri May 15 16:08:54 2026 +0800
[fix](function) fix map_contains_entry runtime error when TIMESTAMPTZ is
map key or value (#63124)
### What problem does this PR solve?
Issue Number: N/A
Problem Summary: `map_contains_entry` throws a `RUNTIME_ERROR` at BE
execution time when the MAP column has `TIMESTAMPTZ` as its key or value
type. Root cause:
`FunctionMapContainsEntry::is_equality_comparison_supported` hard-coded
a list of accepted primitive types (`is_date_type`, `is_time_type`,
`is_number`, `is_string_type`, `is_ip`) but omitted `TYPE_TIMESTAMPTZ`.
As a result, the pre-execution type guard always rejected TIMESTAMPTZ
even though the underlying `dispatch_switch_all` +
`ColumnVector::compare_at` path supports it correctly. The fix replaces
the hand-maintained list with a direct call to `dispatch_switch_all`,
which already covers TIMESTAMPTZ in its `DATETIME` branch, making the
guard consistent with the actual dispatch layer.
---
be/src/exprs/function/function_map.cpp | 7 +-
.../test_timestamptz_map_contains_entry.out | 43 ++++++
.../test_timestamptz_map_contains_entry.groovy | 155 +++++++++++++++++++++
3 files changed, 202 insertions(+), 3 deletions(-)
diff --git a/be/src/exprs/function/function_map.cpp
b/be/src/exprs/function/function_map.cpp
index 0c9898b968c..cff3c1ba0f8 100644
--- a/be/src/exprs/function/function_map.cpp
+++ b/be/src/exprs/function/function_map.cpp
@@ -759,10 +759,11 @@ private:
/*nan_direction_hint=*/1) == 0;
}
- // whether this function supports equality comparison for the given
primitive type
+ // whether this function supports equality comparison for the given
primitive type.
+ // Uses dispatch_switch_all as the single source of truth so any type
supported
+ // by the dispatch layer is automatically accepted here.
bool is_equality_comparison_supported(PrimitiveType type) const {
- return is_string_type(type) || is_number(type) || is_date_type(type) ||
- is_time_type(type) || is_ip(type);
+ return dispatch_switch_all(type, [](const auto&) { return true; });
}
};
diff --git
a/regression-test/data/datatype_p0/timestamptz/test_timestamptz_map_contains_entry.out
b/regression-test/data/datatype_p0/timestamptz/test_timestamptz_map_contains_entry.out
new file mode 100644
index 00000000000..43746eee180
--- /dev/null
+++
b/regression-test/data/datatype_p0/timestamptz/test_timestamptz_map_contains_entry.out
@@ -0,0 +1,43 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !value_hit --
+true
+
+-- !value_miss --
+false
+
+-- !value_miss_key --
+false
+
+-- !key_hit --
+true
+
+-- !key_miss_value --
+false
+
+-- !key_miss_key --
+false
+
+-- !table_value_hit --
+1 true
+2 false
+
+-- !table_value_miss --
+1 false
+2 false
+
+-- !table_key_hit --
+1 true
+2 false
+
+-- !table_key_miss --
+1 false
+2 false
+
+-- !null_search_key --
+1 false
+2 false
+
+-- !null_search_value --
+1 false
+2 false
+
diff --git
a/regression-test/suites/datatype_p0/timestamptz/test_timestamptz_map_contains_entry.groovy
b/regression-test/suites/datatype_p0/timestamptz/test_timestamptz_map_contains_entry.groovy
new file mode 100644
index 00000000000..2b814ef8b6e
--- /dev/null
+++
b/regression-test/suites/datatype_p0/timestamptz/test_timestamptz_map_contains_entry.groovy
@@ -0,0 +1,155 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_timestamptz_map_contains_entry") {
+
+ sql "set time_zone = '+08:00';"
+ sql "set enable_nereids_planner = true;"
+ sql "set enable_fallback_to_original_planner = false;"
+
+ // --- inline literal tests (no table needed) ---
+
+ // TIMESTAMPTZ as map value: hit
+ qt_value_hit """
+ SELECT map_contains_entry(
+ map('a', cast('2024-01-01 00:00:00.000000 +00:00' as
timestamptz(6)),
+ 'b', cast('2024-01-02 03:04:05.123456 +00:00' as
timestamptz(6))),
+ 'a',
+ cast('2024-01-01 00:00:00.000000 +00:00' as timestamptz(6))
+ );
+ """
+
+ // TIMESTAMPTZ as map value: miss (wrong value)
+ qt_value_miss """
+ SELECT map_contains_entry(
+ map('a', cast('2024-01-01 00:00:00.000000 +00:00' as
timestamptz(6)),
+ 'b', cast('2024-01-02 03:04:05.123456 +00:00' as
timestamptz(6))),
+ 'a',
+ cast('2024-01-02 03:04:05.123456 +00:00' as timestamptz(6))
+ );
+ """
+
+ // TIMESTAMPTZ as map value: miss (wrong key)
+ qt_value_miss_key """
+ SELECT map_contains_entry(
+ map('a', cast('2024-01-01 00:00:00.000000 +00:00' as
timestamptz(6)),
+ 'b', cast('2024-01-02 03:04:05.123456 +00:00' as
timestamptz(6))),
+ 'c',
+ cast('2024-01-01 00:00:00.000000 +00:00' as timestamptz(6))
+ );
+ """
+
+ // TIMESTAMPTZ as map key: hit
+ qt_key_hit """
+ SELECT map_contains_entry(
+ map(cast('2024-01-01 00:00:00.000000 +00:00' as timestamptz(6)),
'a',
+ cast('2024-01-02 03:04:05.123456 +00:00' as timestamptz(6)),
'b'),
+ cast('2024-01-01 00:00:00.000000 +00:00' as timestamptz(6)),
+ 'a'
+ );
+ """
+
+ // TIMESTAMPTZ as map key: miss (wrong value)
+ qt_key_miss_value """
+ SELECT map_contains_entry(
+ map(cast('2024-01-01 00:00:00.000000 +00:00' as timestamptz(6)),
'a',
+ cast('2024-01-02 03:04:05.123456 +00:00' as timestamptz(6)),
'b'),
+ cast('2024-01-01 00:00:00.000000 +00:00' as timestamptz(6)),
+ 'b'
+ );
+ """
+
+ // TIMESTAMPTZ as map key: miss (wrong key)
+ qt_key_miss_key """
+ SELECT map_contains_entry(
+ map(cast('2024-01-01 00:00:00.000000 +00:00' as timestamptz(6)),
'a',
+ cast('2024-01-02 03:04:05.123456 +00:00' as timestamptz(6)),
'b'),
+ cast('2024-01-03 00:00:00.000000 +00:00' as timestamptz(6)),
+ 'a'
+ );
+ """
+
+ // --- table-based tests ---
+
+ sql "DROP TABLE IF EXISTS test_timestamptz_map_contains_entry_t;"
+ sql """
+ CREATE TABLE test_timestamptz_map_contains_entry_t (
+ id INT,
+ map_s_tz MAP<STRING, TIMESTAMPTZ(6)>,
+ map_tz_s MAP<TIMESTAMPTZ(6), STRING>
+ )
+ DUPLICATE KEY(id)
+ DISTRIBUTED BY HASH(id) BUCKETS 1
+ PROPERTIES("replication_num" = "1");
+ """
+
+ sql """
+ INSERT INTO test_timestamptz_map_contains_entry_t VALUES (
+ 1,
+ map('a', cast('2024-01-01 00:00:00.000000 +00:00' as
timestamptz(6)),
+ 'b', cast('2024-01-02 03:04:05.123456 +00:00' as
timestamptz(6))),
+ map(cast('2024-01-01 00:00:00.000000 +00:00' as timestamptz(6)),
'a',
+ cast('2024-01-02 03:04:05.123456 +00:00' as timestamptz(6)),
'b')
+ ), (
+ 2,
+ map('x', cast('2024-06-15 12:00:00.000000 +05:30' as
timestamptz(6))),
+ map(cast('2024-06-15 12:00:00.000000 +05:30' as timestamptz(6)),
'x')
+ );
+ """
+
+ // TIMESTAMPTZ as map value, hit
+ qt_table_value_hit """
+ SELECT id, map_contains_entry(map_s_tz, 'a', cast('2024-01-01
00:00:00.000000 +00:00' as timestamptz(6)))
+ FROM test_timestamptz_map_contains_entry_t
+ ORDER BY id;
+ """
+
+ // TIMESTAMPTZ as map value, miss
+ qt_table_value_miss """
+ SELECT id, map_contains_entry(map_s_tz, 'a', cast('2024-01-02
03:04:05.123456 +00:00' as timestamptz(6)))
+ FROM test_timestamptz_map_contains_entry_t
+ ORDER BY id;
+ """
+
+ // TIMESTAMPTZ as map key, hit
+ qt_table_key_hit """
+ SELECT id, map_contains_entry(map_tz_s, cast('2024-01-01
00:00:00.000000 +00:00' as timestamptz(6)), 'a')
+ FROM test_timestamptz_map_contains_entry_t
+ ORDER BY id;
+ """
+
+ // TIMESTAMPTZ as map key, miss
+ qt_table_key_miss """
+ SELECT id, map_contains_entry(map_tz_s, cast('2024-01-01
00:00:00.000000 +00:00' as timestamptz(6)), 'b')
+ FROM test_timestamptz_map_contains_entry_t
+ ORDER BY id;
+ """
+
+ // NULL search key
+ qt_null_search_key """
+ SELECT id, map_contains_entry(map_s_tz, NULL, cast('2024-01-01
00:00:00.000000 +00:00' as timestamptz(6)))
+ FROM test_timestamptz_map_contains_entry_t
+ ORDER BY id;
+ """
+
+ // NULL search value
+ qt_null_search_value """
+ SELECT id, map_contains_entry(map_s_tz, 'a', cast(NULL as
timestamptz(6)))
+ FROM test_timestamptz_map_contains_entry_t
+ ORDER BY id;
+ """
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]