Hey Eric,

EnumerabeProject and EnumerableFilter are not meant to appear in the
plan because they cannot be implemented; as you observed the implement
method throws an exception. For this reason it does not make sense to
use ENUMERABLE_PROJECT_RULE and ENUMERABLE_FILTER_RULE and this is why
the example does not contain them. I assume that you are getting the
UnsupportedOperationException because you added those rules to the
example.

If you instruct the planner to come up with an ENUMERABLE plan and you
include the aforementioned rules then the resulting plan may include
EnumerableProject and EnumerableFilter and that is a valid plan from a
planning perspective because it respects the requested convention. The
planner does not use the EnumerableRel#implement method and the method
becomes relevant only during execution.

Both projection and filter in the enumerable convention are
implemented via the Calc operator and that's why the PROJECT_TO_CALC
rule exists.

Best,
Stamatis

On Mon, Jan 29, 2024 at 4:51 PM Eric Berryman <eric.berry...@gmail.com> wrote:
>
> correction:
> When compared to the jdbc implementation, which works for me using the
> EnumerableConvention.
> I see the difference is that the EnumerableProject gets mapped to a
> EnumerableCalc.
> Mapped to LogicalProject.NONE
> https://github.com/apache/calcite/blob/75511b82ab13ff95bc65f6180d40cf1e234b834e/core/src/main/java/org/apache/calcite/prepare/CalcitePrepareImpl.java#L1061
> Then to EnumerableCalc
> https://github.com/apache/calcite/blob/75511b82ab13ff95bc65f6180d40cf1e234b834e/core/src/main/java/org/apache/calcite/prepare/CalcitePrepareImpl.java#L1065
>
>
> On Mon, Jan 29, 2024 at 10:10 AM Eric Berryman <eric.berry...@gmail.com>
> wrote:
>
> > When compared to the jdbc implementation, which works for me using the
> > EnumerableConvention.
> > I see the difference is that the EnumerableProject gets mapped to a
> > CalcProject.
> > Mapped to Project.NONE
> >
> > https://github.com/apache/calcite/blob/75511b82ab13ff95bc65f6180d40cf1e234b834e/core/src/main/java/org/apache/calcite/prepare/CalcitePrepareImpl.java#L1061
> > Then to CalcProject
> >
> > https://github.com/apache/calcite/blob/75511b82ab13ff95bc65f6180d40cf1e234b834e/core/src/main/java/org/apache/calcite/prepare/CalcitePrepareImpl.java#L1065
> >
> > That sounds like this rule: CoreRules.PROJECT_TO_CALC
> > But, I don't see this getting applied as such.
> >
> > Thank you again,
> > Eric
> >
> > On Sun, Jan 28, 2024 at 12:35 PM Eric Berryman <eric.berry...@gmail.com>
> > wrote:
> >
> >> I was trying some examples, the first being the EndToEndExampleBindable:
> >>
> >> https://github.com/zabetak/calcite/blob/demo-january-2021/core/src/test/java/org/apache/calcite/examples/foodmart/java/EndToEndExampleBindable.java
> >>
> >> This worked fine for me, but when I attempted to use the pattern in
> >> EndToEndExampleEnumerable:
> >>
> >> https://github.com/zabetak/calcite/blob/demo-january-2021/core/src/test/java/org/apache/calcite/examples/foodmart/java/EndToEndExampleEnumerable.java
> >>
> >> I am getting the following error message:
> >> Suppressed: java.lang.UnsupportedOperationException: null
> >> at
> >> org.apache.calcite.adapter.enumerable.EnumerableProject.implement(EnumerableProject.java:91)
> >> at
> >> org.apache.calcite.adapter.enumerable.EnumerableRelImplementor.implementRoot(EnumerableRelImplementor.java:114)
> >> ... 53 common frames omitted
> >>
> >> from the line:
> >> Bindable<Object[]> executablePlan = EnumerableInterpretable.toBindable(
> >>         new HashMap<>(),
> >>         null,
> >>         (EnumerableRel) phyPlan,
> >>         EnumerableRel.Prefer.ARRAY);
> >>
> >> I'm confused how the EnumerableProject implement method has this
> >> java.lang.UnsupportedOperationException, and what am I missing. I'm not
> >> quite connecting the dots on this, and how it should look.
> >>
> >> Thank you!
> >> Eric
> >>
> >>

Reply via email to