calcite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jh...@apache.org
Subject [2/2] incubator-calcite git commit: Copy identifier when fully-qualifying, so column aliases have the right case
Date Sat, 03 Jan 2015 17:00:22 GMT
Copy identifier when fully-qualifying, so column aliases have the right case


Project: http://git-wip-us.apache.org/repos/asf/incubator-calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/51746517
Tree: http://git-wip-us.apache.org/repos/asf/incubator-calcite/tree/51746517
Diff: http://git-wip-us.apache.org/repos/asf/incubator-calcite/diff/51746517

Branch: refs/heads/master
Commit: 51746517268945ada4751dc602ae61d9181cbe63
Parents: 1390832
Author: julianhyde <jhyde@apache.org>
Authored: Fri Jan 2 20:38:56 2015 -0800
Committer: julianhyde <jhyde@apache.org>
Committed: Fri Jan 2 20:38:56 2015 -0800

----------------------------------------------------------------------
 .../main/java/org/apache/calcite/sql/SqlIdentifier.java   | 10 +++++++---
 .../org/apache/calcite/sql/validate/DelegatingScope.java  |  3 ++-
 2 files changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/51746517/core/src/main/java/org/apache/calcite/sql/SqlIdentifier.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlIdentifier.java b/core/src/main/java/org/apache/calcite/sql/SqlIdentifier.java
index c5e2420..854b18b 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlIdentifier.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlIdentifier.java
@@ -127,12 +127,16 @@ public class SqlIdentifier extends SqlNode {
         : ImmutableList.copyOf(poses);
   }
 
-  /** Modifies one name component of this identifier. */
-  public void setName(int i, String name) {
+  /** Returns an identifier that is the same as this except one modified name.
+   * Does not modify this identifier. */
+  public SqlIdentifier setName(int i, String name) {
     if (!names.get(i).equals(name)) {
       String[] nameArray = names.toArray(new String[names.size()]);
       nameArray[i] = name;
-      names = ImmutableList.copyOf(nameArray);
+      return new SqlIdentifier(ImmutableList.copyOf(nameArray), collation, pos,
+          componentPositions);
+    } else {
+      return this;
     }
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/51746517/core/src/main/java/org/apache/calcite/sql/validate/DelegatingScope.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/validate/DelegatingScope.java b/core/src/main/java/org/apache/calcite/sql/validate/DelegatingScope.java
index 72c533e..dc50668 100644
--- a/core/src/main/java/org/apache/calcite/sql/validate/DelegatingScope.java
+++ b/core/src/main/java/org/apache/calcite/sql/validate/DelegatingScope.java
@@ -194,7 +194,8 @@ public abstract class DelegatingScope implements SqlValidatorScope {
               RESOURCE.columnNotFoundInTable(columnName,
                   identifier.getComponent(0, j).toString()));
         }
-        identifier.setName(j, field.getName()); // normalize case to match defn
+        // normalize case to match definition, in a copy of the identifier
+        identifier = identifier.setName(j, field.getName());
         fromRowType = field.getType();
       }
       return SqlQualified.create(this, i, fromNs, identifier);


Mime
View raw message