You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2026/04/13 09:06:45 UTC
(doris) branch branch-4.0 updated: branch-4.0: [fix](fe) Fix no_use_cbo_rule hint being silently ignored in EliminateLogicalSelectHint #62358 (#62426)
This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.0 by this push:
new 4187882098e branch-4.0: [fix](fe) Fix no_use_cbo_rule hint being silently ignored in EliminateLogicalSelectHint #62358 (#62426)
4187882098e is described below
commit 4187882098efd62032a0aa3aa05d1d82b672275c
Author: github-actions[bot] <41...@users.noreply.github.com>
AuthorDate: Mon Apr 13 17:06:37 2026 +0800
branch-4.0: [fix](fe) Fix no_use_cbo_rule hint being silently ignored in EliminateLogicalSelectHint #62358 (#62426)
Cherry-picked from #62358
Co-authored-by: feiniaofeiafei <mo...@selectdb.com>
Co-authored-by: Copilot <22...@users.noreply.github.com>
---
.../rules/analysis/EliminateLogicalSelectHint.java | 3 +-
.../analysis/EliminateLogicalSelectHintTest.java | 56 ++++++++++++++++++++++
2 files changed, 58 insertions(+), 1 deletion(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/EliminateLogicalSelectHint.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/EliminateLogicalSelectHint.java
index e659575a485..49db25ca097 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/EliminateLogicalSelectHint.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/EliminateLogicalSelectHint.java
@@ -66,7 +66,8 @@ public class EliminateLogicalSelectHint extends OneRewriteRuleFactory {
} else if (hintName.equalsIgnoreCase("LEADING")) {
extractLeading((SelectHintLeading) hint, ctx.cascadesContext,
ctx.statementContext, selectHintPlan);
- } else if (hintName.equalsIgnoreCase("USE_CBO_RULE")) {
+ } else if (hintName.equalsIgnoreCase("USE_CBO_RULE")
+ || hintName.equalsIgnoreCase("NO_USE_CBO_RULE")) {
extractRule((SelectHintUseCboRule) hint, ctx.statementContext);
} else if (hintName.equalsIgnoreCase("USE_MV")) {
extractMv((SelectHintUseMv) hint, ConnectContext.get().getStatementContext());
diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/EliminateLogicalSelectHintTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/EliminateLogicalSelectHintTest.java
new file mode 100644
index 00000000000..b9e3f0142d1
--- /dev/null
+++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/EliminateLogicalSelectHintTest.java
@@ -0,0 +1,56 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.rules.analysis;
+
+import org.apache.doris.nereids.hint.Hint;
+import org.apache.doris.nereids.hint.UseCboRuleHint;
+import org.apache.doris.nereids.sqltest.SqlTestBase;
+import org.apache.doris.nereids.util.PlanChecker;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * Tests for EliminateLogicalSelectHint, verifying that no_use_cbo_rule hints are correctly
+ * propagated into the statement context after analysis.
+ */
+public class EliminateLogicalSelectHintTest extends SqlTestBase {
+
+ @Test
+ public void testNoUseCboRuleHintIsRecognized() {
+ String sql = "SELECT /*+ no_use_cbo_rule(INFER_SET_OPERATOR_DISTINCT) */ * FROM T1";
+ PlanChecker checker = PlanChecker.from(connectContext).analyze(sql);
+
+ List<Hint> hints = checker.getCascadesContext().getStatementContext().getHints();
+ List<UseCboRuleHint> cboHints = hints.stream()
+ .filter(h -> h instanceof UseCboRuleHint)
+ .map(h -> (UseCboRuleHint) h)
+ .collect(Collectors.toList());
+
+ Assertions.assertFalse(cboHints.isEmpty(),
+ "no_use_cbo_rule hint should be added to statementContext hints");
+ Assertions.assertTrue(cboHints.stream().anyMatch(UseCboRuleHint::isNotUseCboRule),
+ "hint should have isNotUseCboRule=true");
+ Assertions.assertTrue(
+ cboHints.stream().anyMatch(h -> h.getHintName().equalsIgnoreCase("INFER_SET_OPERATOR_DISTINCT")),
+ "hint should carry the rule name INFER_SET_OPERATOR_DISTINCT");
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org