Skip to content

Commit

Permalink
Add support for LIKE to expression verifier
Browse files Browse the repository at this point in the history
  • Loading branch information
sopel39 committed Oct 2, 2019
1 parent eade180 commit eecd1b7
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import io.prestosql.sql.tree.InPredicate;
import io.prestosql.sql.tree.IsNotNullPredicate;
import io.prestosql.sql.tree.IsNullPredicate;
import io.prestosql.sql.tree.LikePredicate;
import io.prestosql.sql.tree.LogicalBinaryExpression;
import io.prestosql.sql.tree.LongLiteral;
import io.prestosql.sql.tree.Node;
Expand Down Expand Up @@ -470,6 +471,19 @@ protected Boolean visitTryExpression(TryExpression actual, Node expectedExpressi
return process(actual.getInnerExpression(), expected.getInnerExpression());
}

protected Boolean visitLikePredicate(LikePredicate actual, Node expectedExpression)
{
if (!(expectedExpression instanceof LikePredicate)) {
return false;
}

LikePredicate expected = (LikePredicate) expectedExpression;

return process(actual.getValue(), expected.getValue())
&& process(actual.getPattern(), expected.getPattern())
&& process(actual.getEscape(), expected.getEscape());
}

private <T extends Node> boolean process(List<T> actuals, List<T> expecteds)
{
if (actuals.size() != expecteds.size()) {
Expand Down

0 comments on commit eecd1b7

Please sign in to comment.