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

Danny Chen commented on CALCITE-3894:
-------------------------------------

Finally i got the reason:

The RelDataTypeFactory#leastRestrictive finds the common type for IN, CASE and 
SET operations. For common type with DATE and TIMESTAMP, it returns DATE. The 
root cause is that rules in SqlTypeAssignmentRule decide that DATE is 
assignable from TIMESTAMP and TIMESTAMP is assignable from DATE, which is 
actually wrong. Although in Java, this assignment makes sense but that does not 
mean it's true in SQL, because DATE and TIMESTAMP have different time unit.

> The Union operation between DATE with TIMESTAMP returns a wrong result
> ----------------------------------------------------------------------
>
>                 Key: CALCITE-3894
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3894
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: TANG Wen-hui
>            Assignee: TANG Wen-hui
>            Priority: Major
>
> {code:java}
> @Test public void testUnionTime() {
>  CalciteAssert.AssertThat assertThat = CalciteAssert.that();
>  String query = "select * from (\n"
>  + "select \"id\" from (VALUES(DATE '2018-02-03')) \"foo\"(\"id\")\n"
>  + "union\n"
>  + "select \"id\" from (VALUES(TIMESTAMP '2008-03-31 12:23:34')) 
> \"foo\"(\"id\"))";
>  assertThat.query(query).returns("id=2108-03-12\nid=2018-02-03\n");
> }{code}
> The test with wrong result passed.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to