use of io.confluent.ksql.execution.expression.tree.ComparisonExpression in project ksql by confluentinc.
the class ExpressionTypeManagerTest method testComparisonExpr.
@Test
public void testComparisonExpr() {
final Expression expression = new ComparisonExpression(Type.GREATER_THAN, TestExpressions.COL0, COL3);
final SqlType exprType = expressionTypeManager.getExpressionSqlType(expression);
assertThat(exprType, is(SqlTypes.BOOLEAN));
}
use of io.confluent.ksql.execution.expression.tree.ComparisonExpression in project ksql by confluentinc.
the class ExpressionTypeManagerTest method shouldFailForCheckingComplexTypeEquality.
@Test
public void shouldFailForCheckingComplexTypeEquality() {
// Given:
final Expression expression = new ComparisonExpression(Type.EQUAL, MAPCOL, ADDRESS);
// When:
final Exception e = assertThrows(KsqlException.class, () -> expressionTypeManager.getExpressionSqlType(expression));
// Then:
assertThat(e.getMessage(), containsString("Cannot compare COL5 (MAP<BIGINT, DOUBLE>) to COL6 " + "(STRUCT<`NUMBER` BIGINT, `STREET` STRING, `CITY` STRING, `STATE` STRING, " + "`ZIPCODE` BIGINT>) with EQUAL"));
}
use of io.confluent.ksql.execution.expression.tree.ComparisonExpression in project ksql by confluentinc.
the class ExpressionTypeManagerTest method shouldFailForComplexTypeComparison.
@Test
public void shouldFailForComplexTypeComparison() {
// Given:
final Expression expression = new ComparisonExpression(Type.GREATER_THAN, MAPCOL, ADDRESS);
// When:
final Exception e = assertThrows(KsqlException.class, () -> expressionTypeManager.getExpressionSqlType(expression));
// Then:
assertThat(e.getMessage(), containsString("Cannot compare COL5 (MAP<BIGINT, DOUBLE>) to COL6 (STRUCT<`NUMBER` BIGINT, " + "`STREET` STRING, `CITY` STRING, `STATE` STRING, `ZIPCODE` BIGINT>) " + "with GREATER_THAN"));
}
use of io.confluent.ksql.execution.expression.tree.ComparisonExpression in project ksql by confluentinc.
the class ExpressionTypeManagerTest method shouldGetCorrectSchemaForSearchedCase.
@Test
public void shouldGetCorrectSchemaForSearchedCase() {
// Given:
final Expression expression = new SearchedCaseExpression(ImmutableList.of(new WhenClause(new ComparisonExpression(Type.LESS_THAN, COL7, new IntegerLiteral(10)), new StringLiteral("small")), new WhenClause(new ComparisonExpression(Type.LESS_THAN, COL7, new IntegerLiteral(100)), new StringLiteral("medium"))), Optional.of(new StringLiteral("large")));
// When:
final SqlType result = expressionTypeManager.getExpressionSqlType(expression);
// Then:
assertThat(result, is(SqlTypes.STRING));
}
use of io.confluent.ksql.execution.expression.tree.ComparisonExpression in project ksql by confluentinc.
the class SqlPredicateTest method shouldCompileEvaluator.
@Test
public void shouldCompileEvaluator() {
// Given:
predicate = new SqlPredicate(new ComparisonExpression(Type.LESS_THAN, COL0, new LongLiteral(100)), SCHEMA, KSQL_CONFIG, functionRegistry);
transformer = predicate.getTransformer(processingLogger);
// When:
final Optional<GenericRow> result1 = transformer.transform("key", genericRow(99L), ctx);
final Optional<GenericRow> result2 = transformer.transform("key", genericRow(100L), ctx);
// Then:
assertThat(result1, is(not(Optional.empty())));
assertThat(result2, is(Optional.empty()));
}
Aggregations