use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class JoinNode method validateKeyPresent.
@Override
void validateKeyPresent(final SourceName sinkName, final Projection projection) {
if (joinKey.isForeignKey()) {
final DataSourceNode leftInputTable = getLeftmostSourceNode();
final SourceName leftInputTableName = leftInputTable.getAlias();
final List<Column> leftInputTableKeys = leftInputTable.getDataSource().getSchema().key();
final List<Column> missingKeys = leftInputTableKeys.stream().filter(k -> !projection.containsExpression(new QualifiedColumnReferenceExp(leftInputTableName, k.name())) && !projection.containsExpression(new UnqualifiedColumnReferenceExp(ColumnNames.generatedJoinColumnAlias(leftInputTableName, k.name())))).collect(Collectors.toList());
if (!missingKeys.isEmpty()) {
throwMissingKeyColumnForFkJoinException(missingKeys, leftInputTableName);
}
} else {
final boolean atLeastOneKey = joinKey.getAllViableKeys(schema).stream().anyMatch(projection::containsExpression);
if (!atLeastOneKey) {
final boolean synthetic = joinKey.isSynthetic();
final List<? extends Expression> viable = joinKey.getOriginalViableKeys(schema);
throwKeysNotIncludedError(sinkName, "join expression", viable, false, synthetic);
}
}
}
use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class JoinNode method validateColumns.
@Override
protected Set<ColumnReferenceExp> validateColumns(final RequiredColumns requiredColumns) {
final boolean noSyntheticKey = !finalJoin || !joinKey.isSynthetic();
final RequiredColumns updated = noSyntheticKey ? requiredColumns : requiredColumns.asBuilder().remove(new UnqualifiedColumnReferenceExp(getOnlyElement(schema.key()).name())).build();
final Set<ColumnReferenceExp> leftUnknown = left.validateColumns(updated);
final Set<ColumnReferenceExp> rightUnknown = right.validateColumns(updated);
return Sets.intersection(leftUnknown, rightUnknown);
}
use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class FlatMapNodeTest method setUp.
@Before
public void setUp() {
when(source.getSchema()).thenReturn(SOURCE_SCHEMA);
when(source.getNodeOutputType()).thenReturn(DataSourceType.KSTREAM);
when(analysis.getTableFunctions()).thenReturn(ImmutableList.of(A_TABLE_FUNCTION));
when(analysis.getSelectItems()).thenReturn(ImmutableList.of(new AllColumns(Optional.empty()), new SingleColumn(new UnqualifiedColumnReferenceExp(COL0), Optional.empty()), new SingleColumn(A_TABLE_FUNCTION, Optional.empty())));
final MutableFunctionRegistry functionRegistry = new InternalFunctionRegistry();
new UdtfLoader(functionRegistry, Optional.empty(), SqlTypeParser.create(TypeRegistry.EMPTY), true).loadUdtfFromClass(Explode.class, "load path");
flatMapNode = new FlatMapNode(PLAN_ID, source, functionRegistry, analysis);
}
use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class ProjectionTest method shouldNotMatchUnqualifiedColumnToQualifiedSingleColumn.
@Test
public void shouldNotMatchUnqualifiedColumnToQualifiedSingleColumn() {
// Given:
final Projection projection = Projection.of(ImmutableList.of(new SingleColumn(new UnqualifiedColumnReferenceExp(COL0), Optional.empty())));
// Then:
assertThat(projection.containsExpression(new QualifiedColumnReferenceExp(A, COL0)), is(false));
}
use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp 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")))));
}
Aggregations