use of io.confluent.ksql.execution.expression.tree.LikePredicate in project ksql by confluentinc.
the class ExpressionTypeManagerTest method shouldEvaluateBooleanSchemaForLikeExpression.
@Test
public void shouldEvaluateBooleanSchemaForLikeExpression() {
final Expression expression = new LikePredicate(COL1, new StringLiteral("%foo"), Optional.empty());
final SqlType exprType0 = expressionTypeManager.getExpressionSqlType(expression);
assertThat(exprType0, is(SqlTypes.BOOLEAN));
}
use of io.confluent.ksql.execution.expression.tree.LikePredicate in project ksql by confluentinc.
the class SqlToJavaVisitorTest method shouldGenerateCorrectCodeForLikePattern.
@Test
public void shouldGenerateCorrectCodeForLikePattern() {
// Given:
final Expression expression = new LikePredicate(COL1, new StringLiteral("%foo"), Optional.empty());
// When:
final String javaExpression = sqlToJavaVisitor.process(expression);
// Then:
assertThat(javaExpression, equalTo("LikeEvaluator.matches(COL1, \"%foo\")"));
}
use of io.confluent.ksql.execution.expression.tree.LikePredicate in project ksql by confluentinc.
the class ExpressionFormatterTest method shouldFormatLikePredicate.
@Test
public void shouldFormatLikePredicate() {
final LikePredicate predicate = new LikePredicate(new StringLiteral("string"), new StringLiteral("*"), Optional.empty());
assertThat(ExpressionFormatter.formatExpression(predicate), equalTo("('string' LIKE '*')"));
}
use of io.confluent.ksql.execution.expression.tree.LikePredicate in project ksql by confluentinc.
the class ExpressionFormatterTest method shouldFormatLikePredicateWithEscape.
@Test
public void shouldFormatLikePredicateWithEscape() {
final LikePredicate predicate = new LikePredicate(new StringLiteral("string"), new StringLiteral("*"), Optional.of('!'));
assertThat(ExpressionFormatter.formatExpression(predicate), equalTo("('string' LIKE '*' ESCAPE '!')"));
}
use of io.confluent.ksql.execution.expression.tree.LikePredicate in project ksql by confluentinc.
the class QueryFilterNodeTest method shouldThrowNonStringForLike.
@Test
public void shouldThrowNonStringForLike() {
// Given:
final Expression expression = new LikePredicate(new StringLiteral("a"), new IntegerLiteral(10), Optional.empty());
// When:
final KsqlException e = assertThrows(KsqlException.class, () -> new QueryFilterNode(NODE_ID, source, expression, metaStore, ksqlConfig, false, plannerOptions));
// Then:
assertThat(e.getMessage(), containsString("Like condition must be between strings"));
}
Aggregations