Search in sources :

Example 1 with Builder

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());
}
Also used : ColumnNames(io.confluent.ksql.schema.ksql.ColumnNames) ColumnName(io.confluent.ksql.name.ColumnName) SourceName(io.confluent.ksql.name.SourceName) KeyFormat(io.confluent.ksql.serde.KeyFormat) UnqualifiedColumnReferenceExp(io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp) Set(java.util.Set) Builder(io.confluent.ksql.planner.RequiredColumns.Builder) LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) Collectors(java.util.stream.Collectors) Iterators(com.google.common.collect.Iterators) SelectExpression(io.confluent.ksql.execution.plan.SelectExpression) Namespace(io.confluent.ksql.schema.ksql.Column.Namespace) ImmutableBiMap(com.google.common.collect.ImmutableBiMap) List(java.util.List) Stream(java.util.stream.Stream) ImmutableList(com.google.common.collect.ImmutableList) Optional(java.util.Optional) ColumnReferenceExp(io.confluent.ksql.execution.expression.tree.ColumnReferenceExp) RequiredColumns(io.confluent.ksql.planner.RequiredColumns) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) Builder(io.confluent.ksql.planner.RequiredColumns.Builder) UnqualifiedColumnReferenceExp(io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp)

Example 2 with Builder

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)));
}
Also used : Builder(io.confluent.ksql.planner.RequiredColumns.Builder) Test(org.junit.Test)

Aggregations

Builder (io.confluent.ksql.planner.RequiredColumns.Builder)2 ImmutableBiMap (com.google.common.collect.ImmutableBiMap)1 ImmutableList (com.google.common.collect.ImmutableList)1 Iterators (com.google.common.collect.Iterators)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 ColumnReferenceExp (io.confluent.ksql.execution.expression.tree.ColumnReferenceExp)1 UnqualifiedColumnReferenceExp (io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp)1 SelectExpression (io.confluent.ksql.execution.plan.SelectExpression)1 ColumnName (io.confluent.ksql.name.ColumnName)1 SourceName (io.confluent.ksql.name.SourceName)1 RequiredColumns (io.confluent.ksql.planner.RequiredColumns)1 Namespace (io.confluent.ksql.schema.ksql.Column.Namespace)1 ColumnNames (io.confluent.ksql.schema.ksql.ColumnNames)1 LogicalSchema (io.confluent.ksql.schema.ksql.LogicalSchema)1 KeyFormat (io.confluent.ksql.serde.KeyFormat)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1