phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajeshb...@apache.org
Subject phoenix git commit: PHOENIX-3646 Fix issues with Split keys and Replace bind values with actual split keys in CREATE TABLE DDL in Phoenix-Calcite(Rajeshbabu)
Date Fri, 03 Feb 2017 17:48:09 GMT
Repository: phoenix
Updated Branches:
  refs/heads/calcite 2aab5bfa9 -> f6d836a85


PHOENIX-3646 Fix issues with Split keys and Replace bind values with actual split keys in
CREATE TABLE DDL in Phoenix-Calcite(Rajeshbabu)


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

Branch: refs/heads/calcite
Commit: f6d836a852d9d3accc79351675055612880a0660
Parents: 2aab5bf
Author: Rajeshbabu Chintaguntla <rajeshbabu@apache.org>
Authored: Fri Feb 3 23:30:33 2017 +0530
Committer: Rajeshbabu Chintaguntla <rajeshbabu@apache.org>
Committed: Fri Feb 3 23:30:33 2017 +0530

----------------------------------------------------------------------
 .../src/main/codegen/includes/parserImpls.ftl   | 21 ++++++++++++++++++--
 .../phoenix/calcite/PhoenixPrepareImpl.java     |  7 ++++++-
 .../java/org/apache/phoenix/query/BaseTest.java |  3 ++-
 3 files changed, 27 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/f6d836a8/phoenix-core/src/main/codegen/includes/parserImpls.ftl
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/codegen/includes/parserImpls.ftl b/phoenix-core/src/main/codegen/includes/parserImpls.ftl
index 2539032..0d6a7b7 100644
--- a/phoenix-core/src/main/codegen/includes/parserImpls.ftl
+++ b/phoenix-core/src/main/codegen/includes/parserImpls.ftl
@@ -820,15 +820,32 @@ SqlNodeList SplitKeyList() :
 }
 {
     { pos = getPos(); }
-    e = StringLiteral() { splitKeyList = startList(e); }
+    e = SplitKeyLiteral() { splitKeyList = startList(e); }
     (
-        <COMMA> e = StringLiteral() { splitKeyList.add(e); }
+        <COMMA> e = SplitKeyLiteral() { splitKeyList.add(e); }
     ) *
     {
         return new SqlNodeList(splitKeyList, pos.plus(getPos()));
     }
 }
 
+SqlNode SplitKeyLiteral():
+{
+    SqlParserPos pos=null;
+    SqlNode e;
+}
+{
+    { pos = getPos(); }
+    (
+    e = StringLiteral() 
+    |
+    e = NumericLiteral()
+    )
+    {
+        return e.clone(pos);
+    }
+}
+
 SqlColumnDefNode ColumnDef() :
 {
     SqlIdentifier columnName;

http://git-wip-us.apache.org/repos/asf/phoenix/blob/f6d836a8/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixPrepareImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixPrepareImpl.java
b/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixPrepareImpl.java
index 7311e58..9edc4de 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixPrepareImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixPrepareImpl.java
@@ -679,7 +679,12 @@ public class PhoenixPrepareImpl extends CalcitePrepareImpl {
             splits = Lists.newArrayList();
             for (SqlNode splitKey : splitKeyList) {
                 final SqlLiteral key = (SqlLiteral) splitKey;
-                splits.add(nodeFactory.literal(((NlsString) key.getValue()).toString()));
+                Object value = key.getValue();
+                if(key.getValue() instanceof NlsString) {
+                    String quotedValue = ((NlsString) key.getValue()).toString();
+                    value = quotedValue.substring(1, quotedValue.length() - 1);
+                }
+                splits.add(nodeFactory.literal(value));
             }
         }
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/f6d836a8/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
index 6631546..4ea40de 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
@@ -123,6 +123,7 @@ import org.apache.hadoop.hbase.ipc.PhoenixRpcSchedulerFactory;
 import org.apache.hadoop.hbase.ipc.RpcControllerFactory;
 import org.apache.hadoop.hbase.ipc.controller.ServerRpcControllerFactory;
 import org.apache.hadoop.hbase.regionserver.RSRpcServices;
+import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.phoenix.end2end.BaseClientManagedTimeIT;
 import org.apache.phoenix.end2end.BaseHBaseManagedTimeIT;
 import org.apache.phoenix.exception.SQLExceptionCode;
@@ -791,7 +792,7 @@ public abstract class BaseTest {
         if (splits != null) {
             buf.append(" SPLIT ON (");
             for (int i = 0; i < splits.length; i++) {
-                buf.append("?,");
+                buf.append("'").append(Bytes.toString(splits[i])).append("'").append(",");
             }
             buf.setCharAt(buf.length()-1, ')');
         }


Mime
View raw message