You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Tanner Clary (Jira)" <ji...@apache.org> on 2024/01/12 17:17:00 UTC

[jira] [Created] (CALCITE-6197) TIME_SUB is unparsed incorrectly

Tanner Clary created CALCITE-6197:
-------------------------------------

             Summary: TIME_SUB is unparsed incorrectly
                 Key: CALCITE-6197
                 URL: https://issues.apache.org/jira/browse/CALCITE-6197
             Project: Calcite
          Issue Type: Improvement
            Reporter: Tanner Clary


This {{RelToSqlConverterTest}} explains it:

{code:java}
  @Test void testBigQueryTimeSubFunction() {
    String timeSub = "select time_sub(time '15:30:00', interval 2 hour)\n"
        + "from \"foodmart\".\"product\"\n";
    final String expectedTimeSub =
        "SELECT TIME_SUB(TIME '15:30:00', INTERVAL 2 HOUR)\n"
        + "FROM \"foodmart\".\"product\"";
    sql(timeSub).withBigQuery().withLibrary(SqlLibrary.BIG_QUERY).ok(expectedTimeSub);
  }
{code}

This fails with:


{code:java}
Expected: is "SELECT TIME_SUB(TIME '15:30:00', INTERVAL 2 HOUR)\nFROM \"foodmart\".\"product\""
     but: was "SELECT (TIME '15:30:00' - INTERVAL 1 HOUR * 2)\nFROM foodmart.product"
{code}

The other *_SUB() DATETIME functions seem to be working as intended so that should narrow down the problem. I will try to fix this when I have more time if someone doesn't beat me to it.





--
This message was sent by Atlassian Jira
(v8.20.10#820010)