Hi Eric,

If I am not mistaken, in order to achieve that you need to use
FilterSetOpTransposeRule [1], see CoreRules#FILTER_SET_OP_TRANSPOSE.

Best regards,
Ruben

[1]
https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/rel/rules/FilterSetOpTransposeRule.java

On Mon, Jan 8, 2024 at 5:28 PM Eric Berryman <eric.berry...@gmail.com>
wrote:

> Thank you,
>
> That makes sense. But it seems I should see a filter pushed below for a
> where on a union, no?
> ie.
> SELECT t2.field
> FROM (
> SELECT id, field FROM table1
> UNION ALL
> SELECT id, field FROM table2
> UNION ALL
> SELECT id, field FROM table3) as t2
> WHERE t2.field = 'test'
>
> Thank you again!
> Eric
>
>
> On Wed, Jan 3, 2024 at 5:43 AM Stamatis Zampetakis <zabe...@gmail.com>
> wrote:
>
> > Hey Eric,
> >
> > When you have a disjunction in the WHERE clause it may not be safe to
> > push the condition below a join especially when it comes to outer
> > joins. I suppose that the FilterJoinRule [1] is the place that you
> > want to check to see if the filter can be pushed below the join and
> > into the scan.
> >
> > Best,
> > Stamatis
> >
> > [1]
> >
> https://github.com/apache/calcite/blob/8d9b27f1ace7f975407920cb88806715b1f0ef82/core/src/main/java/org/apache/calcite/rel/rules/FilterJoinRule.java
> >
> > On Tue, Jan 2, 2024 at 11:22 PM Eric Berryman <eric.berry...@gmail.com>
> > wrote:
> > >
> > > Hello,
> > >
> > > I'm making a FilterableTable with LDAP as a backend.
> > >
> > > I noticed in the FilterableTable method:
> > > public Enumerable<Object[]> scan(DataContext root, List<RexNode>
> filters)
> > >
> > > The filters list is empty if the sql where clause is checking the same
> > > field in all tables.
> > > ie.
> > > select test1.field test2.field
> > > from test1
> > > full outer join test2 on test1.id = test2.id
> > > where test1.field = 'myval' or test2.field = 'myval';
> > >
> > > When I do an EXPLAIN PLAN FOR select ...
> > > I notice the BindableTableScan filters array is empty with both:
> > > where test1.field = 'myval' or test2.field = 'myval';
> > > and it has the filter if I remove one:
> > > where test1.field = 'myval'
> > >
> > > Is there an example I could be pointed to help understand the query
> > planner
> > > here, and hopefully write my implementation such that the filters show
> up
> > > as expected for each table?
> > >
> > > Thank you!
> > > Eric
> >
>

Reply via email to