From 6aa60e61f7e5f505f919c00128942cfa8939bc49 Mon Sep 17 00:00:00 2001 From: Yiming Liu Date: Sun, 17 Jul 2016 00:51:28 +0800 Subject: [PATCH] KYLIN-1898: Upgrade Calcite to 1.8 --- atopcalcite/pom.xml | 10 ------- .../apache/calcite/sql2rel/SqlToRelConverter.java | 13 ++++---- jdbc/pom.xml | 8 +---- .../main/java/org/apache/kylin/jdbc/KylinMeta.java | 35 ++++++++++++++++++++++ pom.xml | 21 +++++++++---- query/pom.xml | 2 +- 6 files changed, 58 insertions(+), 31 deletions(-) diff --git a/atopcalcite/pom.xml b/atopcalcite/pom.xml index b208ea1..7f4e508 100644 --- a/atopcalcite/pom.xml +++ b/atopcalcite/pom.xml @@ -39,16 +39,6 @@ org.apache.calcite calcite-core - - org.apache.calcite - calcite-avatica - - - com.google.protobuf - protobuf-java - - - diff --git a/atopcalcite/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java b/atopcalcite/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java index 849d5d7..c01663a 100644 --- a/atopcalcite/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java +++ b/atopcalcite/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java @@ -35,8 +35,6 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeSet; -import java.util.logging.Level; -import java.util.logging.Logger; import org.apache.calcite.avatica.util.Spaces; import org.apache.calcite.linq4j.Ord; @@ -187,6 +185,7 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; +import org.slf4j.Logger; /* * OVERRIDE POINT: @@ -500,9 +499,8 @@ public class SqlToRelConverter { final RelTraitSet traitSet = rootRel.getTraitSet().replace(RelCollationTraitDef.INSTANCE, collations); rootRel = rootRel.copy(traitSet, rootRel.getInputs()); } - boolean dumpPlan = SQL2REL_LOGGER.isLoggable(Level.FINE); - if (dumpPlan) { - SQL2REL_LOGGER.fine(RelOptUtil.dumpPlan("Plan after trimming unused fields", rootRel, false, SqlExplainLevel.EXPPLAN_ATTRIBUTES)); + if (SQL2REL_LOGGER.isDebugEnabled()) { + SQL2REL_LOGGER.debug(RelOptUtil.dumpPlan("Plan after trimming unused fields", rootRel, false, SqlExplainLevel.EXPPLAN_ATTRIBUTES)); } } return rootRel; @@ -548,9 +546,8 @@ public class SqlToRelConverter { } checkConvertedType(query, result); - boolean dumpPlan = SQL2REL_LOGGER.isLoggable(Level.FINE); - if (dumpPlan) { - SQL2REL_LOGGER.fine(RelOptUtil.dumpPlan("Plan after converting SqlNode to RelNode", result, false, SqlExplainLevel.EXPPLAN_ATTRIBUTES)); + if (SQL2REL_LOGGER.isDebugEnabled()) { + SQL2REL_LOGGER.debug(RelOptUtil.dumpPlan("Plan after converting SqlNode to RelNode", result, false, SqlExplainLevel.EXPPLAN_ATTRIBUTES)); } final RelDataType validatedRowType = validator.getValidatedNodeType(query); diff --git a/jdbc/pom.xml b/jdbc/pom.xml index 890a4c0..7797145 100644 --- a/jdbc/pom.xml +++ b/jdbc/pom.xml @@ -40,13 +40,7 @@ org.apache.calcite - calcite-avatica - - - com.google.protobuf - protobuf-java - - + calcite-core org.apache.httpcomponents diff --git a/jdbc/src/main/java/org/apache/kylin/jdbc/KylinMeta.java b/jdbc/src/main/java/org/apache/kylin/jdbc/KylinMeta.java index 8059dd0..002e5bd 100644 --- a/jdbc/src/main/java/org/apache/kylin/jdbc/KylinMeta.java +++ b/jdbc/src/main/java/org/apache/kylin/jdbc/KylinMeta.java @@ -29,6 +29,7 @@ import java.util.regex.Pattern; import org.apache.calcite.avatica.AvaticaUtils; import org.apache.calcite.avatica.ColumnMetaData; +import org.apache.calcite.avatica.Meta; import org.apache.calcite.avatica.MetaImpl; import org.apache.calcite.avatica.MissingResultsException; import org.apache.calcite.avatica.NoSuchStatementException; @@ -58,15 +59,33 @@ public class KylinMeta extends MetaImpl { return result; } + @Override + public ExecuteBatchResult prepareAndExecuteBatch(StatementHandle sh, List sqlCommands) throws NoSuchStatementException { + return new ExecuteBatchResult(new long[]{}); + } + + @Override + public ExecuteBatchResult executeBatch(StatementHandle sh, List> parameterValues) throws NoSuchStatementException { + return new ExecuteBatchResult(new long[]{}); + } + // real execution happens in KylinResultSet.execute() @Override + @Deprecated public ExecuteResult execute(StatementHandle sh, List parameterValues, long maxRowCount) throws NoSuchStatementException { final MetaResultSet metaResultSet = MetaResultSet.create(sh.connectionId, sh.id, false, sh.signature, null); return new ExecuteResult(Collections.singletonList(metaResultSet)); } + @Override + public ExecuteResult execute(StatementHandle sh, List parameterValues, int maxRowsInFirstFrame) throws NoSuchStatementException { + final MetaResultSet metaResultSet = MetaResultSet.create(sh.connectionId, sh.id, false, sh.signature, null); + return new ExecuteResult(Collections.singletonList(metaResultSet)); + } + // mimic from CalciteMetaImpl, real execution happens via callback in KylinResultSet.execute() @Override + @Deprecated public ExecuteResult prepareAndExecute(StatementHandle sh, String sql, long maxRowCount, PrepareCallback callback) { try { synchronized (callback.getMonitor()) { @@ -83,6 +102,22 @@ public class KylinMeta extends MetaImpl { } @Override + public ExecuteResult prepareAndExecute(StatementHandle sh, String sql, long maxRowCount, int maxRowsInFirstFrame, PrepareCallback callback) throws NoSuchStatementException { + try { + synchronized (callback.getMonitor()) { + callback.clear(); + sh.signature = connection().mockPreparedSignature(sql); + callback.assign(sh.signature, null, -1); + } + callback.execute(); + final MetaResultSet metaResultSet = MetaResultSet.create(sh.connectionId, sh.id, false, sh.signature, null); + return new ExecuteResult(Collections.singletonList(metaResultSet)); + } catch (SQLException e) { + throw new RuntimeException(e); + } + } + + @Override public void closeStatement(StatementHandle h) { // nothing to do } diff --git a/pom.xml b/pom.xml index 806c16b..d95ce7f 100644 --- a/pom.xml +++ b/pom.xml @@ -100,7 +100,7 @@ 1.2.7.RELEASE - 1.6.0 + 1.8.0 2.6.0 @@ -279,15 +279,26 @@ org.apache.calcite - calcite-avatica + calcite-linq4j ${calcite.version} - org.apache.calcite - calcite-linq4j + org.apache.calcite.avatica + avatica ${calcite.version} - + + + org.apache.calcite + calcite-avatica + 1.6.0 + + + com.google.protobuf + protobuf-java + + + org.apache.spark diff --git a/query/pom.xml b/query/pom.xml index 0dff0c3..f4c7e50 100644 --- a/query/pom.xml +++ b/query/pom.xml @@ -50,7 +50,7 @@ org.apache.calcite - calcite-linq4j + calcite-core log4j -- 2.7.4 (Apple Git-66)