From a4530b75bce3ea586f37084be1a803d083d37a2b Mon Sep 17 00:00:00 2001 From: 924060929 Date: Thu, 27 Nov 2025 21:16:34 +0800 Subject: [PATCH 1/2] fix --- .../rules/rewrite/SlotTypeReplacer.java | 4 +- .../trees/plans/logical/LogicalOlapScan.java | 84 +++++---- .../rules/rewrite/PruneNestedColumnTest.java | 161 ++++++++++++++++++ 3 files changed, 211 insertions(+), 38 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/SlotTypeReplacer.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/SlotTypeReplacer.java index 661f537eabf2a4..99ccdaf330914d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/SlotTypeReplacer.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/SlotTypeReplacer.java @@ -456,7 +456,7 @@ public Plan visitLogicalOlapScan(LogicalOlapScan olapScan, Void context) { } Pair> replaced = replaceExpressions(olapScan.getOutput(), false, true); if (replaced.first) { - return olapScan.withPrunedTypeSlots(replaced.second); + return olapScan.withCachedOutput(replaced.second); } return olapScan; } @@ -718,7 +718,7 @@ private void tryRecordReplaceSlots(Plan plan, Object checkObj, Set shou boolean shouldPrune = false; for (Slot slot : output) { int slotId = slot.getExprId().asInt(); - if (replacedDataTypes.containsKey(slotId)) { + if (slot.getDataType() instanceof NestedColumnPrunable && replacedDataTypes.containsKey(slotId)) { shouldReplaceSlots.add(slotId); shouldPrune = true; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java index cb1214cd7c5afc..3edc162b5a5948 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java @@ -104,6 +104,11 @@ public class LogicalOlapScan extends LogicalCatalogRelation implements OlapScan, */ private final Map, Slot> cacheSlotWithSlotName; + /** + * this is the cache output to overwrite the output, the priority is higher than cacheSlotWithSlotName + */ + private final Optional> cachedOutput; + /////////////////////////////////////////////////////////////////////////// // Members for tablet ids. /////////////////////////////////////////////////////////////////////////// @@ -161,7 +166,7 @@ public LogicalOlapScan(RelationId id, OlapTable table, List qualifier) { table.getPartitionIds(), false, ImmutableList.of(), -1, false, PreAggStatus.unset(), ImmutableList.of(), ImmutableList.of(), - Maps.newHashMap(), Optional.empty(), false, ImmutableMap.of(), + Maps.newHashMap(), Optional.empty(), Optional.empty(), false, ImmutableMap.of(), ImmutableList.of(), ImmutableList.of(), ImmutableList.of(), ImmutableList.of(), Optional.empty(), ImmutableList.of(), Optional.empty(), ""); } @@ -170,7 +175,7 @@ public LogicalOlapScan(RelationId id, OlapTable table, List qualifier, L List hints, Optional tableSample, Collection operativeSlots) { this(id, table, qualifier, Optional.empty(), Optional.empty(), table.getPartitionIds(), false, tabletIds, - -1, false, PreAggStatus.unset(), ImmutableList.of(), hints, Maps.newHashMap(), + -1, false, PreAggStatus.unset(), ImmutableList.of(), hints, Maps.newHashMap(), Optional.empty(), tableSample, false, ImmutableMap.of(), ImmutableList.of(), operativeSlots, ImmutableList.of(), ImmutableList.of(), Optional.empty(), ImmutableList.of(), Optional.empty(), ""); } @@ -183,7 +188,7 @@ public LogicalOlapScan(RelationId id, OlapTable table, List qualifier, L this(id, table, qualifier, Optional.empty(), Optional.empty(), // must use specifiedPartitions here for prune partition by sql like 'select * from t partition p1' specifiedPartitions, false, tabletIds, - -1, false, PreAggStatus.unset(), specifiedPartitions, hints, Maps.newHashMap(), + -1, false, PreAggStatus.unset(), specifiedPartitions, hints, Maps.newHashMap(), Optional.empty(), tableSample, false, ImmutableMap.of(), ImmutableList.of(), operativeSlots, ImmutableList.of(), ImmutableList.of(), Optional.empty(), ImmutableList.of(), Optional.empty(), ""); @@ -199,7 +204,7 @@ public LogicalOlapScan(RelationId id, OlapTable table, List qualifier, L this(id, table, qualifier, Optional.empty(), Optional.empty(), selectedPartitionIds, false, tabletIds, selectedIndexId, true, preAggStatus, - specifiedPartitions, hints, Maps.newHashMap(), tableSample, true, ImmutableMap.of(), + specifiedPartitions, hints, Maps.newHashMap(), Optional.empty(), tableSample, true, ImmutableMap.of(), ImmutableList.of(), operativeSlots, ImmutableList.of(), ImmutableList.of(), Optional.empty(), ImmutableList.of(), Optional.empty(), ""); } @@ -213,7 +218,7 @@ public LogicalOlapScan(RelationId id, Table table, List qualifier, List selectedTabletIds, long selectedIndexId, boolean indexSelected, PreAggStatus preAggStatus, List specifiedPartitions, List hints, Map, Slot> cacheSlotWithSlotName, - Optional tableSample, boolean directMvScan, + Optional> cachedOutput, Optional tableSample, boolean directMvScan, Map>> colToSubPathsMap, List specifiedTabletIds, Collection operativeSlots, List virtualColumns, List scoreOrderKeys, Optional scoreLimit, @@ -245,6 +250,7 @@ public LogicalOlapScan(RelationId id, Table table, List qualifier, this.hints = Objects.requireNonNull(hints, "hints can not be null"); this.cacheSlotWithSlotName = Objects.requireNonNull(cacheSlotWithSlotName, "mvNameToSlot can not be null"); + this.cachedOutput = Objects.requireNonNull(cachedOutput, "cachedOutput can not be null"); this.tableSample = tableSample; this.directMvScan = directMvScan; this.colToSubPathsMap = colToSubPathsMap; @@ -337,8 +343,9 @@ public LogicalOlapScan withGroupExpression(Optional groupExpres groupExpression, Optional.of(getLogicalProperties()), selectedPartitionIds, partitionPruned, selectedTabletIds, selectedIndexId, indexSelected, preAggStatus, manuallySpecifiedPartitions, - hints, cacheSlotWithSlotName, tableSample, directMvScan, colToSubPathsMap, manuallySpecifiedTabletIds, - operativeSlots, virtualColumns, scoreOrderKeys, scoreLimit, annOrderKeys, annLimit, tableAlias); + hints, cacheSlotWithSlotName, cachedOutput, tableSample, directMvScan, + colToSubPathsMap, manuallySpecifiedTabletIds, operativeSlots, virtualColumns, + scoreOrderKeys, scoreLimit, annOrderKeys, annLimit, tableAlias); } @Override @@ -347,8 +354,9 @@ public Plan withGroupExprLogicalPropChildren(Optional groupExpr return new LogicalOlapScan(relationId, (Table) table, qualifier, groupExpression, logicalProperties, selectedPartitionIds, partitionPruned, selectedTabletIds, selectedIndexId, indexSelected, preAggStatus, manuallySpecifiedPartitions, - hints, cacheSlotWithSlotName, tableSample, directMvScan, colToSubPathsMap, manuallySpecifiedTabletIds, - operativeSlots, virtualColumns, scoreOrderKeys, scoreLimit, annOrderKeys, annLimit, tableAlias); + hints, cacheSlotWithSlotName, cachedOutput, tableSample, directMvScan, + colToSubPathsMap, manuallySpecifiedTabletIds, operativeSlots, virtualColumns, + scoreOrderKeys, scoreLimit, annOrderKeys, annLimit, tableAlias); } /** @@ -359,8 +367,9 @@ public LogicalOlapScan withSelectedPartitionIds(List selectedPartitionIds) Optional.empty(), Optional.of(getLogicalProperties()), selectedPartitionIds, true, selectedTabletIds, selectedIndexId, indexSelected, preAggStatus, manuallySpecifiedPartitions, - hints, cacheSlotWithSlotName, tableSample, directMvScan, colToSubPathsMap, manuallySpecifiedTabletIds, - operativeSlots, virtualColumns, scoreOrderKeys, scoreLimit, annOrderKeys, annLimit, tableAlias); + hints, cacheSlotWithSlotName, cachedOutput, tableSample, directMvScan, + colToSubPathsMap, manuallySpecifiedTabletIds, operativeSlots, virtualColumns, + scoreOrderKeys, scoreLimit, annOrderKeys, annLimit, tableAlias); } /** @@ -373,7 +382,7 @@ public LogicalOlapScan withMaterializedIndexSelected(long indexId) { Optional.empty(), Optional.of(getLogicalProperties()), selectedPartitionIds, partitionPruned, selectedTabletIds, indexId, true, PreAggStatus.unset(), manuallySpecifiedPartitions, hints, cacheSlotWithSlotName, - tableSample, directMvScan, colToSubPathsMap, manuallySpecifiedTabletIds, + cachedOutput, tableSample, directMvScan, colToSubPathsMap, manuallySpecifiedTabletIds, operativeSlots, virtualColumns, scoreOrderKeys, scoreLimit, annOrderKeys, annLimit, tableAlias); } @@ -385,8 +394,9 @@ public LogicalOlapScan withSelectedTabletIds(List selectedTabletIds) { Optional.empty(), Optional.of(getLogicalProperties()), selectedPartitionIds, partitionPruned, selectedTabletIds, selectedIndexId, indexSelected, preAggStatus, manuallySpecifiedPartitions, - hints, cacheSlotWithSlotName, tableSample, directMvScan, colToSubPathsMap, manuallySpecifiedTabletIds, - operativeSlots, virtualColumns, scoreOrderKeys, scoreLimit, annOrderKeys, annLimit, tableAlias); + hints, cacheSlotWithSlotName, cachedOutput, tableSample, directMvScan, + colToSubPathsMap, manuallySpecifiedTabletIds, operativeSlots, virtualColumns, scoreOrderKeys, + scoreLimit, annOrderKeys, annLimit, tableAlias); } /** @@ -397,8 +407,9 @@ public LogicalOlapScan withPreAggStatus(PreAggStatus preAggStatus) { Optional.empty(), Optional.of(getLogicalProperties()), selectedPartitionIds, partitionPruned, selectedTabletIds, selectedIndexId, indexSelected, preAggStatus, manuallySpecifiedPartitions, - hints, cacheSlotWithSlotName, tableSample, directMvScan, colToSubPathsMap, manuallySpecifiedTabletIds, - operativeSlots, virtualColumns, scoreOrderKeys, scoreLimit, annOrderKeys, annLimit, tableAlias); + hints, cacheSlotWithSlotName, cachedOutput, tableSample, directMvScan, + colToSubPathsMap, manuallySpecifiedTabletIds, operativeSlots, virtualColumns, + scoreOrderKeys, scoreLimit, annOrderKeys, annLimit, tableAlias); } /** @@ -409,8 +420,9 @@ public LogicalOlapScan withColToSubPathsMap(Map>> colTo Optional.empty(), Optional.empty(), selectedPartitionIds, partitionPruned, selectedTabletIds, selectedIndexId, indexSelected, preAggStatus, manuallySpecifiedPartitions, - hints, cacheSlotWithSlotName, tableSample, directMvScan, colToSubPathsMap, manuallySpecifiedTabletIds, - operativeSlots, virtualColumns, scoreOrderKeys, scoreLimit, annOrderKeys, annLimit, tableAlias); + hints, cacheSlotWithSlotName, cachedOutput, tableSample, directMvScan, + colToSubPathsMap, manuallySpecifiedTabletIds, operativeSlots, virtualColumns, + scoreOrderKeys, scoreLimit, annOrderKeys, annLimit, tableAlias); } /** @@ -421,8 +433,9 @@ public LogicalOlapScan withManuallySpecifiedTabletIds(List manuallySpecifi Optional.empty(), Optional.of(getLogicalProperties()), selectedPartitionIds, partitionPruned, selectedTabletIds, selectedIndexId, indexSelected, preAggStatus, manuallySpecifiedPartitions, - hints, cacheSlotWithSlotName, tableSample, directMvScan, colToSubPathsMap, manuallySpecifiedTabletIds, - operativeSlots, virtualColumns, scoreOrderKeys, scoreLimit, annOrderKeys, annLimit, tableAlias); + hints, cacheSlotWithSlotName, cachedOutput, tableSample, directMvScan, + colToSubPathsMap, manuallySpecifiedTabletIds, operativeSlots, virtualColumns, + scoreOrderKeys, scoreLimit, annOrderKeys, annLimit, tableAlias); } @Override @@ -432,8 +445,9 @@ public LogicalOlapScan withRelationId(RelationId relationId) { Optional.empty(), Optional.empty(), selectedPartitionIds, false, selectedTabletIds, selectedIndexId, indexSelected, preAggStatus, manuallySpecifiedPartitions, - hints, Maps.newHashMap(), tableSample, directMvScan, colToSubPathsMap, selectedTabletIds, - operativeSlots, virtualColumns, scoreOrderKeys, scoreLimit, annOrderKeys, annLimit, tableAlias); + hints, cacheSlotWithSlotName, cachedOutput, tableSample, directMvScan, + colToSubPathsMap, selectedTabletIds, operativeSlots, virtualColumns, scoreOrderKeys, + scoreLimit, annOrderKeys, annLimit, tableAlias); } @Override @@ -442,8 +456,9 @@ public LogicalOlapScan withTableAlias(String tableAlias) { Optional.empty(), Optional.of(getLogicalProperties()), selectedPartitionIds, partitionPruned, selectedTabletIds, selectedIndexId, indexSelected, preAggStatus, manuallySpecifiedPartitions, - hints, cacheSlotWithSlotName, tableSample, directMvScan, colToSubPathsMap, manuallySpecifiedTabletIds, - operativeSlots, virtualColumns, scoreOrderKeys, scoreLimit, annOrderKeys, annLimit, tableAlias); + hints, cacheSlotWithSlotName, cachedOutput, tableSample, directMvScan, + colToSubPathsMap, manuallySpecifiedTabletIds, operativeSlots, virtualColumns, + scoreOrderKeys, scoreLimit, annOrderKeys, annLimit, tableAlias); } /** @@ -461,7 +476,7 @@ public LogicalOlapScan withVirtualColumns(List virtualColumns) groupExpression, Optional.of(logicalProperties), selectedPartitionIds, partitionPruned, selectedTabletIds, selectedIndexId, indexSelected, preAggStatus, manuallySpecifiedPartitions, - hints, cacheSlotWithSlotName, tableSample, directMvScan, colToSubPathsMap, + hints, cacheSlotWithSlotName, cachedOutput, tableSample, directMvScan, colToSubPathsMap, manuallySpecifiedTabletIds, operativeSlots, virtualColumns, scoreOrderKeys, scoreLimit, annOrderKeys, annLimit, tableAlias); } @@ -485,7 +500,7 @@ public LogicalOlapScan withVirtualColumnsAndTopN( groupExpression, Optional.of(logicalProperties), selectedPartitionIds, partitionPruned, selectedTabletIds, selectedIndexId, indexSelected, preAggStatus, manuallySpecifiedPartitions, - hints, cacheSlotWithSlotName, tableSample, directMvScan, colToSubPathsMap, + hints, cacheSlotWithSlotName, cachedOutput, tableSample, directMvScan, colToSubPathsMap, manuallySpecifiedTabletIds, operativeSlots, virtualColumns, scoreOrderKeys, scoreLimit, annOrderKeys, annLimit, tableAlias); } @@ -533,6 +548,9 @@ public Optional getSelectedMaterializedIndexName() { @Override public List computeOutput() { + if (cachedOutput.isPresent()) { + return cachedOutput.get(); + } if (selectedIndexId != ((OlapTable) table).getBaseIndexId()) { return getOutputByIndex(selectedIndexId); } @@ -817,7 +835,7 @@ public CatalogRelation withOperativeSlots(Collection operativeSlots) { groupExpression, Optional.of(getLogicalProperties()), selectedPartitionIds, partitionPruned, selectedTabletIds, selectedIndexId, indexSelected, preAggStatus, manuallySpecifiedPartitions, - hints, cacheSlotWithSlotName, tableSample, directMvScan, colToSubPathsMap, + hints, cacheSlotWithSlotName, cachedOutput, tableSample, directMvScan, colToSubPathsMap, manuallySpecifiedTabletIds, operativeSlots, virtualColumns, scoreOrderKeys, scoreLimit, annOrderKeys, annLimit, tableAlias); } @@ -852,19 +870,13 @@ private Map constructReplaceMap(MTMV mtmv) { return replaceMap; } - /** withPrunedTypeSlots */ - public LogicalOlapScan withPrunedTypeSlots(List outputSlots) { - Map, Slot> replaceSlotMap = new HashMap<>(); - for (Slot outputSlot : outputSlots) { - Pair key = Pair.of(selectedIndexId, outputSlot.getName()); - replaceSlotMap.put(key, outputSlot); - } - + /** withCachedOutput */ + public LogicalOlapScan withCachedOutput(List outputSlots) { return new LogicalOlapScan(relationId, (Table) table, qualifier, groupExpression, Optional.empty(), selectedPartitionIds, partitionPruned, selectedTabletIds, selectedIndexId, indexSelected, preAggStatus, manuallySpecifiedPartitions, - hints, replaceSlotMap, tableSample, directMvScan, colToSubPathsMap, + hints, cacheSlotWithSlotName, Optional.of(outputSlots), tableSample, directMvScan, colToSubPathsMap, manuallySpecifiedTabletIds, operativeSlots, virtualColumns, scoreOrderKeys, scoreLimit, annOrderKeys, annLimit, tableAlias); } diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/PruneNestedColumnTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/PruneNestedColumnTest.java index 3d22e1e6c28e24..fccc0e4c646599 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/PruneNestedColumnTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/PruneNestedColumnTest.java @@ -586,6 +586,167 @@ public void testDataTypeAccessTree() { ); } + @Test + public void testWithVariant() throws Exception { + connectContext.getSessionVariable().enableDecimal256 = true; + + createTable("CREATE TABLE test.`table_20_undef_partitions2_keys3_properties4_distributed_by56` (\n" + + " `col_tinyint_undef_signed_index_inverted` tinyint NULL,\n" + + " `col_smallint_undef_signed_not_null_index_inverted` smallint NOT NULL,\n" + + " `pk` int NULL,\n" + + " `col_int_undef_signed` int NULL,\n" + + " `col_bigint_undef_signed` bigint NULL,\n" + + " `col_decimal_10_0__undef_signed` decimal(10,0) NULL,\n" + + " `col_largeint_undef_signed` largeint NULL,\n" + + " `col_boolean_undef_signed` boolean NULL,\n" + + " `col_boolean_undef_signed_not_null` boolean NOT NULL,\n" + + " `col_tinyint_undef_signed` tinyint NULL,\n" + + " `col_tinyint_undef_signed_not_null` tinyint NOT NULL,\n" + + " `col_tinyint_undef_signed_not_null_index_inverted` tinyint NOT NULL,\n" + + " `col_smallint_undef_signed` smallint NULL,\n" + + " `col_smallint_undef_signed_index_inverted` smallint NULL,\n" + + " `col_smallint_undef_signed_not_null` smallint NOT NULL,\n" + + " `col_int_undef_signed_index_inverted` int NULL,\n" + + " `col_int_undef_signed_not_null` int NOT NULL,\n" + + " `col_int_undef_signed_not_null_index_inverted` int NOT NULL,\n" + + " `col_bigint_undef_signed_index_inverted` bigint NULL,\n" + + " `col_bigint_undef_signed_not_null` bigint NOT NULL,\n" + + " `col_bigint_undef_signed_not_null_index_inverted` bigint NOT NULL,\n" + + " `col_largeint_undef_signed_not_null` largeint NOT NULL,\n" + + " `col_decimal_10_0__undef_signed_index_inverted` decimal(10,0) NULL,\n" + + " `col_decimal_10_0__undef_signed_not_null` decimal(10,0) NOT NULL,\n" + + " `col_decimal_10_0__undef_signed_not_null_index_inverted` decimal(10,0) NOT NULL,\n" + + " `col_decimal_16_10__undef_signed` decimal(16,10) NULL,\n" + + " `col_decimal_16_10__undef_signed_index_inverted` decimal(16,10) NULL,\n" + + " `col_decimal_16_10__undef_signed_not_null` decimal(16,10) NOT NULL,\n" + + " `col_decimal_16_10__undef_signed_not_null_index_inverted` decimal(16,10) NOT NULL,\n" + + " `col_decimal_37__12__undef_signed` decimal(37,12) NULL,\n" + + " `col_decimal_37__12__undef_signed_index_inverted` decimal(37,12) NULL,\n" + + " `col_decimal_37__12__undef_signed_not_null` decimal(37,12) NOT NULL,\n" + + " `col_decimal_37__12__undef_signed_not_null_index_inverted` decimal(37,12) NOT NULL,\n" + + " `col_decimal_17_0__undef_signed` decimal(17,0) NULL,\n" + + " `col_decimal_17_0__undef_signed_index_inverted` decimal(17,0) NULL,\n" + + " `col_decimal_17_0__undef_signed_not_null` decimal(17,0) NOT NULL,\n" + + " `col_decimal_17_0__undef_signed_not_null_index_inverted` decimal(17,0) NOT NULL,\n" + + " `col_decimal_8_4__undef_signed` decimal(8,4) NULL,\n" + + " `col_decimal_8_4__undef_signed_index_inverted` decimal(8,4) NULL,\n" + + " `col_decimal_8_4__undef_signed_not_null` decimal(8,4) NOT NULL,\n" + + " `col_decimal_8_4__undef_signed_not_null_index_inverted` decimal(8,4) NOT NULL,\n" + + " `col_decimal_9_0__undef_signed` decimal(9,0) NULL,\n" + + " `col_decimal_9_0__undef_signed_index_inverted` decimal(9,0) NULL,\n" + + " `col_decimal_9_0__undef_signed_not_null` decimal(9,0) NOT NULL,\n" + + " `col_decimal_9_0__undef_signed_not_null_index_inverted` decimal(9,0) NOT NULL,\n" + + " `col_decimal_76__56__undef_signed` decimal(76,56) NULL,\n" + + " `col_decimal_76__56__undef_signed_index_inverted` decimal(76,56) NULL,\n" + + " `col_decimal_76__56__undef_signed_not_null` decimal(76,56) NOT NULL,\n" + + " `col_decimal_76__56__undef_signed_not_null_index_inverted` decimal(76,56) NOT NULL,\n" + + " `col_datetime_undef_signed` datetime NULL,\n" + + " `col_datetime_undef_signed_index_inverted` datetime NULL,\n" + + " `col_datetime_undef_signed_not_null` datetime NOT NULL,\n" + + " `col_datetime_undef_signed_not_null_index_inverted` datetime NOT NULL,\n" + + " `col_map_boolean__boolean__undef_signed` map NULL,\n" + + " `col_map_boolean__boolean__undef_signed_not_null` map NOT NULL,\n" + + " `col_map_tinyint__tinyint__undef_signed` map NULL,\n" + + " `col_map_tinyint__tinyint__undef_signed_not_null` map NOT NULL,\n" + + " `col_map_smallint__smallint__undef_signed` map NULL,\n" + + " `col_map_smallint__smallint__undef_signed_not_null` map NOT NULL,\n" + + " `col_map_int__int__undef_signed` map NULL,\n" + + " `col_map_int__int__undef_signed_not_null` map NOT NULL,\n" + + " `col_map_bigint__bigint__undef_signed` map NULL,\n" + + " `col_map_bigint__bigint__undef_signed_not_null` map NOT NULL,\n" + + " `col_map_largeint__largeint__undef_signed` map NULL,\n" + + " `col_map_largeint__largeint__undef_signed_not_null` map NOT NULL,\n" + + " `col_map_decimal_10_0___decimal_10_0___undef_signed` map NULL,\n" + + " `col_map_decimal_10_0___decimal_10_0___undef_signed_not_null` map NOT NULL,\n" + + " `col_map_decimal_16_10___decimal_16_10___undef_signed` map NULL,\n" + + " `col_map_decimal_16_10___decimal_16_10___undef_signed_not_null` map NOT NULL,\n" + + " `col_map_decimal_37__12___decimal_37__12___undef_signed` map NULL,\n" + + " `col_map_decimal_37__12___decimal_37__12___undef_signed_not_null` map NOT NULL,\n" + + " `col_map_decimal_8_4___decimal_8_4___undef_signed` map NULL,\n" + + " `col_map_decimal_8_4___decimal_8_4___undef_signed_not_null` map NOT NULL,\n" + + " `col_map_decimal_76__56___decimal_76__56___undef_signed` map NULL,\n" + + " `col_map_decimal_76__56___decimal_76__56___undef_signed_not_null` map NOT NULL,\n" + + " `col_map_char_255___boolean__undef_signed` map NULL,\n" + + " `col_map_char_255___boolean__undef_signed_not_null` map NOT NULL,\n" + + " `col_map_char_255___tinyint__undef_signed` map NULL,\n" + + " `col_map_char_255___tinyint__undef_signed_not_null` map NOT NULL,\n" + + " `col_map_varchar_255___int__undef_signed` map NULL,\n" + + " `col_map_varchar_255___int__undef_signed_not_null` map NOT NULL,\n" + + " `col_map_varchar_65533___largeint__undef_signed` map NULL,\n" + + " `col_map_varchar_65533___largeint__undef_signed_not_null` map NOT NULL,\n" + + " `col_map_string__decimal_10_0___undef_signed` map NULL,\n" + + " `col_map_string__decimal_10_0___undef_signed_not_null` map NOT NULL,\n" + + " `col_map_varchar_65533___decimal_76__50___undef_signed` map NULL,\n" + + " `col_map_varchar_65533___decimal_76__50___undef_signed_not_null` map NOT NULL,\n" + + " `col_map_date__boolean__undef_signed` map NULL,\n" + + " `col_map_date__boolean__undef_signed_not_null` map NOT NULL,\n" + + " `col_map_date__tinyint__undef_signed` map NULL,\n" + + " `col_map_date__tinyint__undef_signed_not_null` map NOT NULL,\n" + + " `col_map_date__smallint__undef_signed` map NULL,\n" + + " `col_map_date__smallint__undef_signed_not_null` map NOT NULL,\n" + + " `col_map_date__int__undef_signed` map NULL,\n" + + " `col_map_date__int__undef_signed_not_null` map NOT NULL,\n" + + " `col_map_datetime_6___bigint__undef_signed` map NULL,\n" + + " `col_map_datetime_6___bigint__undef_signed_not_null` map NOT NULL,\n" + + " `col_map_datetime_3___largeint__undef_signed` map NULL,\n" + + " `col_map_datetime_3___largeint__undef_signed_not_null` map NOT NULL,\n" + + " `col_map_datetime__decimal_76__50___undef_signed` map NULL,\n" + + " `col_map_datetime__decimal_76__50___undef_signed_not_null` map NOT NULL,\n" + + " `col_map_date__decimal_16_10___undef_signed` map NULL,\n" + + " `col_map_date__decimal_16_10___undef_signed_not_null` map NOT NULL,\n" + + " `col_map_date__decimal_37__12___undef_signed` map NULL,\n" + + " `col_map_date__decimal_37__12___undef_signed_not_null` map NOT NULL,\n" + + " `col_struct` struct NULL,\n" + + " `col_struct2` struct NOT NULL,\n" + + " `col_variant_undef_signed` variant NULL,\n" + + " `col_variant_undef_signed_not_null` variant NOT NULL,\n" + + " INDEX col_tinyint_undef_signed_index_inverted_idx (`col_tinyint_undef_signed_index_inverted`) USING INVERTED,\n" + + " INDEX col_tinyint_undef_signed_not_null_index_inverted_idx (`col_tinyint_undef_signed_not_null_index_inverted`) USING INVERTED,\n" + + " INDEX col_smallint_undef_signed_index_inverted_idx (`col_smallint_undef_signed_index_inverted`) USING INVERTED,\n" + + " INDEX col_smallint_undef_signed_not_null_index_inverted_idx (`col_smallint_undef_signed_not_null_index_inverted`) USING INVERTED,\n" + + " INDEX col_int_undef_signed_index_inverted_idx (`col_int_undef_signed_index_inverted`) USING INVERTED,\n" + + " INDEX col_int_undef_signed_not_null_index_inverted_idx (`col_int_undef_signed_not_null_index_inverted`) USING INVERTED,\n" + + " INDEX col_bigint_undef_signed_index_inverted_idx (`col_bigint_undef_signed_index_inverted`) USING INVERTED,\n" + + " INDEX col_bigint_undef_signed_not_null_index_inverted_idx (`col_bigint_undef_signed_not_null_index_inverted`) USING INVERTED,\n" + + " INDEX col_decimal_10_0__undef_signed_index_inverted_idx (`col_decimal_10_0__undef_signed_index_inverted`) USING INVERTED,\n" + + " INDEX col_decimal_10_0__undef_signed_not_null_index_inverted_idx (`col_decimal_10_0__undef_signed_not_null_index_inverted`) USING INVERTED,\n" + + " INDEX col_decimal_16_10__undef_signed_index_inverted_idx (`col_decimal_16_10__undef_signed_index_inverted`) USING INVERTED,\n" + + " INDEX col_decimal_16_10__undef_signed_not_null_index_inverted_idx (`col_decimal_16_10__undef_signed_not_null_index_inverted`) USING INVERTED,\n" + + " INDEX col_decimal_37__12__undef_signed_index_inverted_idx (`col_decimal_37__12__undef_signed_index_inverted`) USING INVERTED,\n" + + " INDEX col_decimal_37__12__undef_signed_not_null_index_inverted_idx (`col_decimal_37__12__undef_signed_not_null_index_inverted`) USING INVERTED,\n" + + " INDEX col_decimal_17_0__undef_signed_index_inverted_idx (`col_decimal_17_0__undef_signed_index_inverted`) USING INVERTED,\n" + + " INDEX col_decimal_17_0__undef_signed_not_null_index_inverted_idx (`col_decimal_17_0__undef_signed_not_null_index_inverted`) USING INVERTED,\n" + + " INDEX col_decimal_8_4__undef_signed_index_inverted_idx (`col_decimal_8_4__undef_signed_index_inverted`) USING INVERTED,\n" + + " INDEX col_decimal_8_4__undef_signed_not_null_index_inverted_idx (`col_decimal_8_4__undef_signed_not_null_index_inverted`) USING INVERTED,\n" + + " INDEX col_decimal_9_0__undef_signed_index_inverted_idx (`col_decimal_9_0__undef_signed_index_inverted`) USING INVERTED,\n" + + " INDEX col_decimal_9_0__undef_signed_not_null_index_inverted_idx (`col_decimal_9_0__undef_signed_not_null_index_inverted`) USING INVERTED,\n" + + " INDEX col_decimal_76__56__undef_signed_index_inverted_idx (`col_decimal_76__56__undef_signed_index_inverted`) USING INVERTED,\n" + + " INDEX col_decimal_76__56__undef_signed_not_null_index_inverted_idx (`col_decimal_76__56__undef_signed_not_null_index_inverted`) USING INVERTED,\n" + + " INDEX col_datetime_undef_signed_index_inverted_idx (`col_datetime_undef_signed_index_inverted`) USING INVERTED,\n" + + " INDEX col_datetime_undef_signed_not_null_index_inverted_idx (`col_datetime_undef_signed_not_null_index_inverted`) USING INVERTED\n" + + ") ENGINE=OLAP\n" + + "DUPLICATE KEY(`col_tinyint_undef_signed_index_inverted`, `col_smallint_undef_signed_not_null_index_inverted`, `pk`, `col_int_undef_signed`, `col_bigint_undef_signed`, `col_decimal_10_0__undef_signed`, `col_largeint_undef_signed`)\n" + + "PARTITION BY RANGE(`col_tinyint_undef_signed_index_inverted`, `col_smallint_undef_signed_not_null_index_inverted`)\n" + + "(PARTITION p0 VALUES [(\"-128\", \"-32768\"), (\"0\", \"0\")),\n" + + "PARTITION p1 VALUES [(\"0\", \"0\"), (\"10\", \"256\")),\n" + + "PARTITION p2 VALUES [(\"10\", \"256\"), (\"50\", \"10240\")),\n" + + "PARTITION p3 VALUES [(\"50\", \"10240\"), (\"100\", \"32767\")),\n" + + "PARTITION p4 VALUES [(\"100\", \"32767\"), (MAXVALUE, MAXVALUE)))\n" + + "DISTRIBUTED BY HASH(`pk`) BUCKETS 10\n" + + "PROPERTIES (\n" + + "\"replication_allocation\" = \"tag.location.default: 1\"" + + ")"); + + PlanChecker.from(connectContext) + .analyze("SELECT col_variant_undef_signed_not_null,\n" + + " col_struct,\n" + + " col_variant_undef_signed_not_null[\"c_map_largeint\"]\n" + + " FROM table_20_undef_partitions2_keys3_properties4_distributed_by56") + .rewrite() + .getCascadesContext() + .getRewritePlan(); + } + private void setAccessPathAndAssertType(SlotReference slot, List path, String expectedType) { setAccessPathsAndAssertType(slot, ImmutableList.of(path), expectedType); } From ec03ca8a58b581552e8ba6a758723abb562f2b12 Mon Sep 17 00:00:00 2001 From: 924060929 Date: Fri, 28 Nov 2025 17:39:40 +0800 Subject: [PATCH 2/2] fix --- .../doris/nereids/trees/plans/logical/LogicalOlapScan.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java index 3edc162b5a5948..a334b8ddcc5cc6 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java @@ -445,7 +445,7 @@ public LogicalOlapScan withRelationId(RelationId relationId) { Optional.empty(), Optional.empty(), selectedPartitionIds, false, selectedTabletIds, selectedIndexId, indexSelected, preAggStatus, manuallySpecifiedPartitions, - hints, cacheSlotWithSlotName, cachedOutput, tableSample, directMvScan, + hints, Maps.newHashMap(), Optional.empty(), tableSample, directMvScan, colToSubPathsMap, selectedTabletIds, operativeSlots, virtualColumns, scoreOrderKeys, scoreLimit, annOrderKeys, annLimit, tableAlias); }