Skip to content
Open
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 @@ -117,6 +117,7 @@
import org.apache.doris.nereids.types.DataType;
import org.apache.doris.nereids.types.coercion.CharacterType;
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.qe.SessionVariable;
import org.apache.doris.statistics.AnalysisManager;
import org.apache.doris.statistics.ColumnStatistic;
import org.apache.doris.statistics.ColumnStatisticBuilder;
Expand Down Expand Up @@ -1200,16 +1201,23 @@ public static Optional<String> disableJoinReorderIfStatsInvalid(List<CatalogRela
double rowCount = calculator.getTableRowCount(scan);
// row count not available
if (rowCount == -1) {
LOG.info("disable join reorder since row count not available: "
+ scan.getTable().getNameWithFullQualifiers());
try {
context.getConnectContext().getSessionVariable()
.setVarOnce(SessionVariable.DISABLE_JOIN_REORDER, "true");
LOG.info("disable join reorder since table row count is not available :"
+ scan.getTable().getName());
} catch (Exception e) {
LOG.error("disable NereidsJoinReorderOnce failed", e);
}
return Optional.of("table[" + scan.getTable().getName() + "] row count is invalid");
}
if (scan instanceof OlapScan) {
// ndv abnormal
Optional<String> reason = calculator.checkNdvValidation((OlapScan) scan, rowCount);
if (reason.isPresent()) {
try {
ConnectContext.get().getSessionVariable().disableNereidsJoinReorderOnce();
ConnectContext.get().getSessionVariable()
.setVarOnce(SessionVariable.DISABLE_JOIN_REORDER, "true");
LOG.info("disable join reorder since col stats invalid: "
+ reason.get());
} catch (Exception e) {
Expand Down
14 changes: 14 additions & 0 deletions fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
Original file line number Diff line number Diff line change
Expand Up @@ -3079,5 +3079,19 @@ public boolean isEnableCooldownReplicaAffinity() {
return enableCooldownReplicaAffinity;
}

/**
*
* @return true iff set success
*/
public boolean setVarOnce(String varName, String value) {
try {
setIsSingleSetVar(true);
VariableMgr.setVar(this, new SetVar(varName, new StringLiteral(value)));
return true;
} catch (DdlException e) {
LOG.warn("set onece {} = {} failed", varName, value);
return false;
}
}
}

Loading