OIiveirra commented on code in PR #71331:
URL: https://github.com/apache/doris/pull/71331#discussion_r4781406052


##########
regression-test/suites/external_table_p0/iceberg/test_iceberg_low_cardinality_partial_agg.groovy:
##########
@@ -0,0 +1,70 @@
+// 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_iceberg_low_cardinality_partial_agg", 
"p0,external,doris,external_docker,external_docker_doris") {
+    if 
(!"true".equalsIgnoreCase(context.config.otherConfigs.get("enableIcebergTest")))
 {
+        return
+    }
+
+    def catalog = "iceberg_partial_agg_test"
+    def db = "partial_agg_test"
+    def host = context.config.otherConfigs.get("externalEnvIp")
+    def restPort = context.config.otherConfigs.get("iceberg_rest_uri_port")
+    def s3Port = context.config.otherConfigs.get("iceberg_minio_port")
+    sql "drop catalog if exists ${catalog}"
+    sql """create catalog ${catalog} properties (
+        'type'='iceberg', 'iceberg.catalog.type'='rest', 
'uri'='http://${host}:${restPort}',
+        's3.access_key'='admin', 's3.secret_key'='password', 
's3.region'='us-east-1',
+        's3.endpoint'='http://${host}:${s3Port}')"""
+    try {
+        sql "create database if not exists ${catalog}.${db}"
+        sql "use ${catalog}.${db}"
+        sql "drop table if exists partial_groups"
+        sql "create table partial_groups (k1 string, k2 string, amount 
decimal(10,2))"
+        // Each file spans multiple scan blocks and contains every grouping 
key.
+        4.times { batch ->
+            sql """insert into partial_groups
+                select if(number % 2 = 0, 'A', 'B'), if(number % 4 < 2, 'X', 
'Y'),
+                       cast(number % 4 + 1 + ${batch} as decimal(10,2))
+                from numbers("number" = "32768")"""
+        }
+        sql "analyze table partial_groups with sync"
+
+        def query = { forceHash -> """select /*+ 
SET_VAR(enable_local_shuffle_planner=true,
+                enable_local_shuffle=true, parallel_pipeline_task_num=4,
+                enable_external_table_batch_mode=true, 
num_files_in_batch_mode=1,
+                disable_streaming_preaggregations=false, 
enable_bucketed_hash_agg=false,
+                use_serial_exchange=false, 
enable_local_exchange_before_streaming_agg=${forceHash}) */
+                k1, k2, sum(amount), avg(amount), count(*) from partial_groups
+                group by k1, k2 order by k1, k2""" }
+        def expected = [["A", "X", 81920.00G, 2.5000G, 32768L], ["A", "Y", 
147456.00G, 4.5000G, 32768L],
+                        ["B", "X", 114688.00G, 3.5000G, 32768L], ["B", "Y", 
180224.00G, 5.5000G, 32768L]]
+        [false, true].each { forceHash ->
+            def statement = query(forceHash)
+            def plan = sql("explain distributed plan ${statement}").collect { 
it[0] }.join("\n")
+            // Only the immediate child of the partial aggregate determines 
its distribution.
+            def exchange = plan =~ /(?m)^\s*\d+:VAGGREGATE \(update 
serialize\)[^\n]*\n(?:\s*\|[^\n]*\n)*\s*\d+:VLOCAL-EXCHANGE\s*\n\s*\|\s*type: 
(\w+)/
+            assertTrue(exchange.find(), plan)
+            assertEquals(forceHash ? "LOCAL_EXECUTION_HASH_SHUFFLE" : 
"PASSTHROUGH", exchange.group(1))
+            assertEquals(expected, sql(statement))

Review Comment:
   Addressed in 89d2c4c0f31. Both ordered queries now use named qt checks with 
a generated golden file. The distributed-plan assertions are retained. 
Generation and normal-mode comparison passed.



##########
regression-test/suites/external_table_p0/iceberg/test_iceberg_low_cardinality_partial_agg.groovy:
##########
@@ -0,0 +1,70 @@
+// 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_iceberg_low_cardinality_partial_agg", 
"p0,external,doris,external_docker,external_docker_doris") {
+    if 
(!"true".equalsIgnoreCase(context.config.otherConfigs.get("enableIcebergTest")))
 {
+        return
+    }
+
+    def catalog = "iceberg_partial_agg_test"
+    def db = "partial_agg_test"
+    def host = context.config.otherConfigs.get("externalEnvIp")
+    def restPort = context.config.otherConfigs.get("iceberg_rest_uri_port")
+    def s3Port = context.config.otherConfigs.get("iceberg_minio_port")
+    sql "drop catalog if exists ${catalog}"
+    sql """create catalog ${catalog} properties (
+        'type'='iceberg', 'iceberg.catalog.type'='rest', 
'uri'='http://${host}:${restPort}',
+        's3.access_key'='admin', 's3.secret_key'='password', 
's3.region'='us-east-1',
+        's3.endpoint'='http://${host}:${s3Port}')"""
+    try {
+        sql "create database if not exists ${catalog}.${db}"
+        sql "use ${catalog}.${db}"
+        sql "drop table if exists partial_groups"
+        sql "create table partial_groups (k1 string, k2 string, amount 
decimal(10,2))"
+        // Each file spans multiple scan blocks and contains every grouping 
key.
+        4.times { batch ->
+            sql """insert into partial_groups
+                select if(number % 2 = 0, 'A', 'B'), if(number % 4 < 2, 'X', 
'Y'),
+                       cast(number % 4 + 1 + ${batch} as decimal(10,2))
+                from numbers("number" = "32768")"""
+        }
+        sql "analyze table partial_groups with sync"
+
+        def query = { forceHash -> """select /*+ 
SET_VAR(enable_local_shuffle_planner=true,
+                enable_local_shuffle=true, parallel_pipeline_task_num=4,
+                enable_external_table_batch_mode=true, 
num_files_in_batch_mode=1,
+                disable_streaming_preaggregations=false, 
enable_bucketed_hash_agg=false,
+                use_serial_exchange=false, 
enable_local_exchange_before_streaming_agg=${forceHash}) */
+                k1, k2, sum(amount), avg(amount), count(*) from partial_groups
+                group by k1, k2 order by k1, k2""" }
+        def expected = [["A", "X", 81920.00G, 2.5000G, 32768L], ["A", "Y", 
147456.00G, 4.5000G, 32768L],
+                        ["B", "X", 114688.00G, 3.5000G, 32768L], ["B", "Y", 
180224.00G, 5.5000G, 32768L]]
+        [false, true].each { forceHash ->
+            def statement = query(forceHash)
+            def plan = sql("explain distributed plan ${statement}").collect { 
it[0] }.join("\n")
+            // Only the immediate child of the partial aggregate determines 
its distribution.
+            def exchange = plan =~ /(?m)^\s*\d+:VAGGREGATE \(update 
serialize\)[^\n]*\n(?:\s*\|[^\n]*\n)*\s*\d+:VLOCAL-EXCHANGE\s*\n\s*\|\s*type: 
(\w+)/
+            assertTrue(exchange.find(), plan)
+            assertEquals(forceHash ? "LOCAL_EXECUTION_HASH_SHUFFLE" : 
"PASSTHROUGH", exchange.group(1))
+            assertEquals(expected, sql(statement))
+        }
+    } finally {
+        sql "drop table if exists ${catalog}.${db}.partial_groups"

Review Comment:
   Addressed in 89d2c4c0f31. The suite recreates the fixture before testing and 
leaves the analyzed table available afterwards. Verified that all 131,072 rows 
remained after normal-mode execution.



-- 
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]

Reply via email to