You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Ian Bertolacci <ia...@workday.com.INVALID> on 2022/11/11 00:11:20 UTC

Adding implementations of operators for RexExecutor?

Howdy,
I’m playing around with some testing expressions after transformation, and would like to use RexExecutor to evaluate\* the original expression and expression resulting from the transformation.
(\*these expressions do not have input refs or any other kinds of “free-variables”)
However, this transformation specifically and intentionally inserts SqlOperators which RexExecutor (specifically RexToLixTranslator) does not know how to implement, and fails.
RexToLixTranslator asks RexImpTable.INSTANCE for the implementation of the operators, but I cant see any way to give RexImpTable.INSTANCE an implementation of an operator.

Any guidance?
Right now I’m using the simple RexUtil.EXECUTOR, but I’m getting the feeling that this is a situation where I need to construct a RexExecutor from scratch with a DataContext that has a Schema with those Functions defined.
Would doing so allow the RexExecutor to implement these non-standard operators?

Thanks!
-Ian J. Bertolacci

Re: Adding implementations of operators for RexExecutor?

Posted by Julian Hyde <jh...@gmail.com>.
Ian,

I don’t think anyone has done this before, but making your own executor does seem to be the right path.

It’s possible that Schema does not need to be part of the solution. Schema is used for looking up operators by name, but if you already have the operators (because they are referenced in the RexCall) then maybe you don’t need Schema.

Julian


> On Nov 15, 2022, at 3:57 AM, Stamatis Zampetakis <za...@gmail.com> wrote:
> 
> Hey Ian,
> 
> If the SqlOperator implements the ImplementableFunction [1] interface then
> you may be able to use the RexExecutor [2] but I assume you already
> explored this direction.
> I am not sure if there is an easier way to achieve this.
> 
> Best,
> Stamatis
> 
> [1]
> https://github.com/apache/calcite/blob/28c5881c8de10751b415aaf3e3f50b3168c893d3/core/src/main/java/org/apache/calcite/schema/ImplementableFunction.java
> [2]
> https://github.com/apache/calcite/blob/28c5881c8de10751b415aaf3e3f50b3168c893d3/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java#L856
> 
> On Fri, Nov 11, 2022 at 1:11 AM Ian Bertolacci
> <ia...@workday.com.invalid> wrote:
> 
>> Howdy,
>> I’m playing around with some testing expressions after transformation, and
>> would like to use RexExecutor to evaluate\* the original expression and
>> expression resulting from the transformation.
>> (\*these expressions do not have input refs or any other kinds of
>> “free-variables”)
>> However, this transformation specifically and intentionally inserts
>> SqlOperators which RexExecutor (specifically RexToLixTranslator) does not
>> know how to implement, and fails.
>> RexToLixTranslator asks RexImpTable.INSTANCE for the implementation of the
>> operators, but I cant see any way to give RexImpTable.INSTANCE an
>> implementation of an operator.
>> 
>> Any guidance?
>> Right now I’m using the simple RexUtil.EXECUTOR, but I’m getting the
>> feeling that this is a situation where I need to construct a RexExecutor
>> from scratch with a DataContext that has a Schema with those Functions
>> defined.
>> Would doing so allow the RexExecutor to implement these non-standard
>> operators?
>> 
>> Thanks!
>> -Ian J. Bertolacci
>> 


Re: Adding implementations of operators for RexExecutor?

Posted by Stamatis Zampetakis <za...@gmail.com>.
Hey Ian,

If the SqlOperator implements the ImplementableFunction [1] interface then
you may be able to use the RexExecutor [2] but I assume you already
explored this direction.
I am not sure if there is an easier way to achieve this.

Best,
Stamatis

[1]
https://github.com/apache/calcite/blob/28c5881c8de10751b415aaf3e3f50b3168c893d3/core/src/main/java/org/apache/calcite/schema/ImplementableFunction.java
[2]
https://github.com/apache/calcite/blob/28c5881c8de10751b415aaf3e3f50b3168c893d3/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java#L856

On Fri, Nov 11, 2022 at 1:11 AM Ian Bertolacci
<ia...@workday.com.invalid> wrote:

> Howdy,
> I’m playing around with some testing expressions after transformation, and
> would like to use RexExecutor to evaluate\* the original expression and
> expression resulting from the transformation.
> (\*these expressions do not have input refs or any other kinds of
> “free-variables”)
> However, this transformation specifically and intentionally inserts
> SqlOperators which RexExecutor (specifically RexToLixTranslator) does not
> know how to implement, and fails.
> RexToLixTranslator asks RexImpTable.INSTANCE for the implementation of the
> operators, but I cant see any way to give RexImpTable.INSTANCE an
> implementation of an operator.
>
> Any guidance?
> Right now I’m using the simple RexUtil.EXECUTOR, but I’m getting the
> feeling that this is a situation where I need to construct a RexExecutor
> from scratch with a DataContext that has a Schema with those Functions
> defined.
> Would doing so allow the RexExecutor to implement these non-standard
> operators?
>
> Thanks!
> -Ian J. Bertolacci
>