From 17de17dfa585316f3c5487c50da66f05ee81910c Mon Sep 17 00:00:00 2001 From: Cheng Xuntao <7731943+xtcyclist@users.noreply.github.com> Date: Fri, 14 Apr 2023 18:19:02 +0800 Subject: [PATCH] stop the pushing down of not expressions that are not rewritten to proper forms. (#5502) --- src/graph/visitor/ExtractFilterExprVisitor.cpp | 15 +++++++++++++++ src/graph/visitor/ExtractFilterExprVisitor.h | 1 + 2 files changed, 16 insertions(+) diff --git a/src/graph/visitor/ExtractFilterExprVisitor.cpp b/src/graph/visitor/ExtractFilterExprVisitor.cpp index f4a97e1ecc7..6a36564ba21 100644 --- a/src/graph/visitor/ExtractFilterExprVisitor.cpp +++ b/src/graph/visitor/ExtractFilterExprVisitor.cpp @@ -231,6 +231,21 @@ void ExtractFilterExprVisitor::visit(ColumnExpression *) { canBePushed_ = false; } +void ExtractFilterExprVisitor::visit(UnaryExpression *expr) { + if (expr->kind() == Expression::Kind::kUnaryNot && + (expr->operand()->kind() == Expression::Kind::kLogicalAnd || + expr->operand()->kind() == Expression::Kind::kLogicalOr)) { + // The NOT operation in this kind of expressions should had been reduced. + // In case it had not been reduced, pushing it down would cause wrong results. + canBePushed_ = false; + return; + } + if (expr->operand() != nullptr) { + expr->operand()->accept(this); + return; + } +} + // @return: whether this logical expr satisfies split condition bool ExtractFilterExprVisitor::visitLogicalAnd(LogicalExpression *expr, std::vector &flags) { DCHECK_EQ(expr->kind(), Expression::Kind::kLogicalAnd); diff --git a/src/graph/visitor/ExtractFilterExprVisitor.h b/src/graph/visitor/ExtractFilterExprVisitor.h index 67deec512ad..40bccf7b46a 100644 --- a/src/graph/visitor/ExtractFilterExprVisitor.h +++ b/src/graph/visitor/ExtractFilterExprVisitor.h @@ -84,6 +84,7 @@ class ExtractFilterExprVisitor final : public ExprVisitorImpl { void visit(LogicalExpression *) override; void visit(ColumnExpression *) override; void visit(SubscriptRangeExpression *) override; + void visit(UnaryExpression *) override; private: enum class PushType {