beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Work logged] (BEAM-4807) Upgrade calcite to 1.17.0
Date Tue, 07 Aug 2018 23:56:00 GMT

     [ https://issues.apache.org/jira/browse/BEAM-4807?focusedWorklogId=132165&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-132165
]

ASF GitHub Bot logged work on BEAM-4807:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 07/Aug/18 23:55
            Start Date: 07/Aug/18 23:55
    Worklog Time Spent: 10m 
      Work Description: akedin closed pull request #6169: [BEAM-4807] [SQL] Upgrade Calcite
and Avatica
URL: https://github.com/apache/beam/pull/6169
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/sdks/java/extensions/sql/build.gradle b/sdks/java/extensions/sql/build.gradle
index 55c9d6663f3..33fa6b2beee 100644
--- a/sdks/java/extensions/sql/build.gradle
+++ b/sdks/java/extensions/sql/build.gradle
@@ -55,8 +55,8 @@ configurations {
   fmppTemplates
 }
 
-def calcite_version = "1.16.0"
-def avatica_version = "1.11.0"
+def calcite_version = "1.17.0"
+def avatica_version = "1.12.0"
 
 dependencies {
   javacc "net.java.dev.javacc:javacc:4.0"
diff --git a/sdks/java/extensions/sql/src/main/codegen/config.fmpp b/sdks/java/extensions/sql/src/main/codegen/config.fmpp
index e2ba55af220..f9fb117ce80 100644
--- a/sdks/java/extensions/sql/src/main/codegen/config.fmpp
+++ b/sdks/java/extensions/sql/src/main/codegen/config.fmpp
@@ -48,6 +48,11 @@ data: {
         "TBLPROPERTIES"
       ]
 
+      # List of additional join types. Each is a method with no arguments.
+      # Example: LeftSemiJoin()
+      joinTypes: [
+      ]
+
       # List of methods for parsing custom SQL statements.
       statementParserMethods: [
         "SqlSetOptionBeam(Span.of(), null)"
diff --git a/sdks/java/extensions/sql/src/main/codegen/includes/parserImpls.ftl b/sdks/java/extensions/sql/src/main/codegen/includes/parserImpls.ftl
index 57122187594..66ac4964066 100644
--- a/sdks/java/extensions/sql/src/main/codegen/includes/parserImpls.ftl
+++ b/sdks/java/extensions/sql/src/main/codegen/includes/parserImpls.ftl
@@ -30,7 +30,7 @@ boolean IfExistsOpt() :
 SqlNodeList Options() :
 {
     final Span s;
-    final List<SqlNode> list = Lists.newArrayList();
+    final List<SqlNode> list = new ArrayList<SqlNode>();
 }
 {
     <OPTIONS> { s = span(); } <LPAREN>
@@ -87,7 +87,7 @@ List<Schema.Field> FieldListAngular() :
 
 List<Schema.Field> FieldListBody() :
 {
-    final List<Schema.Field> fields = Lists.newArrayList();
+    final List<Schema.Field> fields = new ArrayList<Schema.Field>();
     Schema.Field field = null;
 }
 {
diff --git a/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/BeamCalciteSchema.java
b/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/BeamCalciteSchema.java
index 5fe4a05b69b..cc6058de3d1 100644
--- a/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/BeamCalciteSchema.java
+++ b/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/BeamCalciteSchema.java
@@ -25,6 +25,7 @@
 import org.apache.beam.sdk.extensions.sql.meta.Table;
 import org.apache.beam.sdk.extensions.sql.meta.provider.TableProvider;
 import org.apache.calcite.linq4j.tree.Expression;
+import org.apache.calcite.rel.type.RelProtoDataType;
 import org.apache.calcite.schema.Function;
 import org.apache.calcite.schema.Schema;
 import org.apache.calcite.schema.SchemaPlus;
@@ -69,6 +70,16 @@ public Expression getExpression(SchemaPlus parentSchema, String name) {
     return tableProvider.getTables().keySet();
   }
 
+  @Override
+  public RelProtoDataType getType(String name) {
+    return null;
+  }
+
+  @Override
+  public Set<String> getTypeNames() {
+    return Collections.emptySet();
+  }
+
   @Override
   public org.apache.calcite.schema.Table getTable(String name) {
     Table table = tableProvider.getTables().get(name);
diff --git a/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/JdbcDriver.java
b/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/JdbcDriver.java
index f3ce0016165..4c0345401d1 100644
--- a/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/JdbcDriver.java
+++ b/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/JdbcDriver.java
@@ -21,13 +21,13 @@
 
 import com.google.auto.service.AutoService;
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Function;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import java.util.function.Consumer;
 import org.apache.beam.sdk.extensions.sql.impl.parser.impl.BeamSqlParserImpl;
 import org.apache.beam.sdk.extensions.sql.impl.planner.BeamRelDataTypeSystem;
 import org.apache.beam.sdk.extensions.sql.impl.planner.BeamRuleSets;
@@ -88,27 +88,24 @@
     }
     // inject beam rules into planner
     Hook.PLANNER.add(
-        new Function<RelOptPlanner, Void>() {
-          @Override
-          public Void apply(RelOptPlanner planner) {
-            for (RuleSet ruleSet : BeamRuleSets.getRuleSets()) {
-              for (RelOptRule rule : ruleSet) {
-                planner.addRule(rule);
+        (Consumer<RelOptPlanner>)
+            planner -> {
+              for (RuleSet ruleSet : BeamRuleSets.getRuleSets()) {
+                for (RelOptRule rule : ruleSet) {
+                  planner.addRule(rule);
+                }
               }
-            }
-            planner.removeRule(CalcRemoveRule.INSTANCE);
-            planner.removeRule(SortRemoveRule.INSTANCE);
-
-            List<RelTraitDef> relTraitDefs = new ArrayList<>(planner.getRelTraitDefs());
-            planner.clearRelTraitDefs();
-            for (RelTraitDef def : relTraitDefs) {
-              if (!(def instanceof RelCollationTraitDef)) {
-                planner.addRelTraitDef(def);
+              planner.removeRule(CalcRemoveRule.INSTANCE);
+              planner.removeRule(SortRemoveRule.INSTANCE);
+
+              List<RelTraitDef> relTraitDefs = new ArrayList<>(planner.getRelTraitDefs());
+              planner.clearRelTraitDefs();
+              for (RelTraitDef def : relTraitDefs) {
+                if (!(def instanceof RelCollationTraitDef)) {
+                  planner.addRelTraitDef(def);
+                }
               }
-            }
-            return null;
-          }
-        });
+            });
     // register JDBC driver
     INSTANCE.register();
   }
diff --git a/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rule/BeamUnnestRule.java
b/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rule/BeamUnnestRule.java
index a2094c63551..45c2bb423db 100644
--- a/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rule/BeamUnnestRule.java
+++ b/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rule/BeamUnnestRule.java
@@ -22,7 +22,9 @@
 import org.apache.beam.sdk.extensions.sql.impl.rel.BeamUnnestRel;
 import org.apache.calcite.plan.RelOptRule;
 import org.apache.calcite.plan.RelOptRuleCall;
+import org.apache.calcite.plan.volcano.RelSubset;
 import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.SingleRel;
 import org.apache.calcite.rel.core.Uncollect;
 import org.apache.calcite.rel.core.Union;
 import org.apache.calcite.rel.logical.LogicalCorrelate;
@@ -35,7 +37,7 @@
   private BeamUnnestRule() {
     super(
         operand(
-            LogicalCorrelate.class, operand(RelNode.class, any()), operand(Uncollect.class,
any())),
+            LogicalCorrelate.class, operand(RelNode.class, any()), operand(SingleRel.class,
any())),
         "BeamUnnestRule");
   }
 
@@ -44,6 +46,16 @@ public void onMatch(RelOptRuleCall call) {
     LogicalCorrelate correlate = call.rel(0);
     RelNode outer = call.rel(1);
     RelNode uncollect = call.rel(2);
+    if (!(uncollect instanceof Uncollect)) {
+      // Drop projection
+      uncollect = ((SingleRel) uncollect).getInput();
+      if (uncollect instanceof RelSubset) {
+        uncollect = ((RelSubset) uncollect).getOriginal();
+      }
+      if (!(uncollect instanceof Uncollect)) {
+        return;
+      }
+    }
 
     call.transformTo(
         new BeamUnnestRel(
diff --git a/sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/BeamSqlDslSqlStdOperatorsTest.java
b/sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/BeamSqlDslSqlStdOperatorsTest.java
index a2b558be3c5..75cddd8443a 100644
--- a/sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/BeamSqlDslSqlStdOperatorsTest.java
+++ b/sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/BeamSqlDslSqlStdOperatorsTest.java
@@ -656,7 +656,7 @@ public void testDatetimePlusFunction() {
   }
 
   @Test
-  @SqlOperatorTest(name = "DATETIME_PLUS", kind = "PLUS")
+  @SqlOperatorTest(name = "+", kind = "PLUS")
   public void testDatetimeInfixPlus() {
     ExpressionChecker checker =
         new ExpressionChecker()


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 132165)
    Time Spent: 40m  (was: 0.5h)

> Upgrade calcite to 1.17.0
> -------------------------
>
>                 Key: BEAM-4807
>                 URL: https://issues.apache.org/jira/browse/BEAM-4807
>             Project: Beam
>          Issue Type: New Feature
>          Components: dsl-sql
>            Reporter: Andrew Pilloud
>            Assignee: Andrew Pilloud
>            Priority: Major
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> We should upgrade calcite.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message