use of io.confluent.ksql.execution.expression.tree.QualifiedColumnReferenceExp in project ksql by confluentinc.
the class LogicalPlanner method buildJoinKey.
private JoinKey buildJoinKey(final Join join) {
final List<QualifiedColumnReferenceExp> viableKeyColumns = join.viableKeyColumns();
if (viableKeyColumns.isEmpty()) {
return JoinKey.syntheticColumn();
}
final Projection projection = Projection.of(analysis.original().getSelectItems());
final List<QualifiedColumnReferenceExp> availableKeyColumns = viableKeyColumns.stream().filter(projection::containsExpression).collect(Collectors.toList());
final QualifiedColumnReferenceExp keyColumn = availableKeyColumns.isEmpty() ? // Lack of availability is handle later.
viableKeyColumns.get(0) : availableKeyColumns.get(0);
final ColumnName keyColumnName = ColumnNames.generatedJoinColumnAlias(keyColumn.getQualifier(), keyColumn.getColumnName());
return JoinKey.sourceColumn(keyColumnName, viableKeyColumns);
}
use of io.confluent.ksql.execution.expression.tree.QualifiedColumnReferenceExp in project ksql by confluentinc.
the class ExpressionTypeManagerTest method shouldFailOnQualfiedColumnReference.
@Test
public void shouldFailOnQualfiedColumnReference() {
// Given:
final Expression expression = new QualifiedColumnReferenceExp(SourceName.of("foo"), ColumnName.of("bar"));
// When:
assertThrows(IllegalStateException.class, () -> expressionTypeManager.getExpressionSqlType(expression));
}
use of io.confluent.ksql.execution.expression.tree.QualifiedColumnReferenceExp in project ksql by confluentinc.
the class ProjectionTest method shouldNotMatchQualifiedColumnToDifferentQualifiedSingleColumn.
@Test
public void shouldNotMatchQualifiedColumnToDifferentQualifiedSingleColumn() {
// Given:
final Projection projection = Projection.of(ImmutableList.of(new SingleColumn(new QualifiedColumnReferenceExp(A, COL0), Optional.empty())));
// Then:
assertThat(projection.containsExpression(new QualifiedColumnReferenceExp(B, COL0)), is(false));
}
use of io.confluent.ksql.execution.expression.tree.QualifiedColumnReferenceExp in project ksql by confluentinc.
the class ProjectionTest method shouldNotMatchQualifiedColumnToUnqualifiedSingleColumn.
@Test
public void shouldNotMatchQualifiedColumnToUnqualifiedSingleColumn() {
// Given:
final Projection projection = Projection.of(ImmutableList.of(new SingleColumn(new QualifiedColumnReferenceExp(A, COL0), Optional.empty())));
// Then:
assertThat(projection.containsExpression(new UnqualifiedColumnReferenceExp(COL0)), is(false));
}
use of io.confluent.ksql.execution.expression.tree.QualifiedColumnReferenceExp in project ksql by confluentinc.
the class ColumnReferenceValidatorTest method shouldThrowOnPossibleSyntheticKeyColumnIfQualifiedColumnReference.
@Test
public void shouldThrowOnPossibleSyntheticKeyColumnIfQualifiedColumnReference() {
// Given:
when(sourceSchemas.isJoin()).thenReturn(true);
final Expression notSyntheticKey = new QualifiedColumnReferenceExp(SourceName.of("Bob"), ColumnName.of("ROWKEY"));
// When:
final Exception e = assertThrows(UnknownColumnException.class, () -> analyzer.analyzeExpression(notSyntheticKey, "SELECT"));
// Then:
assertThat(e.getMessage(), containsString("SELECT column 'Bob.ROWKEY' cannot be resolved."));
}
Aggregations