github-actions[bot] commented on code in PR #67154: URL: https://github.com/apache/doris/pull/67154#discussion_r3870593918
########## regression-test/suites/nereids_function_p0/agg_function/nereids_agg_fn_map_decimal_precision.groovy: ########## @@ -0,0 +1,59 @@ +// 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. + +// map_agg/map_agg_v2 expose their MAP key/value as independent top-level Any(0)/Any(1) +// arguments. The default decimal v3 precision promotion must keep those logical groups +// independent: merging them into one wider type would widen the DECIMAL(38,0) key to a +// scale that cannot hold a 38-digit integral key (so the entry disappears as a NULL key) +// and truncate twelve fractional digits from the DECIMAL(38,18) value before aggregation. +suite("nereids_agg_fn_map_decimal_precision") { + sql "set enable_nereids_planner=true" + sql "set enable_fallback_to_original_planner=false" + + sql "drop table if exists map_agg_dec_precision" + sql """ + create table map_agg_dec_precision ( + g int, + k decimal(38, 0), + v decimal(38, 18) + ) + duplicate key(g) + distributed by hash(g) buckets 1 + properties("replication_num" = "1") + """ + sql """ + insert into map_agg_dec_precision values + (1, 99999999999999999999999999999999999999, 0.125000000000000000), + (2, 12345678901234567890123456789012345678, 2.000000000000000001), + (2, 12345678901234567890123456789012345678, 3.000000000000000000) + """ + + // the 38-digit integral key must be preserved, and the value must keep all 18 + // fractional digits + order_qt_map_agg_decimal_precision """ + select map_agg(k, v) from map_agg_dec_precision where g = 1; + """ + + order_qt_map_agg_v2_decimal_precision """ + select map_agg_v2(k, v) from map_agg_dec_precision where g = 1; + """ + + // duplicate keys are overwritten by the last value, still without precision loss + order_qt_map_agg_group_by_decimal_precision """ + select g, map_agg(k, v) from map_agg_dec_precision group by g order by g; Review Comment: [P2] Do not assert an unordered duplicate-key winner Both MAP aggregate implementations keep the first duplicate they encounter, including during partial-state merges; they do not overwrite with the last value. This query supplies no aggregate input/merge order (`ORDER BY g` only orders result rows), yet the expected file requires the `3.000...` value for the duplicated key. That winner can change with scan or merge order. Please use unique keys for this precision regression, or otherwise avoid asserting a specific duplicate winner. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
