[ 
https://issues.apache.org/jira/browse/CALCITE-5382?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17635732#comment-17635732
 ] 

Yueguang Jiao edited comment on CALCITE-5382 at 11/18/22 8:25 AM:
------------------------------------------------------------------

[~jiajunbernoulli], I am not sure the reasons are the same. After some 
debugging, I found it is the `null` value in the second row that ceases the 
loop over the rows.


was (Author: lasyard):
[~jiajunbernoulli]I am not sure the reasons are the same. After some debugging, 
I found it is the `null` value in the second row that ceases the loop over the 
rows.

> Values are not casted to correct type in insertion
> --------------------------------------------------
>
>                 Key: CALCITE-5382
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5382
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.32.0
>            Reporter: Yueguang Jiao
>            Priority: Major
>
> Assume we have created a table by
> {code:sql}
> create table test (
>     id int not null,
>     name varchar not null,
>     score double,
>     primary key(id)
> )
> {code}
> Note the column 'score' is nullable.  Then try to parse and validate a 
> statement as
> {code:sql}
> insert into test values
> (1, 'Alice', 1.0),
> (2, 'Betty', null),
> (3, 'Cindy', 3.0)
> {code}
> Before validation, the 'SqlNode' is
> {code:sql}
> INSERT INTO `test`
> VALUES ROW(1, 'Alice', 1.0),
> ROW(2, 'Betty', NULL),
> ROW(3, 'Cindy', 3.0)
> {code}
> After validation, the `SqlNode` is
> {code:sql}
> VALUES ROW(1, 'Alice', CAST(1.0 AS DOUBLE)),
> ROW(2, 'Betty', NULL),
> ROW(3, 'Cindy', 3.0)
> {code}
> The 'score' column in the first row is casted, but not the one in the third 
> row. I think this is not correct.
> This is tested by the following Java code:
> {code:java}
> SqlParser parser = SqlParser.create(sql);
> SqlNode sqlNode = parser.parseQuery();
> log.debug("sqlNode = {}", sqlNode);
> SqlValidator validator = SqlValidatorUtil.newValidator(
>     SqlStdOperatorTable.instance(),
>     catalogReader,
>     new JavaTypeFactoryImpl(),
>     SqlValidator.Config.DEFAULT
> );
> sqlNode = validator.validate(sqlNode);
> log.debug("sqlNode = {}", sqlNode);
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to