impala-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mjac...@apache.org
Subject [5/5] incubator-impala git commit: IMPALA-4056: Fix toSql() of DistributeParam
Date Fri, 02 Sep 2016 20:13:45 GMT
IMPALA-4056: Fix toSql() of DistributeParam

This commit fixes two issues in toSql() of DistributeParam:
1. string literals were not quoted
2. range partition split rows were not printed.
Besides, this commit fixes a small issue in run-hive-server.sh

Change-Id: I984a63a24f02670347b0e1efceb864d265d1f931
Reviewed-on: http://gerrit.cloudera.org:8080/4195
Reviewed-by: Matthew Jacobs <mj@cloudera.com>
Reviewed-by: Alex Behm <alex.behm@cloudera.com>
Tested-by: Internal Jenkins


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

Branch: refs/heads/master
Commit: 052d3cc8dd893f2225accacde3c917aac0c1cfcd
Parents: ab9e54b
Author: Yuanhao Luo <luoyuanhao@software.ict.ac.cn>
Authored: Thu Sep 1 22:17:55 2016 +0800
Committer: Internal Jenkins <cloudera-hudson@gerrit.cloudera.org>
Committed: Fri Sep 2 20:11:27 2016 +0000

----------------------------------------------------------------------
 .../cloudera/impala/analysis/DistributeParam.java    | 14 +++++++-------
 .../com/cloudera/impala/analysis/AnalyzeDDLTest.java | 15 ++++++++++++++-
 testdata/bin/run-hive-server.sh                      |  2 +-
 .../queries/QueryTest/kudu_partition_ddl.test        | 13 -------------
 4 files changed, 22 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/052d3cc8/fe/src/main/java/com/cloudera/impala/analysis/DistributeParam.java
----------------------------------------------------------------------
diff --git a/fe/src/main/java/com/cloudera/impala/analysis/DistributeParam.java b/fe/src/main/java/com/cloudera/impala/analysis/DistributeParam.java
index 7c57593..e718d6b 100644
--- a/fe/src/main/java/com/cloudera/impala/analysis/DistributeParam.java
+++ b/fe/src/main/java/com/cloudera/impala/analysis/DistributeParam.java
@@ -153,12 +153,12 @@ public class DistributeParam implements ParseNode {
   @Override
   public String toSql() {
     if (num_buckets_ == NO_BUCKETS) {
-      StringBuilder builder = new StringBuilder();
+      List<String> splitRowStrings = Lists.newArrayList();
       for (ArrayList<LiteralExpr> splitRow : splitRows_) {
-        splitRowToString(splitRow);
+        splitRowStrings.add(splitRowToString(splitRow));
       }
       return String.format("RANGE(%s) INTO RANGES(%s)", Joiner.on(", ").join(columns_),
-          builder.toString());
+          Joiner.on(", ").join(splitRowStrings));
     } else {
       return String.format("HASH(%s) INTO %d BUCKETS", Joiner.on(", ").join(columns_),
           num_buckets_);
@@ -167,13 +167,13 @@ public class DistributeParam implements ParseNode {
 
   private String splitRowToString(ArrayList<LiteralExpr> splitRow) {
     StringBuilder builder = new StringBuilder();
-    builder.append("[");
+    builder.append("(");
     List<String> rangeElementStrings = Lists.newArrayList();
     for (LiteralExpr rangeElement : splitRow) {
-      rangeElementStrings.add(rangeElement.getStringValue());
+      rangeElementStrings.add(rangeElement.toSql());
     }
-    builder.append(Joiner.on(",").join(rangeElementStrings));
-    builder.append("]");
+    builder.append(Joiner.on(", ").join(rangeElementStrings));
+    builder.append(")");
     return builder.toString();
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/052d3cc8/fe/src/test/java/com/cloudera/impala/analysis/AnalyzeDDLTest.java
----------------------------------------------------------------------
diff --git a/fe/src/test/java/com/cloudera/impala/analysis/AnalyzeDDLTest.java b/fe/src/test/java/com/cloudera/impala/analysis/AnalyzeDDLTest.java
index 6e57ccb..f998e91 100644
--- a/fe/src/test/java/com/cloudera/impala/analysis/AnalyzeDDLTest.java
+++ b/fe/src/test/java/com/cloudera/impala/analysis/AnalyzeDDLTest.java
@@ -1811,7 +1811,20 @@ public class AnalyzeDDLTest extends FrontendTestBase {
         "'storage_handler'='com.cloudera.kudu.hive.KuduStorageHandler', " +
         "'kudu.table_name'='tab'," +
         "'kudu.master_addresses' = '127.0.0.1:8080', " +
-        "'kudu.key_columns' = 'a,b,c')");
+        "'kudu.key_columns' = 'a,b,c'" +
+        ")");
+
+    // Each split row size should equals to the number of range columns.
+    AnalysisError("create table tab (a int, b int, c int, d int) " +
+        "distribute by range(a) split rows ((1,'extra_val'),(2),(3)) " +
+        "tblproperties (" +
+        "'storage_handler'='com.cloudera.kudu.hive.KuduStorageHandler', " +
+        "'kudu.table_name'='tab'," +
+        "'kudu.master_addresses' = '127.0.0.1:8080', " +
+        "'kudu.key_columns' = 'a,b,c'" +
+        ")",
+        "SPLIT ROWS has different size than number of projected key columns: 1. " +
+        "Split row: (1, 'extra_val')");
 
     // No float split keys
     AnalysisError("create table tab (a int, b int, c int, d int) " +

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/052d3cc8/testdata/bin/run-hive-server.sh
----------------------------------------------------------------------
diff --git a/testdata/bin/run-hive-server.sh b/testdata/bin/run-hive-server.sh
index 39b2ffd..530b804 100755
--- a/testdata/bin/run-hive-server.sh
+++ b/testdata/bin/run-hive-server.sh
@@ -51,7 +51,7 @@ do
       ;;
     -help|-h|*)
       echo "run-hive-server.sh : Starts the hive server and the metastore."
-      echo "[-metastore_only] : Only starts the hive metastore."
+      echo "[-only_metastore] : Only starts the hive metastore."
       exit 1;
       ;;
     esac

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/052d3cc8/testdata/workloads/functional-query/queries/QueryTest/kudu_partition_ddl.test
----------------------------------------------------------------------
diff --git a/testdata/workloads/functional-query/queries/QueryTest/kudu_partition_ddl.test
b/testdata/workloads/functional-query/queries/QueryTest/kudu_partition_ddl.test
index 9651979..e5b2a95 100644
--- a/testdata/workloads/functional-query/queries/QueryTest/kudu_partition_ddl.test
+++ b/testdata/workloads/functional-query/queries/QueryTest/kudu_partition_ddl.test
@@ -38,19 +38,6 @@ TBLPROPERTIES(
 Expected int32 literal for column 'id' got 'abc'
 ====
 ---- QUERY
--- Test error handling for split rows with two many components
-create table simple_hash ( id int, name string, valf float, vali bigint)
-DISTRIBUTE BY RANGE(col_does_not_exist, id) SPLIT ROWS ((1, 'abc'))
-TBLPROPERTIES(
-'storage_handler' = 'com.cloudera.kudu.hive.KuduStorageHandler',
-'kudu.table_name' = 'simple_hash',
-'kudu.master_addresses' = '127.0.0.1',
-'kudu.key_columns' = 'id, name'
- )
----- CATCH
-Unknown column: col_does_not_exist
-====
----- QUERY
 -- Test error handling for distribute clauses
 create table simple_hash ( id int, name string, valf float, vali bigint)
 DISTRIBUTE BY RANGE(col_does_not_exist) SPLIT ROWS ((1))


Mime
View raw message