You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ra...@apache.org on 2017/05/25 09:54:02 UTC

phoenix git commit: PHOENIX-3690 Support declaring default values in Phoenix-Calcite - addendum to fix some tests of of default values

Repository: phoenix
Updated Branches:
  refs/heads/calcite 41a3b7f9c -> 39ca90e54


PHOENIX-3690 Support declaring default values in Phoenix-Calcite - addendum to fix some tests of of default values


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

Branch: refs/heads/calcite
Commit: 39ca90e54bced27a70b538431db13e2d75d0041e
Parents: 41a3b7f
Author: Rajeshbabu Chintaguntla <ra...@apache.org>
Authored: Thu May 25 15:23:52 2017 +0530
Committer: Rajeshbabu Chintaguntla <ra...@apache.org>
Committed: Thu May 25 15:23:52 2017 +0530

----------------------------------------------------------------------
 .../apache/phoenix/end2end/DefaultColumnValueIT.java    | 12 ++++++------
 phoenix-core/src/main/codegen/includes/parserImpls.ftl  |  4 ++--
 .../java/org/apache/phoenix/calcite/CalciteUtils.java   | 10 +++++-----
 .../org/apache/phoenix/calcite/PhoenixPrepareImpl.java  |  2 +-
 .../java/org/apache/phoenix/jdbc/PhoenixDriverTest.java |  6 +++++-
 5 files changed, 19 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/39ca90e5/phoenix-core/src/it/java/org/apache/phoenix/end2end/DefaultColumnValueIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DefaultColumnValueIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DefaultColumnValueIT.java
index e930069..906c7fd 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DefaultColumnValueIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DefaultColumnValueIT.java
@@ -472,7 +472,7 @@ public class DefaultColumnValueIT extends ParallelStatsDisabledIT {
         String table = generateUniqueName();
         String ddl = "CREATE TABLE IF NOT EXISTS " + table + "("
                 + "pk INTEGER PRIMARY KEY,"
-                + "int INTEGER DEFAULT -100,"
+                + "\"int\" INTEGER DEFAULT -100,"
                 + "uint UNSIGNED_INT DEFAULT 100, "
                 + "bint BIGINT DEFAULT -200,"
                 + "ubint UNSIGNED_LONG DEFAULT 200,"
@@ -484,7 +484,7 @@ public class DefaultColumnValueIT extends ParallelStatsDisabledIT {
                 + "uflo UNSIGNED_FLOAT DEFAULT 100.9,"
                 + "doub DOUBLE DEFAULT -200.5,"
                 + "udoubl UNSIGNED_DOUBLE DEFAULT 200.8,"
-                + "dec DECIMAL DEFAULT -654624562.3462642362,"
+                + "\"dec\" DECIMAL DEFAULT -654624562.3462642362,"
                 + "bool BOOLEAN DEFAULT true,"
                 + "tim TIME DEFAULT time '1900-10-01 14:03:22.559',"
                 + "dat DATE DEFAULT date '1900-10-01 14:03:22.559',"
@@ -506,7 +506,7 @@ public class DefaultColumnValueIT extends ParallelStatsDisabledIT {
         String table = generateUniqueName();
         String ddl = "CREATE TABLE IF NOT EXISTS " + table + "("
                 + "pk INTEGER NOT NULL,"
-                + "int INTEGER NOT NULL DEFAULT -100,"
+                + "\"int\" INTEGER NOT NULL DEFAULT -100,"
                 + "uint UNSIGNED_INT NOT NULL DEFAULT 100, "
                 + "bint BIGINT NOT NULL DEFAULT -200,"
                 + "ubint UNSIGNED_LONG NOT NULL DEFAULT 200,"
@@ -518,7 +518,7 @@ public class DefaultColumnValueIT extends ParallelStatsDisabledIT {
                 + "uflo UNSIGNED_FLOAT NOT NULL DEFAULT 100.9,"
                 + "doub DOUBLE NOT NULL DEFAULT -200.5,"
                 + "udoub UNSIGNED_DOUBLE NOT NULL DEFAULT 200.8,"
-                + "dec DECIMAL NOT NULL DEFAULT -654624562.3462642362,"
+                + "\"dec\" DECIMAL NOT NULL DEFAULT -654624562.3462642362,"
                 + "bool BOOLEAN NOT NULL DEFAULT true,"
                 + "tim TIME NOT NULL DEFAULT time '1900-10-01 14:03:22.559',"
                 + "dat DATE NOT NULL DEFAULT date '1900-10-01 14:03:22.559',"
@@ -530,8 +530,8 @@ public class DefaultColumnValueIT extends ParallelStatsDisabledIT {
                 + "c CHAR(5) NOT NULL DEFAULT 'EF',"
                 + "bin BINARY(5) NOT NULL DEFAULT 'MNOP',"
                 + "varbin VARBINARY NOT NULL DEFAULT 'QR'"
-                + "CONSTRAINT pk_final PRIMARY KEY (pk, int, uint, bint, ubint, tint, utint,"
-                + "sint, usint, flo, uflo, doub, udoub, dec, bool,"
+                + "CONSTRAINT pk_final PRIMARY KEY (pk, \"int\", uint, bint, ubint, tint, utint,"
+                + "sint, usint, flo, uflo, doub, udoub, \"dec\", bool,"
                 + "tim, dat, timest, utim, udat, utimest,"
                 + "vc, c, bin, varbin)"
                 + ")";

http://git-wip-us.apache.org/repos/asf/phoenix/blob/39ca90e5/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 f4849cb..f58de08 100644
--- a/phoenix-core/src/main/codegen/includes/parserImpls.ftl
+++ b/phoenix-core/src/main/codegen/includes/parserImpls.ftl
@@ -387,7 +387,7 @@ SqlNode SqlCreateSequence() :
     ]
     [
         <INCREMENT> [ <BY> ]
-        v = UnsignedIntLiteral() { incrementBy = SqlLiteral.createExactNumeric(v.toString(), getPos()); }
+        v = IntLiteral() { incrementBy = SqlLiteral.createExactNumeric(v.toString(), getPos()); }
     ]
     [
         <MINVALUE>
@@ -402,7 +402,7 @@ SqlNode SqlCreateSequence() :
     ]
     [
         <CACHE>
-        v = UnsignedIntLiteral() { cache = SqlLiteral.createExactNumeric(v.toString(), getPos()); }
+        cache = UnsignedNumericLiteral()
     ]
     {
         return new SqlCreateSequence(pos.plus(getPos()), sequenceName,

http://git-wip-us.apache.org/repos/asf/phoenix/blob/39ca90e5/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteUtils.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteUtils.java b/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteUtils.java
index 2ab9007..71775af 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteUtils.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteUtils.java
@@ -1415,13 +1415,13 @@ public class CalciteUtils {
                 column.getMaxLength(), column.getScale(),
                 column.getSortOrder());
           Object object =
-                  defaultExpression.getDataType().toObject(key,
-                      defaultExpression.getSortOrder(), defaultExpression.getMaxLength(),
-                      defaultExpression.getScale());
+                  column.getDataType().toObject(key,
+                      column.getSortOrder(), defaultExpression.getMaxLength(),
+                      column.getScale());
           RelDataType pDataTypeToRelDataType =
                   CalciteUtils.pDataTypeToRelDataType(rexBuilder.getTypeFactory(),
-                      defaultExpression.getDataType(), defaultExpression.getMaxLength(),
-                      defaultExpression.getScale(), column.getArraySize());
+                      column.getDataType(), column.getMaxLength(),
+                      column.getScale(), column.getArraySize());
         return rexBuilder.makeLiteral((Comparable)object, pDataTypeToRelDataType,true);
     }
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/39ca90e5/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 1ee84f0..bd7450e 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
@@ -386,7 +386,7 @@ public class PhoenixPrepareImpl extends CalcitePrepareImpl {
                 final ParseNode incrementBy = sequence.incrementBy == null ? null : nodeFactory.literal(sequence.incrementBy.intValue(true));
                 final ParseNode minValue = sequence.minValue == null ? null : nodeFactory.literal(sequence.minValue.intValue(true));
                 final ParseNode maxValue = sequence.maxValue == null ? null : nodeFactory.literal(sequence.maxValue.intValue(true));
-                final ParseNode cache = sequence.cache == null ? null : nodeFactory.literal(sequence.cache.intValue(true));
+                final ParseNode cache = sequence.cache == null ? null : nodeFactory.literal(sequence.cache.longValue(true));
                 final CreateSequenceStatement create = nodeFactory.createSequence(name, startWith, incrementBy, cache, minValue, maxValue, sequence.cycle.booleanValue(), sequence.ifNotExists.booleanValue(), 0);
                 try (final PhoenixStatement stmt = new PhoenixStatement(connection)) {
                     final CreateSequenceCompiler compiler = new CreateSequenceCompiler(stmt, Operation.UPSERT);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/39ca90e5/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixDriverTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixDriverTest.java b/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixDriverTest.java
index 063af5b..f3850cb 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixDriverTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixDriverTest.java
@@ -75,7 +75,11 @@ public class PhoenixDriverTest extends BaseConnectionlessQueryTest {
                 stmt.execute();
             }
             fail("Upsert should have failed since the number of upserts (200) is greater than the MAX_MUTATION_SIZE_ATTRIB (100)");
-        } catch (IllegalArgumentException expected) {}
+        } catch (SQLException expected) {
+            if(!(expected.getCause() instanceof IllegalArgumentException)) {
+                fail("Should throw IllegalArgumentException");
+            }
+        }
     }
 
     @Test