use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class StatementRewriterTest method shouldRewriteQuery.
@Test
public void shouldRewriteQuery() {
// Given:
final Query query = givenQuery(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty());
// When:
final AstNode rewritten = rewriter.rewrite(query, context);
// Then:
assertThat(rewritten, equalTo(new Query(location, rewrittenSelect, rewrittenRelation, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(refinementInfo), false, optionalInt)));
}
use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class StatementRewriterTest method shouldRewritePartitionBy.
@Test
public void shouldRewritePartitionBy() {
// Given:
final PartitionBy partitionBy = new PartitionBy(location, ImmutableList.of(expression));
when(expressionRewriter.apply(expression, context)).thenReturn(rewrittenExpression);
// When:
final AstNode rewritten = rewriter.rewrite(partitionBy, context);
// Then:
assertThat(rewritten, equalTo(new PartitionBy(location, ImmutableList.of(rewrittenExpression))));
}
use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class StatementRewriterTest method shouldRewriteGroupBy.
@Test
public void shouldRewriteGroupBy() {
// Given:
final Expression exp1 = mock(Expression.class);
final Expression exp2 = mock(Expression.class);
final Expression rewrittenExp1 = mock(Expression.class);
final Expression rewrittenExp2 = mock(Expression.class);
final GroupBy groupBy = new GroupBy(location, ImmutableList.of(exp1, exp2));
when(expressionRewriter.apply(exp1, context)).thenReturn(rewrittenExp1);
when(expressionRewriter.apply(exp2, context)).thenReturn(rewrittenExp2);
// When:
final AstNode rewritten = rewriter.rewrite(groupBy, context);
// Then:
assertThat(rewritten, equalTo(new GroupBy(location, ImmutableList.of(rewrittenExp1, rewrittenExp2))));
}
use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class StatementRewriterTest method shouldRewriteJoinWithWindowExpression.
@Test
public void shouldRewriteJoinWithWindowExpression() {
// Given:
final WithinExpression withinExpression = mock(WithinExpression.class);
final WithinExpression rewrittenWithinExpression = mock(WithinExpression.class);
final Join join = givenJoin(Optional.of(withinExpression));
when(mockRewriter.apply(withinExpression, context)).thenReturn(rewrittenWithinExpression);
// When:
final AstNode rewritten = rewriter.rewrite(join, context);
// Then:
assertThat(rewritten, equalTo(new Join(location, rewrittenRelation, ImmutableList.of(new JoinedSource(Optional.empty(), rewrittenRightRelation, Type.LEFT, joinCriteria, Optional.of(rewrittenWithinExpression))))));
}
use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class DataSourceExtractorTest method shouldDetectClashingColumnNamesEvenIfOneJoinSourceHasNoClash.
@Test
public void shouldDetectClashingColumnNamesEvenIfOneJoinSourceHasNoClash() {
// Given:
final AstNode stmt = givenQuery("SELECT * FROM ORDERS " + "JOIN TEST1 t1 ON ORDERS.ITEMID = T1.COL1 " + "JOIN TEST2 t2 ON test1.col1 = test2.col1;");
// When:
extractor.extractDataSources(stmt);
// Then:
assertThat("should clash", extractor.isClashingColumnName(COL0));
}
Aggregations