You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by bluejoe <bl...@cnic.cn> on 2016/08/22 15:17:12 UTC
scan(DataContext, java.util.List) gets strange node like
'CAST($1):....' for a varchar column
Hi,
Dear developers,
I am working on a SQL engine based on Calcite.
I defined a AbstractTable which provides a getRowType() method to tell its columns look like: NAME char, AGE integer
Then I override the scan(DataContext, java.util.List<RexNode>) method to implement the searching function.
When I sent a SQL command like
select * from PERSONS where NAME=‘bluejoe’ and AGE>30
In the scan(DataContext, java.util.List<RexNode>) method,
I found the filter on column `AGE` is parsed properly like `>($2, 30)`
While the filter on column `NAME` is parsed as:
=(CAST($1):CHAR(7) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" NOT NULL, 'bluejoe’)
To make my program work, I have to unwrap the CastFunction Object to get the inner $1 value, ignoring extra information, CHAR(7), for example. You know, this way looks very strange and easy to crash.
I am wonder if there is a more robust way to get the inline `NAME` column name?
Or if I define the column type in a wrong way?
I need your kind help!
Many thanks!
Best regards,
shen, from China
Re: scan(DataContext, java.util.List) gets strange node like 'CAST($1):....' for a varchar column
Posted by Julian Hyde <jh...@apache.org>.
Is your problem related to https://issues.apache.org/jira/browse/CALCITE-1153 <https://issues.apache.org/jira/browse/CALCITE-1153> or https://issues.apache.org/jira/browse/CALCITE-1330? <https://issues.apache.org/jira/browse/CALCITE-1330?>
> On Aug 22, 2016, at 8:17 AM, bluejoe <bl...@cnic.cn> wrote:
>
> Hi,
> Dear developers,
>
> I am working on a SQL engine based on Calcite.
> I defined a AbstractTable which provides a getRowType() method to tell its columns look like: NAME char, AGE integer
>
> Then I override the scan(DataContext, java.util.List<RexNode>) method to implement the searching function.
> When I sent a SQL command like
>
> select * from PERSONS where NAME=‘bluejoe’ and AGE>30
>
> In the scan(DataContext, java.util.List<RexNode>) method,
> I found the filter on column `AGE` is parsed properly like `>($2, 30)`
>
> While the filter on column `NAME` is parsed as:
>
> =(CAST($1):CHAR(7) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" NOT NULL, 'bluejoe’)
>
> To make my program work, I have to unwrap the CastFunction Object to get the inner $1 value, ignoring extra information, CHAR(7), for example. You know, this way looks very strange and easy to crash.
>
> I am wonder if there is a more robust way to get the inline `NAME` column name?
> Or if I define the column type in a wrong way?
>
> I need your kind help!
> Many thanks!
>
> Best regards,
> shen, from China
>