use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class StatementRewriterTest method shouldRewriteStatements.
@Test
public void shouldRewriteStatements() {
// Given:
final Statement statement1 = mock(Statement.class);
final Statement statement2 = mock(Statement.class);
final Statement rewritten1 = mock(Statement.class);
final Statement rewritten2 = mock(Statement.class);
final Statements statements = new Statements(location, ImmutableList.of(statement1, statement2));
when(mockRewriter.apply(statement1, context)).thenReturn(rewritten1);
when(mockRewriter.apply(statement2, context)).thenReturn(rewritten2);
// When:
final AstNode rewritten = rewriter.rewrite(statements, context);
// Then:
assertThat(rewritten, equalTo(new Statements(location, ImmutableList.of(rewritten1, rewritten2))));
}
use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class StatementRewriterTest method shouldRewriteCTAS.
@Test
public void shouldRewriteCTAS() {
// Given:
final CreateTableAsSelect ctas = new CreateTableAsSelect(location, sourceName, query, false, false, csasProperties);
when(mockRewriter.apply(query, context)).thenReturn(rewrittenQuery);
// When:
final AstNode rewritten = rewriter.rewrite(ctas, context);
// Then:
assertThat(rewritten, equalTo(new CreateTableAsSelect(location, sourceName, rewrittenQuery, false, false, csasProperties)));
}
use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class StatementRewriterTest method shouldRewriteInsertInto.
@Test
public void shouldRewriteInsertInto() {
// Given:
final InsertInto ii = new InsertInto(location, sourceName, query, insertIntoProperties);
when(mockRewriter.apply(query, context)).thenReturn(rewrittenQuery);
// When:
final AstNode rewritten = rewriter.rewrite(ii, context);
// Then:
assertThat(rewritten, equalTo(new InsertInto(location, sourceName, rewrittenQuery, insertIntoProperties)));
}
use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class StatementRewriterTest method shouldRewriteAliasedRelation.
@Test
public void shouldRewriteAliasedRelation() {
// Given:
final AliasedRelation aliasedRelation = new AliasedRelation(location, relation, SourceName.of("alias"));
when(mockRewriter.apply(relation, context)).thenReturn(rewrittenRelation);
// When:
final AstNode rewritten = rewriter.rewrite(aliasedRelation, context);
// Then:
assertThat(rewritten, equalTo(new AliasedRelation(location, rewrittenRelation, SourceName.of("alias"))));
}
use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class StatementRewriterTest method shouldRewriteSingleColumn.
@Test
public void shouldRewriteSingleColumn() {
// Given:
final SingleColumn singleColumn = new SingleColumn(location, expression, Optional.of(ColumnName.of("foo")));
when(expressionRewriter.apply(expression, context)).thenReturn(rewrittenExpression);
// When:
final AstNode rewritten = rewriter.rewrite(singleColumn, context);
// Then:
assertThat(rewritten, equalTo(new SingleColumn(location, rewrittenExpression, Optional.of(ColumnName.of("foo")))));
}
Aggregations