drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject drill git commit: DRILL-4707: Fix memory leak or incorrect query result in case two column names are case-insensitive identical.
Date Thu, 30 Jun 2016 01:05:27 GMT
Repository: drill
Updated Branches:
  refs/heads/master b49ea3ebd -> 05c42eae7


DRILL-4707: Fix memory leak or incorrect query result in case two column names are case-insensitive
identical.

Fix is mainly in CALCITE-528

Close apache/drill#515


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/05c42eae
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/05c42eae
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/05c42eae

Branch: refs/heads/master
Commit: 05c42eae79ce3e309028b3824f9449b98e329f29
Parents: b49ea3e
Author: Jinfeng Ni <jni@apache.org>
Authored: Sun Jun 5 17:37:22 2016 -0700
Committer: Jinfeng Ni <jni@apache.org>
Committed: Wed Jun 29 08:15:13 2016 -0700

----------------------------------------------------------------------
 .../drill/exec/planner/sql/SqlConverter.java    |  5 ++
 .../planner/sql/handlers/DefaultSqlHandler.java |  5 +-
 .../org/apache/drill/TestCaseSensitivity.java   | 55 ++++++++++++++++++++
 pom.xml                                         |  2 +-
 4 files changed, 65 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/05c42eae/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/SqlConverter.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/SqlConverter.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/SqlConverter.java
index 3dfea6f..a7fcf99 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/SqlConverter.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/SqlConverter.java
@@ -223,6 +223,11 @@ public class SqlConverter {
       return 38;
     }
 
+    @Override
+    public boolean isSchemaCaseSensitive() {
+      // Drill uses case-insensitive and case-preserve policy
+      return false;
+    }
   }
 
   public RelNode toRel(

http://git-wip-us.apache.org/repos/asf/drill/blob/05c42eae/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/DefaultSqlHandler.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/DefaultSqlHandler.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/DefaultSqlHandler.java
index 341bae2..fda0a1d 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/DefaultSqlHandler.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/DefaultSqlHandler.java
@@ -651,7 +651,10 @@ public class DefaultSqlHandler extends AbstractSqlHandler {
       projections.add(b.makeInputRef(rel, i));
     }
 
-    final List<String> fieldNames2 = SqlValidatorUtil.uniquify(validatedRowType.getFieldNames(),
SqlValidatorUtil.F_SUGGESTER2);
+    final List<String> fieldNames2 = SqlValidatorUtil.uniquify(
+        validatedRowType.getFieldNames(),
+        SqlValidatorUtil.F_SUGGESTER2,
+        rel.getCluster().getTypeFactory().getTypeSystem().isSchemaCaseSensitive());
 
     RelDataType newRowType = RexUtil.createStructType(rel.getCluster().getTypeFactory(),
projections, fieldNames2);
 

http://git-wip-us.apache.org/repos/asf/drill/blob/05c42eae/exec/java-exec/src/test/java/org/apache/drill/TestCaseSensitivity.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestCaseSensitivity.java b/exec/java-exec/src/test/java/org/apache/drill/TestCaseSensitivity.java
new file mode 100644
index 0000000..9953e9c
--- /dev/null
+++ b/exec/java-exec/src/test/java/org/apache/drill/TestCaseSensitivity.java
@@ -0,0 +1,55 @@
+/**
+ * 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.drill;
+
+import org.junit.Test;
+
+public class TestCaseSensitivity extends BaseTestQuery {
+
+  @Test //DRILL-4707
+  public void testCaseSenWhenQueryTwoDiffCols() throws Exception {
+    // 1st column integer, 2nd column varchar
+    testBuilder()
+        .sqlQuery("select n_nationkey as XYZ, n_name as xyz FROM cp.`tpch/nation.parquet`
order by n_nationkey limit 1")
+        .ordered()
+        .baselineColumns("XYZ", "xyz0")
+        .baselineValues(0, "ALGERIA")
+        .build()
+        .run();
+
+    // both columns integer type
+    testBuilder()
+        .sqlQuery("select n_nationkey as XYZ, n_regionkey as xyz FROM cp.`tpch/nation.parquet`
order by n_nationkey limit 1")
+        .ordered()
+        .baselineColumns("XYZ", "xyz0")
+        .baselineValues(0, 0)
+        .build()
+        .run();
+
+    // join two tables. 1st column integer, 2nd column varchar
+    testBuilder()
+        .sqlQuery("select n.n_nationkey as XYZ, r.r_name as xyz from cp.`tpch/nation.parquet`
n, cp.`tpch/region.parquet` r where n.n_regionkey = r.r_regionkey order by n.n_nationkey limit
1")
+        .ordered()
+        .baselineColumns("XYZ", "xyz0")
+        .baselineValues(0, "AFRICA")
+        .build()
+        .run();
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/drill/blob/05c42eae/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 824361f..85b834e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1287,7 +1287,7 @@
           <dependency>
             <groupId>org.apache.calcite</groupId>
             <artifactId>calcite-core</artifactId>
-            <version>1.4.0-drill-r11</version>
+            <version>1.4.0-drill-r12</version>
             <exclusions>
               <exclusion>
                 <groupId>org.jgrapht</groupId>


Mime
View raw message