use of io.confluent.ksql.planner.RequiredColumns.Builder in project ksql by confluentinc.
the class PreJoinProjectNode method validateColumns.
@Override
protected Set<ColumnReferenceExp> validateColumns(final RequiredColumns requiredColumns) {
final List<? extends ColumnReferenceExp> aliased = requiredColumns.get().stream().filter(columnRef -> columnRef instanceof UnqualifiedColumnReferenceExp).filter(columnRef -> aliases.inverse().containsKey(columnRef.getColumnName())).collect(Collectors.toList());
final Builder builder = requiredColumns.asBuilder();
aliased.forEach(columnRef -> {
builder.remove(columnRef);
builder.add(new UnqualifiedColumnReferenceExp(columnRef.getLocation(), aliases.inverse().get(columnRef.getColumnName())));
});
return super.validateColumns(builder.build());
}
use of io.confluent.ksql.planner.RequiredColumns.Builder in project ksql by confluentinc.
the class RequiredColumnsTest method shouldBeImmutable.
@Test
public void shouldBeImmutable() {
// Given:
final RequiredColumns requiredColumns = builder.add(COL0_REF).add(COL1_REF).build();
final Builder builder2 = requiredColumns.asBuilder();
// When:
builder.remove(COL0_REF);
builder2.remove(COL1_REF);
// Then:
assertThat(requiredColumns.get(), is(ImmutableSet.of(COL0_REF, COL1_REF)));
}
Aggregations