use of io.confluent.ksql.planner.plan.UserRepartitionNode in project ksql by confluentinc.
the class LogicalPlanner method buildUserRepartitionNode.
private UserRepartitionNode buildUserRepartitionNode(final PlanNode currentNode, final PartitionBy partitionBy) {
final List<Expression> rewrittenPartitionBys = partitionBy.getExpressions().stream().map(exp -> ExpressionTreeRewriter.rewriteWith(refRewriter::process, exp)).collect(Collectors.toList());
final LogicalSchema schema = buildRepartitionedSchema(currentNode, rewrittenPartitionBys);
return new UserRepartitionNode(new PlanNodeId("PartitionBy"), currentNode, schema, partitionBy.getExpressions(), rewrittenPartitionBys, ksqlConfig);
}
use of io.confluent.ksql.planner.plan.UserRepartitionNode in project ksql by confluentinc.
the class LogicalPlannerTest method shouldRewritePartitionByForJoin.
@Test
public void shouldRewritePartitionByForJoin() {
// Given:
final String simpleQuery = "SELECT t1.col1, t2.col1 FROM test1 t1 JOIN test2 t2 ON t1.col0 = t2.col0 PARTITION BY t1.col1 EMIT CHANGES;";
// When:
final PlanNode logicalPlan = buildLogicalPlan(simpleQuery);
// Then:
final UserRepartitionNode repart = (UserRepartitionNode) logicalPlan.getSources().get(0).getSources().get(0);
assertThat(repart.getPartitionBys(), equalTo(ImmutableList.of(new UnqualifiedColumnReferenceExp(ColumnName.of("T1_COL1")))));
}
use of io.confluent.ksql.planner.plan.UserRepartitionNode in project ksql by confluentinc.
the class SchemaKStreamTest method shouldThrowOnRepartitionByMissingField.
@Test(expected = KsqlException.class)
public void shouldThrowOnRepartitionByMissingField() {
// Given:
final PlanNode logicalPlan = givenInitialKStreamOf("SELECT col0, col2, col3 FROM test1 PARTITION BY not_here EMIT CHANGES;");
final UserRepartitionNode repartitionNode = (UserRepartitionNode) logicalPlan.getSources().get(0).getSources().get(0);
// When:
initialSchemaKStream.selectKey(valueFormat.getFormatInfo(), repartitionNode.getPartitionBys(), Optional.empty(), childContextStacker, false);
}
Aggregations