This is an automated email from the ASF dual-hosted git repository. ibzib pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push: new 6e1ce71 [BEAM-12102] Catch and rethrow Calcite CannotPlanException. new bb7c427 Merge pull request #14447 from ibzib/BEAM-12102 6e1ce71 is described below commit 6e1ce71823d48c26613dc86dec6a08fcceebf021 Author: Kyle Weaver <kcwea...@google.com> AuthorDate: Tue Apr 6 12:12:14 2021 -0700 [BEAM-12102] Catch and rethrow Calcite CannotPlanException. --- .../beam/sdk/extensions/sql/zetasql/ZetaSQLQueryPlanner.java | 11 ++++++++--- .../beam/sdk/extensions/sql/zetasql/ZetaSqlJavaUdfTest.java | 7 +++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/ZetaSQLQueryPlanner.java b/sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/ZetaSQLQueryPlanner.java index 723e6ac..918f7ce 100644 --- a/sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/ZetaSQLQueryPlanner.java +++ b/sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/ZetaSQLQueryPlanner.java @@ -41,6 +41,7 @@ import org.apache.beam.sdk.extensions.sql.zetasql.unnest.BeamZetaSqlUnnestRule; import org.apache.beam.vendor.calcite.v1_20_0.org.apache.calcite.config.CalciteConnectionConfig; import org.apache.beam.vendor.calcite.v1_20_0.org.apache.calcite.jdbc.CalciteSchema; import org.apache.beam.vendor.calcite.v1_20_0.org.apache.calcite.plan.ConventionTraitDef; +import org.apache.beam.vendor.calcite.v1_20_0.org.apache.calcite.plan.RelOptPlanner; import org.apache.beam.vendor.calcite.v1_20_0.org.apache.calcite.plan.RelOptRule; import org.apache.beam.vendor.calcite.v1_20_0.org.apache.calcite.plan.RelOptUtil; import org.apache.beam.vendor.calcite.v1_20_0.org.apache.calcite.plan.RelTraitDef; @@ -213,9 +214,13 @@ public class ZetaSQLQueryPlanner implements QueryPlanner { RelMetadataQuery.THREAD_PROVIDERS.set( JaninoRelMetadataProvider.of(root.rel.getCluster().getMetadataProvider())); root.rel.getCluster().invalidateMetadataQuery(); - BeamRelNode beamRelNode = (BeamRelNode) plannerImpl.transform(0, desiredTraits, root.rel); - LOG.info("BEAMPlan>\n" + RelOptUtil.toString(beamRelNode)); - return beamRelNode; + try { + BeamRelNode beamRelNode = (BeamRelNode) plannerImpl.transform(0, desiredTraits, root.rel); + LOG.info("BEAMPlan>\n" + RelOptUtil.toString(beamRelNode)); + return beamRelNode; + } catch (RelOptPlanner.CannotPlanException e) { + throw new SqlConversionException("Failed to produce plan for query " + sql, e); + } } private static FrameworkConfig defaultConfig( diff --git a/sdks/java/extensions/sql/zetasql/src/test/java/org/apache/beam/sdk/extensions/sql/zetasql/ZetaSqlJavaUdfTest.java b/sdks/java/extensions/sql/zetasql/src/test/java/org/apache/beam/sdk/extensions/sql/zetasql/ZetaSqlJavaUdfTest.java index fa9562c..7c73b70 100644 --- a/sdks/java/extensions/sql/zetasql/src/test/java/org/apache/beam/sdk/extensions/sql/zetasql/ZetaSqlJavaUdfTest.java +++ b/sdks/java/extensions/sql/zetasql/src/test/java/org/apache/beam/sdk/extensions/sql/zetasql/ZetaSqlJavaUdfTest.java @@ -30,6 +30,7 @@ import org.apache.beam.sdk.extensions.sql.SqlTransform; import org.apache.beam.sdk.extensions.sql.impl.JdbcConnection; import org.apache.beam.sdk.extensions.sql.impl.JdbcDriver; import org.apache.beam.sdk.extensions.sql.impl.ScalarFunctionImpl; +import org.apache.beam.sdk.extensions.sql.impl.SqlConversionException; import org.apache.beam.sdk.extensions.sql.impl.rel.BeamRelNode; import org.apache.beam.sdk.extensions.sql.impl.rel.BeamSqlRelUtils; import org.apache.beam.sdk.extensions.sql.meta.provider.ReadOnlyTableProvider; @@ -39,7 +40,6 @@ import org.apache.beam.sdk.testing.PAssert; import org.apache.beam.sdk.testing.TestPipeline; import org.apache.beam.sdk.values.PCollection; import org.apache.beam.sdk.values.Row; -import org.apache.beam.vendor.calcite.v1_20_0.org.apache.calcite.plan.RelOptPlanner.CannotPlanException; import org.apache.beam.vendor.calcite.v1_20_0.org.apache.calcite.tools.Frameworks; import org.apache.beam.vendor.calcite.v1_20_0.org.apache.calcite.tools.RuleSet; import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableList; @@ -298,9 +298,8 @@ public class ZetaSqlJavaUdfTest extends ZetaSqlTestBase { + "SELECT matches(\"a\", \"a\"), 'apple'='beta'", jarPath); ZetaSQLQueryPlanner zetaSQLQueryPlanner = new ZetaSQLQueryPlanner(config); - thrown.expect(CannotPlanException.class); - thrown.expectMessage( - "There are not enough rules to produce a node with desired properties: convention=BEAM_LOGICAL."); + thrown.expect(SqlConversionException.class); + thrown.expectMessage("Failed to produce plan for query"); zetaSQLQueryPlanner.convertToBeamRel(sql); }