chucheng92 commented on code in PR #3395:
URL: https://github.com/apache/calcite/pull/3395#discussion_r1328761843


##########
core/src/test/resources/sql/misc.iq:
##########
@@ -2167,12 +2167,12 @@ select array[1,null,2] as a from (values (1));
 
 values array['a',null,'bcd'],
   array['efgh'];
-+----------------+
-| EXPR$0         |
-+----------------+
-| [a, null, bcd] |
-| [efgh]         |
-+----------------+
++------------------+
+| EXPR$0           |
++------------------+
+| [a  , null, bcd] |

Review Comment:
   @JiajunBernoulli thanks for reviewing. this is a import change in this PR.
   
   if we have `array('A', 'AB')`, the component type is `char(2)`, because the 
element explicit casting bug we not cast 'A' to `char(2)` to match derived 
component type. The correct behavior let 'A' match the `char(2)`, it means 'A' 
need cast to `char(2)`, it will fill with extra spaces by calcite default.
   
   This is calcite and sql standard limitation. Of course, this does look 
weird, actually calcite has other ways to remove spaces. We can activate 
`SqlConformanceEnum.PRAGMATIC_2003` to let 
`shouldConvertRaggedUnionTypesToVarying` be true, it will change array/map char 
type to varchar type to skip these spaces. And I also noticed that some engines 
such as apache flink set `shouldConvertRaggedUnionTypesToVarying` to true by 
default. (calcite is false by default)
   
   More details can be found in javadoc 
https://github.com/apache/calcite/blob/d9dd3ac8a9f695e111a0a5e77f45b61b90f4b5b6/core/src/main/java/org/apache/calcite/sql/validate/SqlConformance.java#L465C7-L465C7
   
   I also have added some cases in the PR to show this difference.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to