You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2022/05/11 16:52:24 UTC

[GitHub] [calcite] yingyuwang opened a new pull request, #2803: [CALCITE-5130] AssertionError: "Conversion to relational algebra failed to preserve datatypes" when union VARCHAR literal and CAST(null AS INTEGER)

yingyuwang opened a new pull request, #2803:
URL: https://github.com/apache/calcite/pull/2803

   In AbstractTypeCoercion#promoteToVarChar() return resultType with nullability if any of the types being promoted are nullable.


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-5130] AssertionError: "Conversion to relational algebra failed to preserve datatypes" when union VARCHAR literal and CAST(null AS INTEGER) [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu merged PR #2803:
URL: https://github.com/apache/calcite/pull/2803


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [calcite] chunweilei commented on a diff in pull request #2803: [CALCITE-5130] AssertionError: "Conversion to relational algebra failed to preserve datatypes" when union VARCHAR literal and CAST(null AS INTEGER)

Posted by GitBox <gi...@apache.org>.
chunweilei commented on code in PR #2803:
URL: https://github.com/apache/calcite/pull/2803#discussion_r876543812


##########
core/src/test/java/org/apache/calcite/test/TypeCoercionTest.java:
##########
@@ -216,7 +216,7 @@ private static ImmutableList<RelDataType> combine(
     sql("select '1' from (values(true)) union values 2")
         .type("RecordType(VARCHAR NOT NULL EXPR$0) NOT NULL");
     sql("select (select 1+2 from (values true)) tt from (values(true)) union values '2'")
-        .type("RecordType(VARCHAR NOT NULL TT) NOT NULL");
+        .type("RecordType(VARCHAR TT) NOT NULL");
     // union with star

Review Comment:
   Is this change expected?



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [calcite] yingyuwang commented on a diff in pull request #2803: [CALCITE-5130] AssertionError: "Conversion to relational algebra failed to preserve datatypes" when union VARCHAR literal and CAST(null AS INTEGER)

Posted by GitBox <gi...@apache.org>.
yingyuwang commented on code in PR #2803:
URL: https://github.com/apache/calcite/pull/2803#discussion_r877126272


##########
core/src/test/java/org/apache/calcite/test/TypeCoercionTest.java:
##########
@@ -216,7 +216,7 @@ private static ImmutableList<RelDataType> combine(
     sql("select '1' from (values(true)) union values 2")
         .type("RecordType(VARCHAR NOT NULL EXPR$0) NOT NULL");
     sql("select (select 1+2 from (values true)) tt from (values(true)) union values '2'")
-        .type("RecordType(VARCHAR NOT NULL TT) NOT NULL");
+        .type("RecordType(VARCHAR TT) NOT NULL");
     // union with star

Review Comment:
   What I found is Calcite seems to add `isNullable=true` when there is a sub query, for example we have:
   ```
       sql("select 1 from (values 1)")
           .type("RecordType(INTEGER NOT NULL EXPR$0) NOT NULL"); // isNullable=false for EXPR$0 when not query from subquery
       sql("select (select 1 from (values 1))")    
           .type("RecordType(INTEGER EXPR$0) NOT NULL"); // isNullable=true for EXPR$0 when query from subquery
   ```
   So before the change, `isNullable=true` is lost at `promoteToVarChar()` for this test.



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org