use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class SchemaKStreamTest method shouldBuildSchemaForGroupByKey.
@Test
public void shouldBuildSchemaForGroupByKey() {
// Given:
givenInitialKStreamOf("SELECT col0, col1 FROM test1 WHERE col0 > 100 EMIT CHANGES;");
final List<Expression> groupBy = Collections.singletonList(new UnqualifiedColumnReferenceExp(ColumnName.of("COL0")));
// When:
final SchemaKGroupedStream groupedSchemaKStream = initialSchemaKStream.groupBy(valueFormat.getFormatInfo(), groupBy, childContextStacker);
// Then:
assertThat(groupedSchemaKStream.schema, is(schemaResolver.resolve(groupedSchemaKStream.getSourceStep(), initialSchemaKStream.getSchema())));
}
use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class SchemaKTableTest method shouldBuildStepForSelectKey.
@Test
public void shouldBuildStepForSelectKey() {
// 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 SchemaKTable<?> resultSchemaKTable = initialSchemaKTable.selectKey(valueFormat.getFormatInfo(), ImmutableList.of(new UnqualifiedColumnReferenceExp(ColumnName.of("COL0"))), Optional.empty(), childContextStacker, true);
// Then:
assertThat(resultSchemaKTable.getSourceTableStep(), equalTo(ExecutionStepFactory.tableSelectKey(childContextStacker, initialSchemaKTable.getSourceTableStep(), InternalFormats.of(keyFormat.withSerdeFeatures(SerdeFeatures.of(SerdeFeature.UNWRAP_SINGLES)), valueFormat.getFormatInfo()), ImmutableList.of(new UnqualifiedColumnReferenceExp(ColumnName.of("COL0"))))));
}
use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class SqlToJavaVisitorTest method shouldGenerateCorrectCodeForDecimalMod.
@Test
public void shouldGenerateCorrectCodeForDecimalMod() {
// Given:
final ArithmeticBinaryExpression binExp = new ArithmeticBinaryExpression(Operator.MODULUS, new UnqualifiedColumnReferenceExp(ColumnName.of("COL8")), new UnqualifiedColumnReferenceExp(ColumnName.of("COL8")));
// When:
final String java = sqlToJavaVisitor.process(binExp);
// Then:
assertThat(java, is("(COL8.remainder(COL8, new MathContext(2, RoundingMode.UNNECESSARY)).setScale(1))"));
}
use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class SqlToJavaVisitorTest method shouldGenerateCorrectCodeForDecimalDecimalLEQ.
@Test
public void shouldGenerateCorrectCodeForDecimalDecimalLEQ() {
// Given:
final ComparisonExpression compExp = new ComparisonExpression(ComparisonExpression.Type.LESS_THAN_OR_EQUAL, new UnqualifiedColumnReferenceExp(ColumnName.of("COL8")), new UnqualifiedColumnReferenceExp(ColumnName.of("COL9")));
// When:
final String java = sqlToJavaVisitor.process(compExp);
// Then:
assertThat(java, containsString("(COL8.compareTo(COL9) <= 0))"));
}
use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class SqlToJavaVisitorTest method shouldGenerateCorrectCodeForDecimalSubtract.
@Test
public void shouldGenerateCorrectCodeForDecimalSubtract() {
// Given:
final ArithmeticBinaryExpression binExp = new ArithmeticBinaryExpression(Operator.SUBTRACT, new UnqualifiedColumnReferenceExp(ColumnName.of("COL8")), new UnqualifiedColumnReferenceExp(ColumnName.of("COL8")));
// When:
final String java = sqlToJavaVisitor.process(binExp);
// Then:
assertThat(java, is("(COL8.subtract(COL8, new MathContext(3, RoundingMode.UNNECESSARY)).setScale(1))"));
}
Aggregations