use of org.apache.beam.sdk.extensions.sql.impl.rel.BeamRelNode 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);
}
}
use of org.apache.beam.sdk.extensions.sql.impl.rel.BeamRelNode in project beam by apache.
the class ZetaSQLPushDownTest method testProjectPushDown_withPredicate.
@Test
public void testProjectPushDown_withPredicate() {
String sql = "SELECT name FROM InMemoryTableProject where id=2";
BeamRelNode zetaSqlNode = zetaSQLQueryPlanner.convertToBeamRel(sql);
BeamRelNode calciteSqlNode = sqlEnv.parseQuery(sql);
assertThat(zetaSqlNode.getInput(0), instanceOf(BeamIOSourceRel.class));
assertThat(calciteSqlNode.getInput(0), instanceOf(BeamIOSourceRel.class));
assertEquals(calciteSqlNode.getInput(0).getDigest(), zetaSqlNode.getInput(0).getDigest());
pipeline.run().waitUntilFinish(Duration.standardMinutes(PIPELINE_EXECUTION_WAITTIME_MINUTES));
}
use of org.apache.beam.sdk.extensions.sql.impl.rel.BeamRelNode in project beam by apache.
the class ZetaSQLPushDownTest method testProjectPushDown_withoutPredicate_withComplexSelect.
@Test
public void testProjectPushDown_withoutPredicate_withComplexSelect() {
String sql = "SELECT id+1 FROM InMemoryTableProject";
BeamRelNode zetaSqlNode = zetaSQLQueryPlanner.convertToBeamRel(sql);
BeamRelNode calciteSqlNode = sqlEnv.parseQuery(sql);
assertThat(zetaSqlNode.getInput(0), instanceOf(BeamIOSourceRel.class));
assertThat(calciteSqlNode.getInput(0), instanceOf(BeamIOSourceRel.class));
assertEquals(calciteSqlNode.getInput(0).getDigest(), zetaSqlNode.getInput(0).getDigest());
pipeline.run().waitUntilFinish(Duration.standardMinutes(PIPELINE_EXECUTION_WAITTIME_MINUTES));
}
use of org.apache.beam.sdk.extensions.sql.impl.rel.BeamRelNode in project beam by apache.
the class ZetaSQLPushDownTest method testProjectPushDown_withoutPredicate.
@Test
public void testProjectPushDown_withoutPredicate() {
String sql = "SELECT name, id, unused1 FROM InMemoryTableProject";
BeamRelNode zetaSqlNode = zetaSQLQueryPlanner.convertToBeamRel(sql);
BeamRelNode calciteSqlNode = sqlEnv.parseQuery(sql);
assertThat(zetaSqlNode, instanceOf(BeamIOSourceRel.class));
assertThat(calciteSqlNode, instanceOf(BeamIOSourceRel.class));
assertEquals(calciteSqlNode.getDigest(), zetaSqlNode.getDigest());
pipeline.run().waitUntilFinish(Duration.standardMinutes(PIPELINE_EXECUTION_WAITTIME_MINUTES));
}
use of org.apache.beam.sdk.extensions.sql.impl.rel.BeamRelNode in project beam by apache.
the class ZetaSQLPushDownTest method testProjectFilterPushDown_withoutPredicate.
@Test
public void testProjectFilterPushDown_withoutPredicate() {
String sql = "SELECT name, id, unused1 FROM InMemoryTableBoth";
BeamRelNode zetaSqlNode = zetaSQLQueryPlanner.convertToBeamRel(sql);
BeamRelNode calciteSqlNode = sqlEnv.parseQuery(sql);
assertThat(zetaSqlNode, instanceOf(BeamIOSourceRel.class));
assertThat(calciteSqlNode, instanceOf(BeamIOSourceRel.class));
assertEquals(calciteSqlNode.getDigest(), zetaSqlNode.getDigest());
pipeline.run().waitUntilFinish(Duration.standardMinutes(PIPELINE_EXECUTION_WAITTIME_MINUTES));
}
Aggregations