diff --git a/velox/dwio/common/MetadataFilter.cpp b/velox/dwio/common/MetadataFilter.cpp index ff337dab80b24..f65afa6adcd50 100644 --- a/velox/dwio/common/MetadataFilter.cpp +++ b/velox/dwio/common/MetadataFilter.cpp @@ -157,13 +157,6 @@ std::unique_ptr MetadataFilter::Node::fromExpression( } return std::make_unique(std::move(lhs), std::move(rhs)); } - if (call->name() == "not") { - auto negated = fromExpression(scanSpec, *call->inputs()[0]); - if (!negated) { - return nullptr; - } - return std::make_unique(std::move(negated)); - } if (call->name() == "endswith" || call->name() == "contains" || call->name() == "like" || call->name() == "startswith" || call->name() == "in" || call->name() == "rlike" || diff --git a/velox/substrait/SubstraitToVeloxPlan.h b/velox/substrait/SubstraitToVeloxPlan.h index cd4a05b5c4a3e..1a885f15f245d 100644 --- a/velox/substrait/SubstraitToVeloxPlan.h +++ b/velox/substrait/SubstraitToVeloxPlan.h @@ -189,7 +189,8 @@ class SubstraitVeloxPlanConverter { /// existing conditions for this field. bool setLeftBound(bool forOrRelation = false) { if (forOrRelation) { - return true; + if (!rightBound_) leftBound_ = true; + return !rightBound_; } if (leftBound_ || inRange_ || multiRange_) { return false; @@ -202,7 +203,8 @@ class SubstraitVeloxPlanConverter { /// existing conditions for this field. bool setRightBound(bool forOrRelation = false) { if (forOrRelation) { - return true; + if (!leftBound_) rightBound_ = true; + return !leftBound_; } if (rightBound_ || inRange_ || multiRange_) { return false; diff --git a/velox/type/Filter.cpp b/velox/type/Filter.cpp index b348fea5b9d6b..5e1942e238877 100644 --- a/velox/type/Filter.cpp +++ b/velox/type/Filter.cpp @@ -661,25 +661,29 @@ bool BytesRange::testBytesRange( if (lowerUnbounded_) { // min > upper_ + int compare = compareRanges(min->data(), min->length(), upper_); return min.has_value() && - compareRanges(min->data(), min->length(), upper_) < 0; + (compare < 0 || (!upperExclusive_ && compare == 0)); } if (upperUnbounded_) { // max < lower_ + int compare = compareRanges(max->data(), max->length(), lower_); return max.has_value() && - compareRanges(max->data(), max->length(), lower_) > 0; + (compare > 0 || (!lowerExclusive_ && compare == 0)); } // min > upper_ + int compare = compareRanges(min->data(), min->length(), upper_); if (min.has_value() && - compareRanges(min->data(), min->length(), upper_) > 0) { + (compare > 0 || (compare == 0 && upperExclusive_))) { return false; } // max < lower_ + compare = compareRanges(max->data(), max->length(), lower_); if (max.has_value() && - compareRanges(max->data(), max->length(), lower_) < 0) { + (compare < 0 || (compare == 0 && lowerExclusive_))) { return false; } return true;