From eecd1b785d76ecd3b9b3c3d03908e84cc0bf4ec2 Mon Sep 17 00:00:00 2001 From: Karol Sobczak Date: Fri, 13 Sep 2019 14:36:57 +0200 Subject: [PATCH] Add support for LIKE to expression verifier --- .../sql/planner/assertions/ExpressionVerifier.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/presto-main/src/test/java/io/prestosql/sql/planner/assertions/ExpressionVerifier.java b/presto-main/src/test/java/io/prestosql/sql/planner/assertions/ExpressionVerifier.java index 9f25469f6bbc..6b81df42b88e 100644 --- a/presto-main/src/test/java/io/prestosql/sql/planner/assertions/ExpressionVerifier.java +++ b/presto-main/src/test/java/io/prestosql/sql/planner/assertions/ExpressionVerifier.java @@ -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; @@ -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 boolean process(List actuals, List expecteds) { if (actuals.size() != expecteds.size()) {