[ https://issues.apache.org/jira/browse/CALCITE-3894?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17076014#comment-17076014 ]
Danny Chen edited comment on CALCITE-3894 at 4/6/20, 2:50 AM: -------------------------------------------------------------- This example query expects to trigger implicit type coercion, for CALCITE type coercion rules, DATE union TIMESTAMP outputs TIMESTAMP. But it didn't, and outputs DATE, i think we should fix this. I checked this SQL in PostgreSQL: {code:sql} select * from (VALUES(DATE '2018-02-03')) t1(a) union all select * from (VALUES(TIMESTAMP '2008-03-31 12:23:34')) t2(b) -- outputs -- 2018-02-03T00:00:00Z -- 2008-03-31T12:23:34Z {code} was (Author: danny0405): This example query expects to trigger implicit type coercion, for CALCITE type coercion rules, DATE union TIMESTAMP outputs TIMESTAMP. But it didn't, and outputs DATE, i think we should fix this. I checked this SQL in PostgreSQL: ```sql select * from (VALUES(DATE '2018-02-03')) t1(a) union all select * from (VALUES(TIMESTAMP '2008-03-31 12:23:34')) t2(b) -- outputs -- 2018-02-03T00:00:00Z -- 2008-03-31T12:23:34Z ``` > 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)