use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class SchemaKTableTest method shouldBuildSchemaForSelectKey.
@Test
public void shouldBuildSchemaForSelectKey() {
// Given:
final String selectQuery = "SELECT col0 AS K, col2, col3 FROM test2 WHERE col0 > 100 EMIT CHANGES;";
final PlanNode logicalPlan = buildLogicalPlan(selectQuery);
initialSchemaKTable = buildSchemaKTableFromPlan(logicalPlan);
// When:
final SchemaKTable<?> resultSchemaKTable = initialSchemaKTable.selectKey(valueFormat.getFormatInfo(), ImmutableList.of(new UnqualifiedColumnReferenceExp(ColumnName.of("COL0"))), Optional.empty(), childContextStacker, true);
// Then:
assertThat(resultSchemaKTable.getSchema(), is(schemaResolver.resolve(resultSchemaKTable.getSourceStep(), initialSchemaKTable.getSchema())));
}
use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class SchemaKTableTest method shouldFailSelectKeyForceRepartitionOnNonKeyColumn.
@Test
public void shouldFailSelectKeyForceRepartitionOnNonKeyColumn() {
// Given:
final String selectQuery = "SELECT col0, col2, col3 FROM test2 WHERE col0 > 100 EMIT CHANGES;";
final PlanNode logicalPlan = buildLogicalPlan(selectQuery);
initialSchemaKTable = buildSchemaKTableFromPlan(logicalPlan);
// When:
final UnsupportedOperationException e = assertThrows(UnsupportedOperationException.class, () -> initialSchemaKTable.selectKey(valueFormat.getFormatInfo(), ImmutableList.of(new UnqualifiedColumnReferenceExp(ColumnName.of("COL1"))), Optional.empty(), childContextStacker, true));
// Then:
assertThat(e.getMessage(), containsString("Cannot repartition a TABLE source."));
}
use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class SchemaKTableTest method shouldRewriteTimeComparisonInFilter.
@Test
public void shouldRewriteTimeComparisonInFilter() {
// Given:
final String selectQuery = "SELECT col0, col2, col3 FROM test2 " + "WHERE ROWTIME = '1984-01-01T00:00:00+00:00' EMIT CHANGES;";
final PlanNode logicalPlan = buildLogicalPlan(selectQuery);
final FilterNode filterNode = (FilterNode) logicalPlan.getSources().get(0).getSources().get(0);
initialSchemaKTable = buildSchemaKTableFromPlan(logicalPlan);
// When:
final SchemaKTable<?> filteredSchemaKTable = initialSchemaKTable.filter(filterNode.getPredicate(), childContextStacker);
// Then:
final TableFilter<?> step = (TableFilter) filteredSchemaKTable.getSourceTableStep();
assertThat(step.getFilterExpression(), Matchers.equalTo(new ComparisonExpression(ComparisonExpression.Type.EQUAL, new UnqualifiedColumnReferenceExp(ColumnName.of("ROWTIME")), new LongLiteral(441763200000L))));
}
use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class ColumnReferenceValidatorTest method shouldThrowOnPossibleSyntheticKeyColumnIfNotValidSyntheticKeyColumnName.
@Test
public void shouldThrowOnPossibleSyntheticKeyColumnIfNotValidSyntheticKeyColumnName() {
// Given:
when(sourceSchemas.isJoin()).thenReturn(true);
final Expression notSyntheticKey = new UnqualifiedColumnReferenceExp(ColumnName.of("NOT_ROWKEY"));
// When:
final Exception e = assertThrows(UnknownColumnException.class, () -> analyzer.analyzeExpression(notSyntheticKey, "SELECT"));
// Then:
assertThat(e.getMessage(), containsString("SELECT column 'NOT_ROWKEY' cannot be resolved."));
}
use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class AggregateAnalyzerTest method shouldNotCaptureWindowStartAsRequiredColumn.
@Test
public void shouldNotCaptureWindowStartAsRequiredColumn() {
// Given:
givenWindowExpression();
givenSelectExpression(new UnqualifiedColumnReferenceExp(SystemColumns.WINDOWSTART_NAME));
// When:
final AggregateAnalysisResult result = analyzer.analyze(analysis, selects);
// Then:
final List<ColumnName> requiredColumnNames = result.getRequiredColumns().stream().map(ColumnReferenceExp::getColumnName).collect(Collectors.toList());
assertThat(requiredColumnNames, not(hasItem(SystemColumns.WINDOWSTART_NAME)));
}
Aggregations