There is a bug of direct select mv with specified partitions. Planner will fail to find the mv column name. Because we need to create the LogicalOlapScan object using the given mv instead of the base table. ``` mysql> SELECT mv_id from part8 index mv1 partition p1; ERROR 1105 (HY000): errCode = 2, detailMessage = Unknown column 'mv_id' in 'table list' in PROJECT clause ``` This pr is to fix this. backport: https://github.com/apache/doris/pull/36817
This commit is contained in:
@ -188,12 +188,13 @@ public class BindRelation extends OneAnalysisRuleFactory {
|
||||
LogicalOlapScan scan;
|
||||
List<Long> partIds = getPartitionIds(table, unboundRelation);
|
||||
List<Long> tabletIds = unboundRelation.getTabletIds();
|
||||
if (!CollectionUtils.isEmpty(partIds)) {
|
||||
if (!CollectionUtils.isEmpty(partIds) && !unboundRelation.getIndexName().isPresent()) {
|
||||
scan = new LogicalOlapScan(unboundRelation.getRelationId(),
|
||||
(OlapTable) table, tableQualifier, partIds,
|
||||
tabletIds, unboundRelation.getHints(), unboundRelation.getTableSample());
|
||||
} else {
|
||||
Optional<String> indexName = unboundRelation.getIndexName();
|
||||
// For direct mv scan.
|
||||
if (indexName.isPresent()) {
|
||||
OlapTable olapTable = (OlapTable) table;
|
||||
Long indexId = olapTable.getIndexIdByName(indexName.get());
|
||||
@ -207,8 +208,10 @@ public class BindRelation extends OneAnalysisRuleFactory {
|
||||
: PreAggStatus.off("For direct index scan.");
|
||||
|
||||
scan = new LogicalOlapScan(unboundRelation.getRelationId(),
|
||||
(OlapTable) table, tableQualifier, tabletIds, indexId,
|
||||
preAggStatus, unboundRelation.getHints(), unboundRelation.getTableSample());
|
||||
(OlapTable) table, tableQualifier, tabletIds,
|
||||
CollectionUtils.isEmpty(partIds) ? ((OlapTable) table).getPartitionIds() : partIds, indexId,
|
||||
preAggStatus, CollectionUtils.isEmpty(partIds) ? ImmutableList.of() : partIds,
|
||||
unboundRelation.getHints(), unboundRelation.getTableSample());
|
||||
} else {
|
||||
scan = new LogicalOlapScan(unboundRelation.getRelationId(),
|
||||
(OlapTable) table, tableQualifier, tabletIds, unboundRelation.getHints(),
|
||||
|
||||
@ -200,8 +200,10 @@ public class MaterializedViewUtils {
|
||||
materializedView,
|
||||
materializedView.getFullQualifiers(),
|
||||
ImmutableList.of(),
|
||||
materializedView.getPartitionIds(),
|
||||
materializedView.getBaseIndexId(),
|
||||
PreAggStatus.on(),
|
||||
ImmutableList.of(),
|
||||
// this must be empty, or it will be used to sample
|
||||
ImmutableList.of(),
|
||||
Optional.empty());
|
||||
|
||||
@ -146,12 +146,12 @@ public class LogicalOlapScan extends LogicalCatalogRelation implements OlapScan
|
||||
}
|
||||
|
||||
public LogicalOlapScan(RelationId id, OlapTable table, List<String> qualifier, List<Long> tabletIds,
|
||||
long selectedIndexId, PreAggStatus preAggStatus, List<String> hints,
|
||||
Optional<TableSample> tableSample) {
|
||||
List<Long> selectedPartitionIds, long selectedIndexId, PreAggStatus preAggStatus,
|
||||
List<Long> specifiedPartitions, List<String> hints, Optional<TableSample> tableSample) {
|
||||
this(id, table, qualifier, Optional.empty(), Optional.empty(),
|
||||
table.getPartitionIds(), false, tabletIds,
|
||||
selectedPartitionIds, false, tabletIds,
|
||||
selectedIndexId, true, preAggStatus,
|
||||
ImmutableList.of(), hints, Maps.newHashMap(), tableSample, true, ImmutableMap.of());
|
||||
specifiedPartitions, hints, Maps.newHashMap(), tableSample, true, ImmutableMap.of());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user