Fix verification for boolean and coalesce exprs
@@ -17,6 +17,7 @@ import com.facebook.presto.sql.tree.ArithmeticBinaryExpression;
import com.facebook.presto.sql.tree.AstVisitor;
import com.facebook.presto.sql.tree.BooleanLiteral;
import com.facebook.presto.sql.tree.Cast;
+import com.facebook.presto.sql.tree.CoalesceExpression;
import com.facebook.presto.sql.tree.ComparisonExpression;
import com.facebook.presto.sql.tree.DoubleLiteral;
import com.facebook.presto.sql.tree.Expression;
@@ -174,8 +175,11 @@ final class ExpressionVerifier
@Override
protected Boolean visitBooleanLiteral(BooleanLiteral actual, Expression expected)
{
+ if (expected instanceof BooleanLiteral) {
return getValueFromLiteral(actual).equals(getValueFromLiteral(expected));
}
+ return false;
+ }
private static String getValueFromLiteral(Expression expression)
{
@@ -235,4 +239,22 @@ final class ExpressionVerifier
}
return symbolAliases.get(((SymbolReference) expected).getName()).equals(actual);
}
+
+ @Override
+ protected Boolean visitCoalesceExpression(CoalesceExpression actual, Expression expected)
+ {
+ if (!(expected instanceof CoalesceExpression)) {
+ return false;
+ }
+
+ CoalesceExpression expectedCoalesce = (CoalesceExpression) expected;
+ if (actual.getOperands().size() == expectedCoalesce.getOperands().size()) {
+ boolean verified = true;
+ for (int i = 0; i < actual.getOperands().size(); i++) {
+ verified &= process(actual.getOperands().get(i), expectedCoalesce.getOperands().get(i));
+ }
+ return verified;
+ }
+ return false;
+ }
}
