Skip to content

Commit

Permalink
forbidden disable check privilege
Browse files Browse the repository at this point in the history
  • Loading branch information
924060929 committed Feb 28, 2024
1 parent 543db2a commit 4f295ff
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
import org.apache.doris.nereids.rules.rewrite.BuildAggForUnion;
import org.apache.doris.nereids.rules.rewrite.CTEInline;
import org.apache.doris.nereids.rules.rewrite.CheckAndStandardizeWindowFunctionAndFrame;
import org.apache.doris.nereids.rules.rewrite.CheckColumnPrivilege;
import org.apache.doris.nereids.rules.rewrite.CheckDataTypes;
import org.apache.doris.nereids.rules.rewrite.CheckMatchExpression;
import org.apache.doris.nereids.rules.rewrite.CheckMultiDistinct;
import org.apache.doris.nereids.rules.rewrite.CheckPrivilege;
import org.apache.doris.nereids.rules.rewrite.CollectFilterAboveConsumer;
import org.apache.doris.nereids.rules.rewrite.CollectProjectAboveConsumer;
import org.apache.doris.nereids.rules.rewrite.ColumnPruning;
Expand Down Expand Up @@ -241,7 +241,7 @@ public class Rewriter extends AbstractBatchJobExecutor {
// 2. and then check the column privileges
// 3. finally, we can eliminate the LogicalView
topic("Inline view and check column privileges",
custom(RuleType.CHECK_COLUMN_PRIVILEGES, CheckColumnPrivilege::new),
custom(RuleType.CHECK_PRIVILEGES, CheckPrivilege::new),
bottomUp(new InlineLogicalView())
),
topic("Eliminate optimization",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public enum RuleType {
REWRITE_CTE_CHILDREN(RuleTypeClass.REWRITE),
COLLECT_FILTER_ON_CONSUMER(RuleTypeClass.REWRITE),
INLINE_VIEW(RuleTypeClass.REWRITE),
CHECK_COLUMN_PRIVILEGES(RuleTypeClass.REWRITE),
CHECK_PRIVILEGES(RuleTypeClass.REWRITE),

COLLECT_FILTER(RuleTypeClass.REWRITE),
COLLECT_JOIN_CONSTRAINT(RuleTypeClass.REWRITE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ private void setVar(SelectHintSetVar selectHint, StatementContext context) {
}
throw new AnalysisException("The nereids is disabled in this sql, fallback to original planner");
}
context.invalidCache(SessionVariable.DISABLE_NEREIDS_RULES);
}

private void extractLeading(SelectHintLeading selectHint, CascadesContext context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
import java.util.Set;
import java.util.stream.Collectors;

/** CheckColumnPrivilege */
public class CheckColumnPrivilege extends ColumnPruning {
/** CheckPrivilege */
public class CheckPrivilege extends ColumnPruning {
private JobContext jobContext;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2611,16 +2611,20 @@ public int getNthOptimizedPlan() {
}

public Set<String> getDisableNereidsRuleNames() {
String checkPrivilege = RuleType.CHECK_PRIVILEGES.name();
return Arrays.stream(disableNereidsRules.split(",[\\s]*"))
.map(rule -> rule.toUpperCase(Locale.ROOT))
.filter(rule -> !StringUtils.equalsIgnoreCase(rule, checkPrivilege))
.collect(ImmutableSet.toImmutableSet());
}

public Set<Integer> getDisableNereidsRules() {
return Arrays.stream(disableNereidsRules.split(",[\\s]*"))
.filter(rule -> !rule.isEmpty())
.map(rule -> rule.toUpperCase(Locale.ROOT))
.map(rule -> RuleType.valueOf(rule).type())
.map(rule -> RuleType.valueOf(rule))
.filter(ruleType -> ruleType != RuleType.CHECK_PRIVILEGES)
.map(RuleType::type)
.collect(ImmutableSet.toImmutableSet());
}

Expand Down

0 comments on commit 4f295ff

Please sign in to comment.