use of io.confluent.ksql.execution.expression.tree.ComparisonExpression in project ksql by confluentinc.
the class SqlToJavaVisitorTest method shouldGenerateCorrectCodeForTimeTimeLT.
@Test
public void shouldGenerateCorrectCodeForTimeTimeLT() {
// Given:
final ComparisonExpression compExp = new ComparisonExpression(Type.LESS_THAN, TIMECOL, TIMECOL);
// When:
final String java = sqlToJavaVisitor.process(compExp);
// Then:
assertThat(java, containsString("(COL12.compareTo(COL12) < 0)"));
}
use of io.confluent.ksql.execution.expression.tree.ComparisonExpression in project ksql by confluentinc.
the class FilterTypeValidatorTest method shouldThrowOnBadTypeComparison.
@Test
public void shouldThrowOnBadTypeComparison() {
// Given:
final Expression left = new UnqualifiedColumnReferenceExp(COLUMN1);
final Expression right = new IntegerLiteral(10);
final Expression comparision = new ComparisonExpression(Type.EQUAL, left, right);
when(schema.findValueColumn(any())).thenReturn(Optional.of(Column.of(COLUMN1, STRING, VALUE, 10)));
// When:
assertThrows("Error in WHERE expression: " + "Cannot compare col1 (STRING) to 10 (INTEGER) with EQUAL.", KsqlException.class, () -> validator.validateFilterExpression(comparision));
}
use of io.confluent.ksql.execution.expression.tree.ComparisonExpression in project ksql by confluentinc.
the class FilterTypeValidatorTest method shouldThrowOnBadTypeCompoundComparison_leftError.
@Test
public void shouldThrowOnBadTypeCompoundComparison_leftError() {
// Given:
final Expression left1 = new UnqualifiedColumnReferenceExp(COLUMN1);
final Expression right1 = new UnqualifiedColumnReferenceExp(COLUMN2);
final Expression comparision1 = new ComparisonExpression(Type.EQUAL, left1, right1);
final Expression left2 = new UnqualifiedColumnReferenceExp(COLUMN1);
final Expression right2 = new StringLiteral("foo");
final Expression comparision2 = new ComparisonExpression(Type.EQUAL, left2, right2);
final Expression expression = new LogicalBinaryExpression(LogicalBinaryExpression.Type.AND, comparision1, comparision2);
when(schema.findValueColumn(COLUMN1)).thenReturn(Optional.of(Column.of(COLUMN1, STRING, VALUE, 10)));
when(schema.findValueColumn(COLUMN2)).thenReturn(Optional.of(Column.of(COLUMN2, INTEGER, VALUE, 10)));
// When:
assertThrows("Error in WHERE expression: " + "Cannot compare col1 (STRING) to col2 (INTEGER) with EQUAL.", KsqlException.class, () -> validator.validateFilterExpression(expression));
}
use of io.confluent.ksql.execution.expression.tree.ComparisonExpression in project ksql by confluentinc.
the class ExpressionTypeManagerTest method shouldFailIfOperatorCannotBeAppiled.
@Test
public void shouldFailIfOperatorCannotBeAppiled() {
// Given:
final ComparisonExpression expr = new ComparisonExpression(Type.GREATER_THAN, new BooleanLiteral("true"), new BooleanLiteral("false"));
// When:
final Exception e = assertThrows(KsqlException.class, () -> expressionTypeManager.getExpressionSqlType(expr));
// Then:
assertThat(e.getMessage(), containsString("Cannot compare true (BOOLEAN) to false (BOOLEAN) with " + "GREATER_THAN"));
}
use of io.confluent.ksql.execution.expression.tree.ComparisonExpression in project ksql by confluentinc.
the class ExpressionTypeManagerTest method shouldFailIfComparisonOperandsAreIncompatible.
@Test
public void shouldFailIfComparisonOperandsAreIncompatible() {
// Given:
final ComparisonExpression expr = new ComparisonExpression(Type.GREATER_THAN, TestExpressions.COL0, COL1);
// When:
final Exception e = assertThrows(KsqlException.class, () -> expressionTypeManager.getExpressionSqlType(expr));
// Then:
assertThat(e.getMessage(), containsString("Cannot compare COL0 (BIGINT) to COL1 (STRING) with GREATER_THAN"));
}
Aggregations