do not check invisible column stats (#27201)
1. forbid_unknown_col_stats check ignore invisible columns 2. a better error message when meet unknown col stats
This commit is contained in:
@ -611,10 +611,13 @@ public class PhysicalPlanTranslator extends DefaultPlanVisitor<PlanFragment, Pla
|
||||
olapScanNode.setCardinality((long) olapScan.getStats().getRowCount());
|
||||
if (context.getSessionVariable() != null && context.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())
|
||||
&& !StatisticConstants.isSystemTable(olapTable)) {
|
||||
&& !StatisticConstants.isSystemTable(olapTable)
|
||||
&& !inVisibleCol) {
|
||||
context.addUnknownStatsColumn(olapScanNode, tupleDescriptor.getSlots().get(i).getId());
|
||||
}
|
||||
}
|
||||
@ -2117,7 +2120,8 @@ public class PhysicalPlanTranslator extends DefaultPlanVisitor<PlanFragment, Pla
|
||||
&& !StatisticConstants.isSystemTable(scanNode.getTupleDesc().getTable())) {
|
||||
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);
|
||||
|
||||
@ -36,4 +36,11 @@ suite("forbid_unknown_col_stats") {
|
||||
);
|
||||
'''
|
||||
|
||||
test {
|
||||
sql """select r_regionkey from region; """
|
||||
exception "java.sql.SQLException: errCode = 2, detailMessage = 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; """
|
||||
}
|
||||
Reference in New Issue
Block a user