Search in sources :

Example 6 with QualifiedColumnReferenceExp

use of io.confluent.ksql.execution.expression.tree.QualifiedColumnReferenceExp 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));
}
Also used : QualifiedColumnReferenceExp(io.confluent.ksql.execution.expression.tree.QualifiedColumnReferenceExp) SingleColumn(io.confluent.ksql.parser.tree.SingleColumn) UnqualifiedColumnReferenceExp(io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp) Test(org.junit.Test)

Example 7 with QualifiedColumnReferenceExp

use of io.confluent.ksql.execution.expression.tree.QualifiedColumnReferenceExp in project ksql by confluentinc.

the class ExpressionFormatterTest method shouldFormatQualifiedColumnReference.

@Test
public void shouldFormatQualifiedColumnReference() {
    final QualifiedColumnReferenceExp ref = new QualifiedColumnReferenceExp(SourceName.of("foo"), ColumnName.of("bar"));
    assertThat(ExpressionFormatter.formatExpression(ref), equalTo("foo.bar"));
}
Also used : QualifiedColumnReferenceExp(io.confluent.ksql.execution.expression.tree.QualifiedColumnReferenceExp) Test(org.junit.Test)

Example 8 with QualifiedColumnReferenceExp

use of io.confluent.ksql.execution.expression.tree.QualifiedColumnReferenceExp in project ksql by confluentinc.

the class SqlToJavaVisitorTest method shouldThrowOnQualifiedColumnReference.

@Test
public void shouldThrowOnQualifiedColumnReference() {
    // Given:
    final Expression expression = new QualifiedColumnReferenceExp(of("foo"), ColumnName.of("bar"));
    // When:
    assertThrows(UnsupportedOperationException.class, () -> sqlToJavaVisitor.process(expression));
}
Also used : ArithmeticBinaryExpression(io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression) Expression(io.confluent.ksql.execution.expression.tree.Expression) CreateMapExpression(io.confluent.ksql.execution.expression.tree.CreateMapExpression) ArithmeticUnaryExpression(io.confluent.ksql.execution.expression.tree.ArithmeticUnaryExpression) CreateArrayExpression(io.confluent.ksql.execution.expression.tree.CreateArrayExpression) CreateStructExpression(io.confluent.ksql.execution.expression.tree.CreateStructExpression) SimpleCaseExpression(io.confluent.ksql.execution.expression.tree.SimpleCaseExpression) SubscriptExpression(io.confluent.ksql.execution.expression.tree.SubscriptExpression) InListExpression(io.confluent.ksql.execution.expression.tree.InListExpression) ComparisonExpression(io.confluent.ksql.execution.expression.tree.ComparisonExpression) SearchedCaseExpression(io.confluent.ksql.execution.expression.tree.SearchedCaseExpression) QualifiedColumnReferenceExp(io.confluent.ksql.execution.expression.tree.QualifiedColumnReferenceExp) Test(org.junit.Test)

Example 9 with QualifiedColumnReferenceExp

use of io.confluent.ksql.execution.expression.tree.QualifiedColumnReferenceExp in project ksql by confluentinc.

the class ColumnReferenceValidatorTest method shouldGetSourceForUnqualifiedColumnRef.

@Test
public void shouldGetSourceForUnqualifiedColumnRef() {
    // Given:
    final ColumnName column = ColumnName.of("qualified");
    final Expression expression = new QualifiedColumnReferenceExp(SourceName.of("fully"), column);
    when(sourceSchemas.sourcesWithField(any(), any())).thenReturn(sourceNames("something"));
    // When:
    analyzer.analyzeExpression(expression, CLAUSE_TYPE);
    // Then:
    verify(sourceSchemas).sourcesWithField(Optional.of(SourceName.of("fully")), column);
}
Also used : ColumnName(io.confluent.ksql.name.ColumnName) Expression(io.confluent.ksql.execution.expression.tree.Expression) QualifiedColumnReferenceExp(io.confluent.ksql.execution.expression.tree.QualifiedColumnReferenceExp) Test(org.junit.Test)

Example 10 with QualifiedColumnReferenceExp

use of io.confluent.ksql.execution.expression.tree.QualifiedColumnReferenceExp in project ksql by confluentinc.

the class ColumnReferenceValidatorTest method shouldGetSourceForQualifiedColumnRef.

@Test
public void shouldGetSourceForQualifiedColumnRef() {
    // Given:
    final QualifiedColumnReferenceExp expression = new QualifiedColumnReferenceExp(SourceName.of("something"), ColumnName.of("else"));
    when(sourceSchemas.sourcesWithField(any(), any())).thenReturn(ImmutableSet.of(SourceName.of("something")));
    // When:
    final Set<SourceName> columnRefs = analyzer.analyzeExpression(expression, CLAUSE_TYPE);
    // Then:
    verify(sourceSchemas).sourcesWithField(Optional.of(expression.getQualifier()), expression.getColumnName());
    assertThat(Iterables.getOnlyElement(columnRefs), is(SourceName.of("something")));
}
Also used : QualifiedColumnReferenceExp(io.confluent.ksql.execution.expression.tree.QualifiedColumnReferenceExp) SourceName(io.confluent.ksql.name.SourceName) Test(org.junit.Test)

Aggregations

QualifiedColumnReferenceExp (io.confluent.ksql.execution.expression.tree.QualifiedColumnReferenceExp)18 Test (org.junit.Test)13 Expression (io.confluent.ksql.execution.expression.tree.Expression)9 UnqualifiedColumnReferenceExp (io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp)6 Context (io.confluent.ksql.engine.rewrite.ExpressionTreeRewriter.Context)4 ColumnName (io.confluent.ksql.name.ColumnName)4 SingleColumn (io.confluent.ksql.parser.tree.SingleColumn)4 Optional (java.util.Optional)4 VisitParentExpressionVisitor (io.confluent.ksql.execution.expression.tree.VisitParentExpressionVisitor)3 SelectExpression (io.confluent.ksql.execution.plan.SelectExpression)3 KsqlWindowExpression (io.confluent.ksql.execution.windows.KsqlWindowExpression)3 SourceName (io.confluent.ksql.name.SourceName)3 WindowExpression (io.confluent.ksql.parser.tree.WindowExpression)3 KsqlException (io.confluent.ksql.util.KsqlException)3 ExpressionTreeRewriter (io.confluent.ksql.engine.rewrite.ExpressionTreeRewriter)2 CodeGenRunner (io.confluent.ksql.execution.codegen.CodeGenRunner)2 KsqlTopic (io.confluent.ksql.execution.ddl.commands.KsqlTopic)2 ArithmeticBinaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression)2 ColumnReferenceExp (io.confluent.ksql.execution.expression.tree.ColumnReferenceExp)2 ComparisonExpression (io.confluent.ksql.execution.expression.tree.ComparisonExpression)2