Search in sources :

Example 1 with SqlConversionException

use of org.apache.beam.sdk.extensions.sql.impl.SqlConversionException in project beam by apache.

the class ZetaSQLQueryPlanner method convertToBeamRelInternal.

private BeamRelNode convertToBeamRelInternal(String sql, QueryParameters queryParams) {
    RelRoot root = plannerImpl.rel(sql, queryParams);
    RelTraitSet desiredTraits = root.rel.getTraitSet().replace(BeamLogicalConvention.INSTANCE).replace(root.collation).simplify();
    // beam physical plan
    root.rel.getCluster().setMetadataProvider(ChainedRelMetadataProvider.of(org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableList.of(NonCumulativeCostImpl.SOURCE, RelMdNodeStats.SOURCE, root.rel.getCluster().getMetadataProvider())));
    root.rel.getCluster().setMetadataQuerySupplier(BeamRelMetadataQuery::instance);
    RelMetadataQuery.THREAD_PROVIDERS.set(JaninoRelMetadataProvider.of(root.rel.getCluster().getMetadataProvider()));
    root.rel.getCluster().invalidateMetadataQuery();
    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);
    }
}
Also used : BeamRelNode(org.apache.beam.sdk.extensions.sql.impl.rel.BeamRelNode) BeamRelMetadataQuery(org.apache.beam.sdk.extensions.sql.impl.planner.BeamRelMetadataQuery) RelRoot(org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelRoot) RelTraitSet(org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelTraitSet) SqlConversionException(org.apache.beam.sdk.extensions.sql.impl.SqlConversionException) RelOptPlanner(org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelOptPlanner)

Aggregations

SqlConversionException (org.apache.beam.sdk.extensions.sql.impl.SqlConversionException)1 BeamRelMetadataQuery (org.apache.beam.sdk.extensions.sql.impl.planner.BeamRelMetadataQuery)1 BeamRelNode (org.apache.beam.sdk.extensions.sql.impl.rel.BeamRelNode)1 RelOptPlanner (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelOptPlanner)1 RelTraitSet (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelTraitSet)1 RelRoot (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelRoot)1