[CALCITE-3210] Fix the bug that RelToSqlConverter converts "cast(null as $type)" just as null#1338
[CALCITE-3210] Fix the bug that RelToSqlConverter converts "cast(null as $type)" just as null#1338weidong3630 wants to merge 5 commits intoapache:masterfrom
Conversation
|
@weidong3630 You can have multiple commits to one PR and do not close the old one, the committers would rebase the code when merging into master. |
Thanks for your advise, I just do it according to the calcite document. I will be attention to it later. |
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java
Outdated
Show resolved
Hide resolved
|
The first word of a commit message should generally not be "Fix". I changed the JIRA subject to "JDBC adapter should generate "CAST(NULL AS type)" rather than "NULL", so maybe use that as the commit message. |
julianhyde
left a comment
There was a problem hiding this comment.
Spaces after '//' please.
Javadoc method comments should start with a verb, first letter upper-case, and end with a period. Rather than "Check whether null item in select need to be casted", write "Returns whether a NULL literal in the SELECT clause needs to be wrapped in a CAST." In the javadoc of that method, can you explain what the algorithm is? I guess you want to wrap if and only if the expression will end up in a SELECT clause? In which case the javadoc should be "Returns whether a NULL literal needs to be wrapped in a CAST."
|
I've adopted your suggestions and modify my code and commit message. @julianhyde |
| * because that the type of NULL can be inferred by the target table of TableModify, | ||
| * so NULL does not need to be wrapped in a CAST. | ||
| * Here is an example, | ||
| * "INSERT INTO t SELECT CAST(NULL AS INT) AS c1, c2 FROM t1" |
There was a problem hiding this comment.
What do you mean by "SingleRel", i didn't see any in your example.
There was a problem hiding this comment.
Implemented done.
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java
Outdated
Show resolved
Hide resolved
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
Show resolved
Hide resolved
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java
Show resolved
Hide resolved
c80dd45 to
52a2d1d
Compare
52a2d1d to
689a5bb
Compare
|
I've solved some conflicts and rebase the commit. Who can help me to review or merge this code? |
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java
Outdated
Show resolved
Hide resolved
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
Show resolved
Hide resolved
| sql(expected).exec(); | ||
| } | ||
|
|
||
| @Test public void testSelectNullWithInsert() { |
There was a problem hiding this comment.
Thanks, can we also give a test case for Join relational expression ?
There was a problem hiding this comment.
Done, see testSelectNullWithInsertFromJoin.
[CALCITE-3267] Remove method SqlDataTypeSpec#deriveType(RelDataTypefa…
1ae3e6c to
199a46c
Compare
…er than "NULL" conditionally (Wang Weidong)
199a46c to
0bcce38
Compare
…er than "NULL" conditionally (Wang Weidong) Add test case of "testSelectNullWithInsertFromJoin".
| + "\"account\"(\"account_id\",\"account_parent\",\"account_type\",\"account_rollup\")" | ||
| + "\tselect \"product\".\"product_id\", \n" | ||
| + "\tcast(NULL AS INT), \n" | ||
| + "\tcast(\"product\".\"product_id\" as varchar), \n" |
There was a problem hiding this comment.
Can we replace all these "\t" with "\n" ? Also put a "\n" at the end of every sql statement line.
…her than "NULL" conditionally (Wang Weidong)
Modify format of test case.
…her than "NULL" conditionally (Wang Weidong)
Modify format of test case.
danny0405
left a comment
There was a problem hiding this comment.
+1 , except some nit problems about code style, will fix when merging.
…er than "NULL" conditionally (Wang Weidong) Always wrap NULL literal in Project project list with CAST operator during rel-to-sql conversion. close apache#1338
Fix the bug described in https://issues.apache.org/jira/browse/CALCITE-3210?filter=-1