use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class DataSourceExtractorTest method shouldHandleAliasedDataSources.
@Test
public void shouldHandleAliasedDataSources() {
// Given:
final AstNode stmt = givenQuery("SELECT * FROM TEST1 t;");
// When:
extractor.extractDataSources(stmt);
// Then:
assertContainsAlias(SourceName.of("T"));
}
use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class DataSourceExtractorTest method shouldExtractUnaliasedJoinDataSources.
@Test
public void shouldExtractUnaliasedJoinDataSources() {
// Given:
final AstNode stmt = givenQuery("SELECT * FROM TEST1 JOIN TEST2" + " ON test1.col1 = test2.col1;");
// When:
extractor.extractDataSources(stmt);
// Then:
assertContainsAlias(TEST1, TEST2);
}
use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class DataSourceExtractorTest method shouldDetectClashingColumnNames.
@Test
public void shouldDetectClashingColumnNames() {
// Given:
final AstNode stmt = givenQuery("SELECT * FROM TEST1 t1 JOIN TEST2 t2" + " ON test1.col1 = test2.col1;");
// When:
extractor.extractDataSources(stmt);
// Then:
assertThat("should clash", extractor.isClashingColumnName(COL0));
}
use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class DataSourceExtractorTest method shouldDetectNoneClashingColumnNames.
@Test
public void shouldDetectNoneClashingColumnNames() {
// 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 not clash", !extractor.isClashingColumnName(ColumnName.of("ORDERTIME")));
}
use of io.confluent.ksql.parser.tree.AstNode in project ksql by confluentinc.
the class DataSourceExtractorTest method shouldThrowIfLeftJoinSourceDoesNotExist.
@Test
public void shouldThrowIfLeftJoinSourceDoesNotExist() {
// Given:
final AstNode stmt = givenQuery("SELECT * FROM UNKNOWN JOIN TEST2" + " ON UNKNOWN.col1 = test2.col1;");
// When:
final Exception e = assertThrows(KsqlException.class, () -> extractor.extractDataSources(stmt));
// Then:
assertThat(e.getMessage(), containsString("UNKNOWN does not exist."));
}
Aggregations