This is an automated email from the ASF dual-hosted git repository. morrysnow pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push: new 34c36e72a90 [pick](nereids)do not check invisible column stats (#30676) 34c36e72a90 is described below commit 34c36e72a9039f6f31fb69611795ec4251798a65 Author: minghong <engle...@gmail.com> AuthorDate: Fri Feb 2 14:13:56 2024 +0800 [pick](nereids)do not check invisible column stats (#30676) pick from master #27201 --- .../glue/translator/PhysicalPlanTranslator.java | 12 ++++-- .../nereids_p0/forbid_unknown_col_stats.groovy | 46 ++++++++++++++++++++++ 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java index 0e0d89d5bd7..2e47c9fc62b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java @@ -179,6 +179,7 @@ import org.apache.doris.planner.external.jdbc.JdbcScanNode; import org.apache.doris.planner.external.odbc.OdbcScanNode; import org.apache.doris.planner.external.paimon.PaimonScanNode; import org.apache.doris.qe.ConnectContext; +import org.apache.doris.statistics.StatisticConstants; import org.apache.doris.tablefunction.TableValuedFunctionIf; import org.apache.doris.thrift.TFetchOption; import org.apache.doris.thrift.TPartitionType; @@ -631,9 +632,13 @@ public class PhysicalPlanTranslator extends DefaultPlanVisitor<PlanFragment, Pla // olapScanNode.setCardinality((long) olapScan.getStats().getRowCount()); if (ConnectContext.get().getSessionVariable().forbidUnknownColStats) { for (int i = 0; i < slots.size(); i++) { - Slot slot = slots.get(i); + SlotReference slot = (SlotReference) slots.get(i); + boolean inVisibleCol = slot.getColumn().isPresent() + && StatisticConstants.shouldIgnoreCol(olapTable, slot.getColumn().get()); if (olapScan.getStats().findColumnStatistics(slot).isUnKnown() - && !isComplexDataType(slot.getDataType())) { + && !isComplexDataType(slot.getDataType()) + && !StatisticConstants.isSystemTable(olapTable) + && !inVisibleCol) { context.addUnknownStatsColumn(olapScanNode, tupleDescriptor.getSlots().get(i).getId()); } } @@ -2124,7 +2129,8 @@ public class PhysicalPlanTranslator extends DefaultPlanVisitor<PlanFragment, Pla if (ConnectContext.get() != null && ConnectContext.get().getSessionVariable().forbidUnknownColStats) { for (SlotId slotId : requiredByProjectSlotIdSet) { if (context.isColumnStatsUnknown(scanNode, slotId)) { - throw new AnalysisException("meet unknown column stats on table " + scanNode); + String colName = scanNode.getTupleDesc().getSlot(slotId.asInt()).getColumn().getName(); + throw new AnalysisException("meet unknown column stats: " + colName); } } context.removeScanFromStatsUnknownColumnsMap(scanNode); diff --git a/regression-test/suites/nereids_p0/forbid_unknown_col_stats.groovy b/regression-test/suites/nereids_p0/forbid_unknown_col_stats.groovy new file mode 100644 index 00000000000..ad22ece8ceb --- /dev/null +++ b/regression-test/suites/nereids_p0/forbid_unknown_col_stats.groovy @@ -0,0 +1,46 @@ +// 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("forbid_unknown_col_stats") { + String db = context.config.getDbNameByFile(context.file) + sql "use ${db}" + sql "SET enable_nereids_planner=true" + sql "SET enable_fallback_to_original_planner=false" + sql "set forbid_unknown_col_stats=true;" + sql "drop table if exists region" + sql ''' + CREATE TABLE region ( + r_regionkey int NOT NULL, + r_name VARCHAR(25) NOT NULL, + r_comment VARCHAR(152) + )ENGINE=OLAP + unique KEY(`r_regionkey`) + COMMENT "OLAP" + DISTRIBUTED BY HASH(`r_regionkey`) BUCKETS 1 + PROPERTIES ( + "replication_num" = "1" + ); + ''' + + test { + sql """select r_regionkey from region; """ + exception "java.sql.SQLException: errCode = 2, detailMessage = Unexpected exception: meet unknown column stats: r_regionkey"; + } + + sql "alter table region modify column r_regionkey set stats ('ndv'='5', 'num_nulls'='0', 'min_value'='0', 'max_value'='4', 'row_count'='5');" + sql """select r_regionkey from region; """ +} \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org