Skip to content

Commit

Permalink
ignore partition row count if table row count is registerred
Browse files Browse the repository at this point in the history
  • Loading branch information
englefly committed Jan 7, 2025
1 parent a539e22 commit 035e37a
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,12 @@ private double getTableRowCount(CatalogRelation scan) {
}
}

private boolean isRegisteredRowCount(OlapScan olapScan) {
AnalysisManager analysisManager = Env.getCurrentEnv().getAnalysisManager();
TableStatsMeta tableMeta = analysisManager.findTableStatsStatus(olapScan.getTable().getId());
return tableMeta != null && tableMeta.userInjected;
}

/**
* if the table is not analyzed and BE does not report row count, return -1
*/
Expand Down Expand Up @@ -554,7 +560,8 @@ private Statistics computeOlapScan(OlapScan olapScan) {
}
}

if (olapScan.getSelectedPartitionIds().size() < olapScan.getTable().getPartitionNum()) {
if (!isRegisteredRowCount(olapScan)
&& olapScan.getSelectedPartitionIds().size() < olapScan.getTable().getPartitionNum()) {
// partition pruned
// try to use selected partition stats, if failed, fall back to table stats
double selectedPartitionsRowCount = getSelectedPartitionRowCount(olapScan, tableRowCount);
Expand Down

0 comments on commit 035e37a

Please sign in to comment.