This is an automated email from the ASF dual-hosted git repository.

mbudiu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git

commit 214345eacf325f18844c456090fcaf75f92c9ee5
Author: suibianwanwan <[email protected]>
AuthorDate: Mon Oct 7 16:38:51 2024 +0800

    Introduced bug guard for [CALCITE-6328]
---
 .../org/apache/calcite/rel/rules/SortRemoveConstantKeysRule.java   | 7 +++++++
 core/src/main/java/org/apache/calcite/util/Bug.java                | 6 ++++++
 2 files changed, 13 insertions(+)

diff --git 
a/core/src/main/java/org/apache/calcite/rel/rules/SortRemoveConstantKeysRule.java
 
b/core/src/main/java/org/apache/calcite/rel/rules/SortRemoveConstantKeysRule.java
index 2a99652363..1c85ee784e 100644
--- 
a/core/src/main/java/org/apache/calcite/rel/rules/SortRemoveConstantKeysRule.java
+++ 
b/core/src/main/java/org/apache/calcite/rel/rules/SortRemoveConstantKeysRule.java
@@ -27,6 +27,7 @@ import org.apache.calcite.rel.RelNode;
 import org.apache.calcite.rel.core.Sort;
 import org.apache.calcite.rel.metadata.RelMetadataQuery;
 import org.apache.calcite.rex.RexBuilder;
+import org.apache.calcite.util.Bug;
 
 import org.immutables.value.Value;
 
@@ -51,6 +52,12 @@ public class SortRemoveConstantKeysRule
   }
 
   @Override public void onMatch(RelOptRuleCall call) {
+    if (!Bug.CALCITE_6611_FIXED) {
+      if (call.getPlanner().getRelTraitDefs()
+          .contains(RelCollationTraitDef.INSTANCE)) {
+        return;
+      }
+    }
     final Sort sort = call.rel(0);
     final RelMetadataQuery mq = call.getMetadataQuery();
     final RelNode input = sort.getInput();
diff --git a/core/src/main/java/org/apache/calcite/util/Bug.java 
b/core/src/main/java/org/apache/calcite/util/Bug.java
index 7c4f1c7524..fd9079331d 100644
--- a/core/src/main/java/org/apache/calcite/util/Bug.java
+++ b/core/src/main/java/org/apache/calcite/util/Bug.java
@@ -220,6 +220,12 @@ public abstract class Bug {
    * is fixed. */
   public static final boolean CALCITE_6328_FIXED = false;
 
+  /** Whether
+   * <a 
href="https://issues.apache.org/jira/browse/CALCITE-6611";>[CALCITE-6611]
+   * Rules that modify the sort collation cannot be applied in 
VolcanoPlanner</a>
+   * is fixed. */
+  public static final boolean CALCITE_6611_FIXED = false;
+
   /**
    * Use this to flag temporary code.
    */

Reply via email to