Repository: phoenix Updated Branches: refs/heads/calcite 5b6e7f91e -> e415755a8
PHOENIX-3617 Fix CREATE TABLE DDL parsing issues in Phoenix Calcaite(Rajeshbabu) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/e415755a Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/e415755a Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/e415755a Branch: refs/heads/calcite Commit: e415755a8e3b64fa46ab98aa2ce853a2c1fa7b1b Parents: 5b6e7f9 Author: Rajeshbabu Chintaguntla <[email protected]> Authored: Tue Jan 24 11:59:00 2017 +0530 Committer: Rajeshbabu Chintaguntla <[email protected]> Committed: Tue Jan 24 11:59:00 2017 +0530 ---------------------------------------------------------------------- .../src/main/codegen/includes/parserImpls.ftl | 18 +++++++++++++----- .../calcite/jdbc/PhoenixCalciteFactory.java | 10 ++++++++++ .../org/apache/calcite/sql/SqlOptionNode.java | 12 ++++++++++++ .../phoenix/calcite/PhoenixPrepareImpl.java | 2 +- 4 files changed, 36 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/e415755a/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 3360f14..af5abd2 100644 --- a/phoenix-core/src/main/codegen/includes/parserImpls.ftl +++ b/phoenix-core/src/main/codegen/includes/parserImpls.ftl @@ -956,11 +956,19 @@ SqlOptionNode FamilyOption() : { key = DualIdentifier() <EQ> - value = Literal() - { - pos = key.getParserPosition().plus(getPos()); - return new SqlOptionNode(pos, key, (SqlLiteral) value); - } + ( + value = Literal() + { + pos = key.getParserPosition().plus(getPos()); + return new SqlOptionNode(pos, key, (SqlLiteral) value); + } + | + value = SimpleIdentifier() + { + pos = key.getParserPosition().plus(getPos()); + return new SqlOptionNode(pos, key, (SqlIdentifier)value); + } + ) } SqlOptionNode GeneralOption() : http://git-wip-us.apache.org/repos/asf/phoenix/blob/e415755a/phoenix-core/src/main/java/org/apache/calcite/jdbc/PhoenixCalciteFactory.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/calcite/jdbc/PhoenixCalciteFactory.java b/phoenix-core/src/main/java/org/apache/calcite/jdbc/PhoenixCalciteFactory.java index d094ccd..5c15025 100644 --- a/phoenix-core/src/main/java/org/apache/calcite/jdbc/PhoenixCalciteFactory.java +++ b/phoenix-core/src/main/java/org/apache/calcite/jdbc/PhoenixCalciteFactory.java @@ -663,5 +663,15 @@ public class PhoenixCalciteFactory extends CalciteFactory { public SqlConformance conformance() { return delegate.conformance(); } + + @Override + public boolean approximateDistinctCount() { + return delegate.approximateDistinctCount(); + } + + @Override + public boolean approximateTopN() { + return delegate.approximateTopN(); + } } } http://git-wip-us.apache.org/repos/asf/phoenix/blob/e415755a/phoenix-core/src/main/java/org/apache/calcite/sql/SqlOptionNode.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/calcite/sql/SqlOptionNode.java b/phoenix-core/src/main/java/org/apache/calcite/sql/SqlOptionNode.java index 149e9ef..3524aab 100644 --- a/phoenix-core/src/main/java/org/apache/calcite/sql/SqlOptionNode.java +++ b/phoenix-core/src/main/java/org/apache/calcite/sql/SqlOptionNode.java @@ -47,6 +47,18 @@ public class SqlOptionNode extends SqlNode { this.value = CalciteUtils.convertSqlLiteral(literal, implementor); } + public SqlOptionNode(SqlParserPos pos, SqlIdentifier key, SqlIdentifier identifier) { + super(pos); + if (key.isSimple()) { + familyName = ""; + propertyName = key.getSimple(); + } else { + familyName = key.names.get(0); + propertyName = key.names.get(1); + } + this.value = identifier.names.get(0); + } + @Override public void unparse(SqlWriter writer, int leftPrec, int rightPrec) { // TODO Auto-generated method stub http://git-wip-us.apache.org/repos/asf/phoenix/blob/e415755a/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 9d86a7a..a4969ca 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 @@ -330,7 +330,7 @@ public class PhoenixPrepareImpl extends CalcitePrepareImpl { final CreateTableStatement create = nodeFactory.createTable( name, props, columnDefs, pkConstraint, splitNodes, tableType, table.ifNotExists.booleanValue(), - baseTableName, where, 0, table.immutable.booleanValue()); + baseTableName, where, 0, table.immutable.booleanValue() ? true : null); try (final PhoenixStatement stmt = new PhoenixStatement(connection)) { final CreateTableCompiler compiler = new CreateTableCompiler(stmt, Operation.UPSERT); final MutationPlan plan = compiler.compile(create);
