You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Paul Trepagnier <pa...@trepagnier.org> on 2019/02/06 22:07:31 UTC
Calcite Validator Customization
I am using Calcite to try to be a federated database server for a BI tool.
This BI tool is sending queries that I cannot change at the source. So, I
am trying to do some customizations within Calcite to handle these
queries.
For instance, one of the queries tries to do a sql concatenate between a
string and an integer. Calcite throws an exception for
this: org.apache.calcite.sql.validate.SqlValidatorException: Cannot apply
'||' to arguments of type '<VARCHAR> || <INTEGER>'. Supported form(s):
'<STRING> || <STRING>'
Is there an easy way to override the behavior of the concatenate operator?
I am new to Calcite, so I do not know what my options are for customizing
the planning/validation behavior. If someone is able to point me in the
right direction, I would greatly appreciate it.
Thank you for any help you can provide,
Paul
Re: Calcite Validator Customization
Posted by Hongze Zhang <no...@126.com>.
Hi,
We used to face the same problem overriding the default behavior including operand type checker of a standard operator. If you are using Calcite as an individual planner (or other circumstances you are not taking the Calcite's default planner tool org.apache.calcite.prepare.PlannerImpl) and using built-in validator implementation (org.apache.calcite.sql.validate.SqlValidatorImpl), you should set validator.setIdentifierExpansion(true) after creating your own validator, this way the overrided operators would be retained by relational algebras.
Best,
Hongze
At 2019-02-07 08:24:00, "Michael Mior" <mm...@apache.org> wrote:
>There are two main steps you'd have to take here. Firstly, you'd have
>to change the operand types accepted by CONCAT in SqlStdOperatorTable.
>Second, you'd have to redefine the CONCAT method in RexImpTable to
>something that actually builds the string instead of just using
>String.concat.
>
>Unfortunately, I don't think you can override the behaviour of
>built-in operators without making your build of Calcite.
>--
>Michael Mior
>mmior@apache.org
>
>Le mer. 6 févr. 2019 à 17:07, Paul Trepagnier <pa...@trepagnier.org> a écrit :
>>
>> I am using Calcite to try to be a federated database server for a BI tool.
>> This BI tool is sending queries that I cannot change at the source. So, I
>> am trying to do some customizations within Calcite to handle these
>> queries.
>>
>> For instance, one of the queries tries to do a sql concatenate between a
>> string and an integer. Calcite throws an exception for
>> this: org.apache.calcite.sql.validate.SqlValidatorException: Cannot apply
>> '||' to arguments of type '<VARCHAR> || <INTEGER>'. Supported form(s):
>> '<STRING> || <STRING>'
>>
>> Is there an easy way to override the behavior of the concatenate operator?
>> I am new to Calcite, so I do not know what my options are for customizing
>> the planning/validation behavior. If someone is able to point me in the
>> right direction, I would greatly appreciate it.
>>
>> Thank you for any help you can provide,
>>
>> Paul
Re: Calcite Validator Customization
Posted by Michael Mior <mm...@apache.org>.
There are two main steps you'd have to take here. Firstly, you'd have
to change the operand types accepted by CONCAT in SqlStdOperatorTable.
Second, you'd have to redefine the CONCAT method in RexImpTable to
something that actually builds the string instead of just using
String.concat.
Unfortunately, I don't think you can override the behaviour of
built-in operators without making your build of Calcite.
--
Michael Mior
mmior@apache.org
Le mer. 6 févr. 2019 à 17:07, Paul Trepagnier <pa...@trepagnier.org> a écrit :
>
> I am using Calcite to try to be a federated database server for a BI tool.
> This BI tool is sending queries that I cannot change at the source. So, I
> am trying to do some customizations within Calcite to handle these
> queries.
>
> For instance, one of the queries tries to do a sql concatenate between a
> string and an integer. Calcite throws an exception for
> this: org.apache.calcite.sql.validate.SqlValidatorException: Cannot apply
> '||' to arguments of type '<VARCHAR> || <INTEGER>'. Supported form(s):
> '<STRING> || <STRING>'
>
> Is there an easy way to override the behavior of the concatenate operator?
> I am new to Calcite, so I do not know what my options are for customizing
> the planning/validation behavior. If someone is able to point me in the
> right direction, I would greatly appreciate it.
>
> Thank you for any help you can provide,
>
> Paul