Gabriel39 commented on code in PR #67979:
URL: https://github.com/apache/doris/pull/67979#discussion_r4011639832
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/AggregateStrategies.java:
##########
@@ -693,6 +693,15 @@ private LogicalAggregate<? extends Plan>
storageLayerAggregate(
return canNotPush;
}
+ // File MIN/MAX retains only source endpoints. A cast can turn both
endpoints into NULL
+ // while an interior value remains valid. Ignore source nullability
when checking the cast
+ // itself, so safe widening casts over nullable columns can still use
metadata.
+ if (logicalScan instanceof LogicalFileScan &&
argumentsOfAggregateFunction.stream()
+ .anyMatch(argument -> argument instanceof Cast
+ && Cast.castNullable(false,
argument.child(0).getDataType(), argument.getDataType()))) {
Review Comment:
Addressed in c96aa1efea and synchronized to #67980 (88cde1a419). MIN/MAX
metadata pushdown now rejects floating-source casts on both scan types. Unit
coverage includes DOUBLE-to-FLOAT and FLOAT-to-DOUBLE; the Paimon regression
also compares isnan(MAX(CAST(... AS FLOAT))) with pushdown on/off. Both
branches pass the targeted FE tests and Checkstyle. End-to-end execution
remains unverified because the local FE connection was refused; CI has been
retriggered.
##########
regression-test/suites/external_table_p0/paimon/test_paimon_minmax_cast.groovy:
##########
@@ -0,0 +1,97 @@
+// 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_paimon_minmax_cast",
"p0,external,paimon,external_docker,external_docker_paimon") {
+ String enabled = context.config.otherConfigs.get("enablePaimonTest")
+ if (enabled == null || !enabled.equalsIgnoreCase("true")) {
+ logger.info("Paimon test is disabled")
+ return
+ }
+
+ String catalogName = "test_paimon_minmax_cast"
+ String dbName = "paimon_minmax_cast_db"
+ String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
+ String minioPort = context.config.otherConfigs.get("iceberg_minio_port")
+ def originalSettings = ["enable_file_scanner_v2", "force_jni_scanner",
+ "enable_strict_cast",
"enable_push_down_no_group_agg"].collectEntries { name ->
+ [(name): sql("show variables like '${name}'")[0][1]]
+ }
+
+ try {
+ // A single writer and bucket keep both overflowing endpoints and the
valid interior value
+ // in one file. Separate files could let metadata aggregation retain
the interior value.
+ spark_paimon_multi """
+ create database if not exists paimon.${dbName};
+ drop table if exists paimon.${dbName}.minmax_cast;
+ create table paimon.${dbName}.minmax_cast (value bigint)
+ using paimon tblproperties (
+ 'bucket'='1',
+ 'bucket-key'='value',
+ 'file.format'='parquet'
+ );
+ insert into paimon.${dbName}.minmax_cast
+ select /*+ coalesce(1) */ value from values
+ (cast(-2147483649 as bigint)),
+ (cast(0 as bigint)),
+ (cast(2147483648 as bigint)) as data(value);
+ """
+
+ sql """drop catalog if exists ${catalogName}"""
+ sql """create catalog ${catalogName} properties (
+ 'type'='paimon',
+ 'warehouse'='s3://warehouse/wh',
+ 's3.endpoint'='http://${externalEnvIp}:${minioPort}',
+ 's3.access_key'='admin',
+ 's3.secret_key'='password',
+ 's3.path.style.access'='true',
+ 'meta.cache.paimon.table.ttl-second'='0'
+ )"""
+ sql """switch ${catalogName}"""
+ sql """use ${dbName}"""
+ sql "set enable_file_scanner_v2=true"
+ sql "set force_jni_scanner=false"
+ sql "set enable_strict_cast=false"
+
+ def queries = [
+ "select min(cast(value as int)) from minmax_cast",
+ "select max(cast(value as int)) from minmax_cast",
+ "select min(cast(value as int)), max(cast(value as int)) from
minmax_cast"
+ ]
+ queries.each { query ->
+ sql "set enable_push_down_no_group_agg=false"
+ def fullScanResult = sql(query)
+ sql "set enable_push_down_no_group_agg=true"
+ // Compare with row-by-row evaluation so the reference cannot
share the metadata bug.
+ assertEquals(fullScanResult, sql(query))
+ explain {
+ sql(query)
+ contains "pushdown agg=NONE"
+ }
+ }
+
+ // Keep a positive control: disabling all file MIN/MAX pushdown must
not satisfy this test.
+ explain {
+ sql "select min(value), max(value) from minmax_cast"
+ contains "pushdown agg=MINMAX"
+ contains "inputSplitNum=1"
Review Comment:
Addressed in c96aa1efea and synchronized to #67980. Every unsafe-query
EXPLAIN and the raw-column positive control now require
paimonNativeReadSplits=1/1, so a JNI fallback cannot satisfy this regression.
The single-split assertion is retained. Groovy syntax checks passed; local
integration execution could not proceed past the FE connection.
--
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]