Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
englefly committed Oct 14, 2024
1 parent bc9b87d commit edec83c
Show file tree
Hide file tree
Showing 3 changed files with 305 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public static void disableJoinReorderIfTableRowCountNotAvailable(
StatsCalculator calculator = new StatsCalculator(context);
for (LogicalOlapScan scan : scans) {
double rowCount = calculator.getOlapTableRowCount(scan);
if (rowCount == -1 && ConnectContext.get() != null) {
if ((rowCount == -1 || !calculator.checkNdvValidation(scan)) && ConnectContext.get() != null) {
try {
ConnectContext.get().getSessionVariable().disableNereidsJoinReorderOnce();
LOG.info("disable join reorder since row count not available: "
Expand Down Expand Up @@ -403,6 +403,19 @@ private double getOlapTableRowCount(OlapScan olapScan) {
return rowCount;
}

// check validation of ndv.
private boolean checkNdvValidation(OlapScan olapScan) {
for (Slot slot : ((Plan) olapScan).getOutput()) {
if (isVisibleSlotReference(slot)) {
ColumnStatistic cache = getColumnStatsFromTableCache((CatalogRelation) olapScan, (SlotReference) slot);
if (!cache.isUnKnown && cache.ndv == 0 && cache.count != cache.numNulls) {
return false;
}
}
}
return true;
}

private Statistics computeOlapScan(OlapScan olapScan) {
OlapTable olapTable = olapScan.getTable();
double tableRowCount = getOlapTableRowCount(olapScan);
Expand Down
Loading

0 comments on commit edec83c

Please sign in to comment.