use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class StatementRewriterTest method shouldRewriteQueryWithHaving.
@Test
public void shouldRewriteQueryWithHaving() {
// Given:
final Query query = givenQuery(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(expression));
when(expressionRewriter.apply(expression, context)).thenReturn(rewrittenExpression);
// 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.of(rewrittenExpression), Optional.of(refinementInfo), false, optionalInt)));
}
use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class StatementRewriterTest method shouldRewriteQueryWithPartitionBy.
@Test
public void shouldRewriteQueryWithPartitionBy() {
// Given:
final PartitionBy partitionBy = mock(PartitionBy.class);
final PartitionBy rewrittenPartitionBy = mock(PartitionBy.class);
final Query query = givenQuery(Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(partitionBy), Optional.empty());
when(mockRewriter.apply(partitionBy, context)).thenReturn(rewrittenPartitionBy);
// When:
final AstNode rewritten = rewriter.rewrite(query, context);
// Then:
assertThat(rewritten, equalTo(new Query(location, rewrittenSelect, rewrittenRelation, Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(rewrittenPartitionBy), Optional.empty(), Optional.of(refinementInfo), false, optionalInt)));
}
use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class StatementRewriterTest method shouldRewriteCreateTable.
@Test
public void shouldRewriteCreateTable() {
// Given:
final TableElement tableElement1 = givenTableElement("foo");
final TableElement tableElement2 = givenTableElement("bar");
final TableElement rewrittenTableElement1 = givenTableElement("baz");
final TableElement rewrittenTableElement2 = givenTableElement("boz");
final CreateTable ct = new CreateTable(location, sourceName, TableElements.of(tableElement1, tableElement2), false, false, sourceProperties, false);
when(mockRewriter.apply(tableElement1, context)).thenReturn(rewrittenTableElement1);
when(mockRewriter.apply(tableElement2, context)).thenReturn(rewrittenTableElement2);
// When:
final AstNode rewritten = rewriter.rewrite(ct, context);
// Then:
assertThat(rewritten, equalTo(new CreateTable(location, sourceName, TableElements.of(rewrittenTableElement1, rewrittenTableElement2), false, false, sourceProperties, false)));
}
use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class StatementRewriterTest method shouldRewriteCSAS.
@Test
public void shouldRewriteCSAS() {
final CreateStreamAsSelect csas = new CreateStreamAsSelect(location, sourceName, query, false, false, csasProperties);
when(mockRewriter.apply(query, context)).thenReturn(rewrittenQuery);
final AstNode rewritten = rewriter.rewrite(csas, context);
assertThat(rewritten, equalTo(new CreateStreamAsSelect(location, sourceName, rewrittenQuery, false, false, csasProperties)));
}
use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class StatementRewriterTest method shouldRewriteCSASWithPartitionBy.
@Test
public void shouldRewriteCSASWithPartitionBy() {
final CreateStreamAsSelect csas = new CreateStreamAsSelect(location, sourceName, query, false, false, csasProperties);
when(mockRewriter.apply(query, context)).thenReturn(rewrittenQuery);
when(expressionRewriter.apply(expression, context)).thenReturn(rewrittenExpression);
final AstNode rewritten = rewriter.rewrite(csas, context);
assertThat(rewritten, equalTo(new CreateStreamAsSelect(location, sourceName, rewrittenQuery, false, false, csasProperties)));
}
Aggregations