use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class DataSourceExtractorTest method shouldThrowIfSourceDoesNotExist.
@Test
public void shouldThrowIfSourceDoesNotExist() {
// Given:
final AstNode stmt = givenQuery("SELECT * FROM UNKNOWN;");
// When:
final Exception e = assertThrows(KsqlException.class, () -> extractor.extractDataSources(stmt));
// Then:
assertThat(e.getMessage(), containsString("UNKNOWN does not exist."));
}
use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class DataSourceExtractorTest method shouldExtractUnaliasedDataSources.
@Test
public void shouldExtractUnaliasedDataSources() {
// Given:
final AstNode stmt = givenQuery("SELECT * FROM TEST1;");
// When:
extractor.extractDataSources(stmt);
// Then:
assertContainsAlias(TEST1);
}
use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class DataSourceExtractorTest method shouldIncludePseudoColumnsInClashingNames.
@Test
public void shouldIncludePseudoColumnsInClashingNames() {
// Given:
final AstNode stmt = givenQuery("SELECT * FROM TEST1 t1 JOIN TEST2 t2" + " ON test1.col1 = test2.col1;");
// When:
extractor.extractDataSources(stmt);
// Then:
SystemColumns.pseudoColumnNames(ROWPARTITION_ROWOFFSET_ENABLED).forEach(pseudoCol -> assertThat(pseudoCol + " should clash", extractor.isClashingColumnName(pseudoCol)));
}
use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class StatementRewriterTest method shouldRewriteQueryWithFilter.
@Test
public void shouldRewriteQueryWithFilter() {
// Given:
final Query query = givenQuery(Optional.empty(), Optional.of(expression), Optional.empty(), Optional.empty(), Optional.empty());
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.of(rewrittenExpression), 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 shouldRewriteJoin.
@Test
public void shouldRewriteJoin() {
// Given:
final Join join = givenJoin(Optional.empty());
// 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.empty())))));
}
Aggregations