diff --git a/CHANGELOG.md b/CHANGELOG.md index b47ba24..f727b79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ * Optimize `join.restrict`, split predicate and push down the tree. +* Make sure restrict.restrict keeps applying further optimizations down + the tree. + ## 0.21.0 - 2023-05-18 * BREAKING: minimal version for ruby is now 2.7. Ruby 2.4 and 2.6 have diff --git a/lib/bmg/operator/restrict.rb b/lib/bmg/operator/restrict.rb index 9f14998..ed9345a 100644 --- a/lib/bmg/operator/restrict.rb +++ b/lib/bmg/operator/restrict.rb @@ -51,7 +51,7 @@ def to_ast protected def _restrict(type, predicate) - Restrict.new(type, @operand, @predicate & predicate) + @operand.restrict(@predicate & predicate) end protected ### inspect diff --git a/spec/unit/operator/test_restrict.rb b/spec/unit/operator/test_restrict.rb index 57a4784..a4c9805 100644 --- a/spec/unit/operator/test_restrict.rb +++ b/spec/unit/operator/test_restrict.rb @@ -4,10 +4,10 @@ module Operator describe Restrict do let(:data) { - [ + Relation.new([ { a: 1, b: 2 }, { a: 11, b: 2 } - ] + ]) } subject {