use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class SqlToJavaVisitorTest method shouldGenerateCorrectCodeForDecimalDecimalEQ.
@Test
public void shouldGenerateCorrectCodeForDecimalDecimalEQ() {
// Given:
final ComparisonExpression compExp = new ComparisonExpression(ComparisonExpression.Type.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 shouldGenerateCorrectCodeForDecimalAdd.
@Test
public void shouldGenerateCorrectCodeForDecimalAdd() {
// Given:
final ArithmeticBinaryExpression binExp = new ArithmeticBinaryExpression(Operator.ADD, new UnqualifiedColumnReferenceExp(ColumnName.of("COL8")), new UnqualifiedColumnReferenceExp(ColumnName.of("COL8")));
// When:
final String java = sqlToJavaVisitor.process(binExp);
// Then:
assertThat(java, is("(COL8.add(COL8, new MathContext(3, RoundingMode.UNNECESSARY)).setScale(1))"));
}
use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class SqlToJavaVisitorTest method shouldGenerateCorrectCodeForDecimalDecimalGT.
@Test
public void shouldGenerateCorrectCodeForDecimalDecimalGT() {
// Given:
final ComparisonExpression compExp = new ComparisonExpression(ComparisonExpression.Type.GREATER_THAN, 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 shouldGenerateCastDecimalToDoubleInBinaryExpression.
@Test
public void shouldGenerateCastDecimalToDoubleInBinaryExpression() {
// Given:
final ArithmeticBinaryExpression binExp = new ArithmeticBinaryExpression(Operator.ADD, new UnqualifiedColumnReferenceExp(ColumnName.of("COL8")), new UnqualifiedColumnReferenceExp(ColumnName.of("COL3")));
// When:
final String java = sqlToJavaVisitor.process(binExp);
// Then:
final String doubleCast = CastEvaluator.generateCode("COL8", SqlTypes.decimal(2, 1), SqlTypes.DOUBLE, ksqlConfig);
assertThat(java, containsString(doubleCast));
}
use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class SqlToJavaVisitorTest method shouldGenerateCorrectCodeForDecimalNegation.
@Test
public void shouldGenerateCorrectCodeForDecimalNegation() {
// Given:
final ArithmeticUnaryExpression binExp = new ArithmeticUnaryExpression(Optional.empty(), Sign.MINUS, new UnqualifiedColumnReferenceExp(ColumnName.of("COL8")));
// When:
final String java = sqlToJavaVisitor.process(binExp);
// Then:
assertThat(java, is("(COL8.negate(new MathContext(2, RoundingMode.UNNECESSARY)))"));
}
Aggregations