You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Ravi Kapoor <ka...@gmail.com> on 2024/05/03 05:22:43 UTC
Dynamic Parameters Handling in RelNode
Hello Team,
Is there any way in the calcite framework to use runtime variables in Rel
Node in order to get the same variable back in the translated query?
Basically I want the same variable to be used back as the runtime parameter
after query translation.
Here I am talking specifically about using dynamic parameters in
table/column identifiers and not dynamic rex nodes.
Let's say in Teradata I can write below query
*TD*: select employee_id, TRIM(employee_name) from :*table_name*
The translated sql should give back to me the same parameter in the query.
*say Trim is mapped to LTRIM*
*BigQuery*: select employee_id, LTRIM(employee_name) from :*table_name*
I believe we can only have static values in schema plus to
create tables/columns. But what about such cases?
Need to handle this gracefully with no string manipulation.
--
Thanks,
Ravi
Re: Dynamic Parameters Handling in RelNode
Posted by Walaa Eldin Moustafa <wa...@gmail.com>.
You should be able to do it at the SqlNode stage. You can create a
SqlShuttle that replaces your placeholder table name with another table
name.
Re: Dynamic Parameters Handling in RelNode
Posted by Ravi Kapoor <ka...@gmail.com>.
Hi Walaa,
Adding onto the last mail:
1) I already have the value of *table_name* parameter with schema and table
object to help calcite resolving it while creating RelNode.
Is there any way to pass this? But In the translated query the value
should be replaced with the key itself.
Or Do we always need to pass this in the sql query as in the static query
itself?
On Fri, May 3, 2024 at 11:04 AM Walaa Eldin Moustafa <wa...@gmail.com>
wrote:
> Hi Ravi,
>
> RelNodes depend on specific table objects with known schemas. Unless we
> know that table's schema there is no way to generate the RelNode in the
> first place. Maybe if you know the schema (data types of the table
> columns), it is possible to get around the lack of a name, but I do not see
> how this works if there is no table object or schema in the first place.
>
> Thanks,
> Walaa.
>
>
> On Thu, May 2, 2024 at 10:23 PM Ravi Kapoor <ka...@gmail.com>
> wrote:
>
> > Hello Team,
> > Is there any way in the calcite framework to use runtime variables in Rel
> > Node in order to get the same variable back in the translated query?
> > Basically I want the same variable to be used back as the runtime
> parameter
> > after query translation.
> >
> > Here I am talking specifically about using dynamic parameters in
> > table/column identifiers and not dynamic rex nodes.
> >
> > Let's say in Teradata I can write below query
> > *TD*: select employee_id, TRIM(employee_name) from :*table_name*
> >
> > The translated sql should give back to me the same parameter in the
> query.
> > *say Trim is mapped to LTRIM*
> > *BigQuery*: select employee_id, LTRIM(employee_name) from :*table_name*
> >
> > I believe we can only have static values in schema plus to
> > create tables/columns. But what about such cases?
> > Need to handle this gracefully with no string manipulation.
> >
> > --
> > Thanks,
> > Ravi
> >
>
--
Thanks,
Ravi Kapoor
+91-9818764564
kapoorravi63@gmail.com
Re: Dynamic Parameters Handling in RelNode
Posted by Walaa Eldin Moustafa <wa...@gmail.com>.
Hi Ravi,
RelNodes depend on specific table objects with known schemas. Unless we
know that table's schema there is no way to generate the RelNode in the
first place. Maybe if you know the schema (data types of the table
columns), it is possible to get around the lack of a name, but I do not see
how this works if there is no table object or schema in the first place.
Thanks,
Walaa.
On Thu, May 2, 2024 at 10:23 PM Ravi Kapoor <ka...@gmail.com> wrote:
> Hello Team,
> Is there any way in the calcite framework to use runtime variables in Rel
> Node in order to get the same variable back in the translated query?
> Basically I want the same variable to be used back as the runtime parameter
> after query translation.
>
> Here I am talking specifically about using dynamic parameters in
> table/column identifiers and not dynamic rex nodes.
>
> Let's say in Teradata I can write below query
> *TD*: select employee_id, TRIM(employee_name) from :*table_name*
>
> The translated sql should give back to me the same parameter in the query.
> *say Trim is mapped to LTRIM*
> *BigQuery*: select employee_id, LTRIM(employee_name) from :*table_name*
>
> I believe we can only have static values in schema plus to
> create tables/columns. But what about such cases?
> Need to handle this gracefully with no string manipulation.
>
> --
> Thanks,
> Ravi
>