Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
package org.apache.doris.analysis;

import org.apache.doris.catalog.TableIf;
import org.apache.doris.info.TableRefInfo;
import org.apache.doris.thrift.TTupleDescriptor;

import com.google.common.base.Joiner;
Expand All @@ -39,14 +38,10 @@ public class TupleDescriptor {

// underlying table, if there is one
private TableIf table;
// underlying table, if there is one
private TableRefInfo ref;

private int tableId = -1;

public TupleDescriptor(TupleId id) {
this.id = id;
this.slots = new ArrayList<SlotDescriptor>();
this.slots = new ArrayList<>();
this.idToSlotDesc = new HashMap<>();
}

Expand All @@ -59,14 +54,6 @@ public TupleId getId() {
return id;
}

public TableRefInfo getRef() {
return ref;
}

public void setRef(TableRefInfo tableRefInfo) {
ref = tableRefInfo;
}

public ArrayList<SlotDescriptor> getSlots() {
return slots;
}
Expand Down Expand Up @@ -111,14 +98,11 @@ public void setTable(TableIf tbl) {
}

public TTupleDescriptor toThrift() {
TTupleDescriptor ttupleDesc = new TTupleDescriptor(id.asInt(), 0, 0);
TTupleDescriptor tTupleDesc = new TTupleDescriptor(id.asInt(), 0, 0);
if (table != null && table.getId() >= 0) {
ttupleDesc.setTableId((int) table.getId());
}
if (tableId > 0) {
ttupleDesc.setTableId(tableId);
tTupleDesc.setTableId((int) table.getId());
}
return ttupleDesc;
return tTupleDesc;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Deque;
import java.util.HashMap;
import java.util.LinkedList;
Expand Down Expand Up @@ -450,14 +449,7 @@ private void backup(Repository repository, Database db, BackupCommand command) t
tableRefInfoList.addAll(tableRefInfos);
} else {
for (String tableName : tableNames) {
TableRefInfo tableRefInfo = new TableRefInfo(new TableNameInfo(db.getFullName(), tableName),
null,
null,
null,
new ArrayList<>(),
null,
null,
new ArrayList<>());
TableRefInfo tableRefInfo = new TableRefInfo(new TableNameInfo(db.getFullName(), tableName), null);
tableRefInfoList.add(tableRefInfo);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -666,10 +666,6 @@ public void setQueryTableSnapshot(TableSnapshot tableSnapshot) {
}

public TableSnapshot getQueryTableSnapshot() {
TableSnapshot snapshot = desc.getRef().getTableSnapShot();
if (snapshot != null) {
return snapshot;
}
return this.tableSnapshot;
}

Expand All @@ -678,10 +674,6 @@ public void setScanParams(TableScanParams scanParams) {
}

public TableScanParams getScanParams() {
TableScanParams scan = desc.getRef().getScanParams();
if (scan != null) {
return scan;
}
return this.scanParams;
}

Expand Down

This file was deleted.

25 changes: 1 addition & 24 deletions fe/fe-core/src/main/java/org/apache/doris/info/TableRefInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,30 +55,7 @@ public class TableRefInfo {
* constructor
*/
public TableRefInfo(TableNameInfo tableNameInfo, String tableAlias) {
this(tableNameInfo, null, tableAlias);
}

public TableRefInfo(TableNameInfo tableNameInfo, PartitionNamesInfo partitionNamesInfo, String tableAlias) {
this(tableNameInfo, partitionNamesInfo, tableAlias, new ArrayList<>());
}

public TableRefInfo(TableNameInfo tableNameInfo, PartitionNamesInfo partitionNamesInfo,
String tableAlias, List<String> relationHints) {
this(tableNameInfo, partitionNamesInfo, new ArrayList<>(), tableAlias, null, relationHints);
}

public TableRefInfo(TableNameInfo tableNameInfo, PartitionNamesInfo partitionNamesInfo,
List<Long> tabletIdList, String tableAlias,
TableSample tableSample, List<String> relationHints) {
this(tableNameInfo, null, partitionNamesInfo, tabletIdList, tableAlias, tableSample, relationHints);
}

public TableRefInfo(TableNameInfo tableNameInfo, TableSnapshot tableSnapShot,
PartitionNamesInfo partitionNamesInfo,
List<Long> tabletIdList, String tableAlias,
TableSample tableSample, List<String> relationHints) {
this(tableNameInfo, null, tableSnapShot, partitionNamesInfo,
tabletIdList, tableAlias, tableSample, relationHints);
this(tableNameInfo, null, null, null, new ArrayList<>(), tableAlias, null, new ArrayList<>());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@
import org.apache.doris.fs.DirectoryLister;
import org.apache.doris.fs.FileSystemDirectoryLister;
import org.apache.doris.fs.TransactionScopeCachingDirectoryListerFactory;
import org.apache.doris.info.BaseTableRefInfo;
import org.apache.doris.info.TableNameInfo;
import org.apache.doris.info.TableRefInfo;
import org.apache.doris.nereids.exceptions.AnalysisException;
import org.apache.doris.nereids.processor.post.runtimefilterv2.RuntimeFilterV2;
import org.apache.doris.nereids.properties.DistributionSpec;
Expand Down Expand Up @@ -770,7 +767,7 @@ public PlanFragment visitPhysicalFileScan(PhysicalFileScan fileScan, PlanTransla
fileScan.getTableSnapshot().ifPresent(fileQueryScanNode::setQueryTableSnapshot);
fileScan.getScanParams().ifPresent(fileQueryScanNode::setScanParams);
}
return getPlanFragmentForPhysicalFileScan(fileScan, context, scanNode, table, tupleDescriptor);
return getPlanFragmentForPhysicalFileScan(fileScan, context, scanNode);
}

@Override
Expand Down Expand Up @@ -846,21 +843,16 @@ public PlanFragment visitPhysicalHudiScan(PhysicalHudiScan hudiScan, PlanTransla
hudiScanNode.setQueryTableSnapshot(hudiScan.getTableSnapshot().get());
}
hudiScanNode.setSelectedPartitions(hudiScan.getSelectedPartitions());
return getPlanFragmentForPhysicalFileScan(hudiScan, context, hudiScanNode, table, tupleDescriptor);
return getPlanFragmentForPhysicalFileScan(hudiScan, context, hudiScanNode);
}

@NotNull
private PlanFragment getPlanFragmentForPhysicalFileScan(PhysicalFileScan fileScan, PlanTranslatorContext context,
ScanNode scanNode,
ExternalTable table, TupleDescriptor tupleDescriptor) {
ScanNode scanNode) {
scanNode.setNereidsId(fileScan.getId());
context.getNereidsIdToPlanNodeIdMap().put(fileScan.getId(), scanNode.getId());
scanNode.setPushDownAggNoGrouping(context.getRelationPushAggOp(fileScan.getRelationId()));

TableNameInfo tableNameInfo = new TableNameInfo(null, "", "");
TableRefInfo ref = new TableRefInfo(tableNameInfo, null, null);
BaseTableRefInfo tableRefInfo = new BaseTableRefInfo(ref, tableNameInfo, table);
tupleDescriptor.setRef(tableRefInfo);
if (fileScan.getStats() != null) {
scanNode.setCardinality((long) fileScan.getStats().getRowCount());
}
Expand All @@ -885,10 +877,6 @@ public PlanFragment visitPhysicalJdbcScan(PhysicalJdbcScan jdbcScan, PlanTransla
jdbcScanNode.setNereidsId(jdbcScan.getId());
context.getNereidsIdToPlanNodeIdMap().put(jdbcScan.getId(), jdbcScanNode.getId());

TableNameInfo tableNameInfo = new TableNameInfo(null, "", "");
TableRefInfo ref = new TableRefInfo(tableNameInfo, null, null);
BaseTableRefInfo tableRefInfo = new BaseTableRefInfo(ref, tableNameInfo, table);
tupleDescriptor.setRef(tableRefInfo);
if (jdbcScan.getStats() != null) {
jdbcScanNode.setCardinality((long) jdbcScan.getStats().getRowCount());
}
Expand Down Expand Up @@ -981,10 +969,6 @@ private PlanFragment computePhysicalOlapScan(PhysicalOlapScan olapScan, PlanTran
}
}
// TODO: Do we really need tableName here?
TableNameInfo tableName = new TableNameInfo(null, "", "");
TableRefInfo ref = new TableRefInfo(tableName, null, null);
BaseTableRefInfo tableRefInfo = new BaseTableRefInfo(ref, tableName, olapTable);
tupleDescriptor.setRef(tableRefInfo);
olapScanNode.setSelectedPartitionIds(olapScan.getSelectedPartitionIds());
olapScanNode.setNereidsPrunedTabletIds(new LinkedHashSet<>(olapScan.getSelectedTabletIds()));
if (olapScan.getTableSample().isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import org.apache.doris.catalog.Replica;
import org.apache.doris.catalog.ScalarType;
import org.apache.doris.catalog.Tablet;
import org.apache.doris.catalog.info.PartitionNamesInfo;
import org.apache.doris.cloud.qe.ComputeGroupException;
import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.Config;
Expand Down Expand Up @@ -334,22 +333,10 @@ protected void computeNumNodes() {
}


private Collection<Long> partitionPrune(PartitionInfo partitionInfo,
PartitionNamesInfo partitionNamesInfo) throws AnalysisException {
private Collection<Long> partitionPrune(PartitionInfo partitionInfo) throws AnalysisException {
PartitionPruner partitionPruner = null;
Map<Long, PartitionItem> keyItemMap;
if (partitionNamesInfo != null) {
keyItemMap = Maps.newHashMap();
for (String partName : partitionNamesInfo.getPartitionNames()) {
Partition partition = olapTable.getPartition(partName, partitionNamesInfo.isTemp());
if (partition == null) {
ErrorReport.reportAnalysisException(ErrorCode.ERR_NO_SUCH_PARTITION, partName);
}
keyItemMap.put(partition.getId(), partitionInfo.getItem(partition.getId()));
}
} else {
keyItemMap = partitionInfo.getIdToItem(false);
}
keyItemMap = partitionInfo.getIdToItem(false);
if (partitionInfo.getType() == PartitionType.RANGE) {
if (isPointQuery() && partitionInfo.getPartitionColumns().size() == 1) {
// short circuit, a quick path to find partition
Expand Down Expand Up @@ -698,10 +685,9 @@ private boolean isEnableCooldownReplicaAffinity(ConnectContext connectContext) {
private void computePartitionInfo() throws AnalysisException {
long start = System.currentTimeMillis();
// Step1: compute partition ids
PartitionNamesInfo partitionNames = desc.getRef().getPartitionNamesInfo();
PartitionInfo partitionInfo = olapTable.getPartitionInfo();
if (partitionInfo.getType() == PartitionType.RANGE || partitionInfo.getType() == PartitionType.LIST) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This drops the only FE-side restriction that preserves explicitly specified partitions when recomputes partition ids. Nereids still builds with for queries like (), and later calls . After this change, that method always starts from all partitions, so the manual partition subset is lost on this path. Please keep the explicit-partition filter here, or preserve the preselected partition set when recomputing.

selectedPartitionIds = partitionPrune(partitionInfo, partitionNames);
selectedPartitionIds = partitionPrune(partitionInfo);
} else {
selectedPartitionIds = olapTable.getPartitionIds();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3916,13 +3916,7 @@ private TRestoreSnapshotResult restoreSnapshotImpl(TRestoreSnapshotRequest reque
if (request.isSetTableRefs()) {
for (TTableRef tTableRef : request.getTableRefs()) {
tableRefs.add(new TableRefInfo(new TableNameInfo(tTableRef.getTable()),
null,
null,
null,
new ArrayList<>(),
tTableRef.getAliasName(),
null,
new ArrayList<>()));
tTableRef.getAliasName()));
}
}

Expand Down
Loading