This is an automated email from the ASF dual-hosted git repository. kxiao pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push: new 513385020c8 [fix](Nereids) bound error when in diff value of table name case config (#25957) (#26257) 513385020c8 is described below commit 513385020c8359832411bd0d15dd1f4e2c1deff6 Author: morrySnow <101034200+morrys...@users.noreply.github.com> AuthorDate: Thu Nov 2 14:11:12 2023 +0800 [fix](Nereids) bound error when in diff value of table name case config (#25957) (#26257) - when lower_case_table_names = 0, reference of table name should case sensitive - when lower_case_table_names = 1 and 2 cte name should case insensitive more details, please read doris doc: https://doris.apache.org/docs/advanced/variables#supported-variables --- .../main/java/org/apache/doris/nereids/CTEContext.java | 8 +++++++- .../apache/doris/nereids/rules/analysis/SlotBinder.java | 15 ++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/CTEContext.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/CTEContext.java index 9653811492e..1cca6a32d9d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/CTEContext.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/CTEContext.java @@ -17,6 +17,7 @@ package org.apache.doris.nereids; +import org.apache.doris.common.Config; import org.apache.doris.nereids.exceptions.AnalysisException; import org.apache.doris.nereids.trees.expressions.CTEId; import org.apache.doris.nereids.trees.plans.Plan; @@ -25,6 +26,7 @@ import org.apache.doris.nereids.trees.plans.logical.LogicalSubQueryAlias; import com.google.common.collect.ImmutableMap; +import java.util.Locale; import java.util.Map; import java.util.Optional; import javax.annotation.Nullable; @@ -54,7 +56,8 @@ public class CTEContext { if ((parsedPlan == null && previousCteContext != null) || (parsedPlan != null && previousCteContext == null)) { throw new AnalysisException("Only first CteContext can contains null cte plan or previousCteContext"); } - this.name = parsedPlan == null ? null : parsedPlan.getAlias(); + this.name = parsedPlan == null ? null : Config.lower_case_table_names != 0 + ? parsedPlan.getAlias().toLowerCase(Locale.ROOT) : parsedPlan.getAlias(); this.cteContextMap = previousCteContext == null ? ImmutableMap.of() : ImmutableMap.<String, CTEContext>builder() @@ -83,6 +86,9 @@ public class CTEContext { * findCTEContext */ public Optional<CTEContext> findCTEContext(String cteName) { + if (Config.lower_case_table_names != 0) { + cteName = cteName.toLowerCase(Locale.ROOT); + } if (cteName.equals(name)) { return Optional.of(this); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/SlotBinder.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/SlotBinder.java index 303254868c8..4b5b977b0aa 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/SlotBinder.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/SlotBinder.java @@ -19,6 +19,7 @@ package org.apache.doris.nereids.rules.analysis; import org.apache.doris.analysis.SetType; import org.apache.doris.cluster.ClusterNamespace; +import org.apache.doris.common.Config; import org.apache.doris.common.DdlException; import org.apache.doris.common.util.Util; import org.apache.doris.nereids.CascadesContext; @@ -284,14 +285,14 @@ class SlotBinder extends SubExprAnalyzer { } if (namePartsSize == 2) { String qualifierTableName = boundSlot.getQualifier().get(qualifierSize - 1); - return qualifierTableName.equalsIgnoreCase(nameParts.get(0)) + return sameTableName(qualifierTableName, nameParts.get(0)) && boundSlot.getName().equalsIgnoreCase(nameParts.get(1)); } if (nameParts.size() == 3) { String qualifierTableName = boundSlot.getQualifier().get(qualifierSize - 1); String qualifierDbName = boundSlot.getQualifier().get(qualifierSize - 2); return compareDbNameIgnoreClusterName(nameParts.get(0), qualifierDbName) - && qualifierTableName.equalsIgnoreCase(nameParts.get(1)) + && sameTableName(qualifierTableName, nameParts.get(1)) && boundSlot.getName().equalsIgnoreCase(nameParts.get(2)); } // catalog.db.table.column @@ -301,7 +302,7 @@ class SlotBinder extends SubExprAnalyzer { String qualifierCatalogName = boundSlot.getQualifier().get(qualifierSize - 3); return qualifierCatalogName.equalsIgnoreCase(nameParts.get(0)) && compareDbNameIgnoreClusterName(nameParts.get(1), qualifierDbName) - && qualifierTableName.equalsIgnoreCase(nameParts.get(2)) + && sameTableName(qualifierTableName, nameParts.get(2)) && boundSlot.getName().equalsIgnoreCase(nameParts.get(3)); } //TODO: handle name parts more than three. @@ -309,4 +310,12 @@ class SlotBinder extends SubExprAnalyzer { + StringUtils.join(nameParts, ".")); }).collect(Collectors.toList()); } + + private boolean sameTableName(String boundSlot, String unboundSlot) { + if (Config.lower_case_table_names != 1) { + return boundSlot.equals(unboundSlot); + } else { + return boundSlot.equalsIgnoreCase(unboundSlot); + } + } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org