You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (JIRA)" <ji...@apache.org> on 2018/01/28 00:57:00 UTC

[jira] [Updated] (CALCITE-2091) DruidAdapterIT testFilterTimestamp does not test translating of extract fn to interval

     [ https://issues.apache.org/jira/browse/CALCITE-2091?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julian Hyde updated CALCITE-2091:
---------------------------------
    Description: 
DruidAdapterIT testFilterTimestamp does not test translating of extract fn to interval.

This test was added to verify that the extract function is transformed to a date range on timestamp column. But in this it does not seem to be pushing extract to interval. This task is to check the root cause and fix this. I guess this is possibly an issue with cost computation not accounting for interval being queried. 

{code} 
/** Tests that conditions applied to time units extracted via the EXTRACT
   * function become ranges on the timestamp column
   *
   * <p>Test case for
   * <a href="https://issues.apache.org/jira/browse/CALCITE-1334">[CALCITE-1334]
   * Convert predicates on EXTRACT function calls into date ranges</a>. */
  @Test public void testFilterTimestamp() {
    String sql = "select count(*) as c\n"
        + "from \"foodmart\"\n"
        + "where extract(year from \"timestamp\") = 1997\n"
        + "and extract(month from \"timestamp\") in (4, 6)\n";
    final String explain = "DruidQuery(table=[[foodmart, foodmart]], "
        + "intervals=[[1900-01-09T00:00:00.000Z/2992-01-10T00:00:00.000Z]], "
        + "filter=[AND(=(EXTRACT(FLAG(YEAR), $0), 1997), OR(=(EXTRACT(FLAG(MONTH), $0), 4), "
        + "=(EXTRACT(FLAG(MONTH), $0), 6)))], groups=[{}], aggs=[[COUNT()]])";
    sql(sql)
        .explainContains(explain)
        .returnsUnordered("C=13500");
  }
{code} 

  was:
this test was added to verify that the extract function is transformed to a date range on timestamp column. But in this it does not seem to be pushing extract to interval. This task is to check the root cause and fix this. I guess this is possibly an issue with cost computation not accounting for interval being queried. 

{code} 
/** Tests that conditions applied to time units extracted via the EXTRACT
   * function become ranges on the timestamp column
   *
   * <p>Test case for
   * <a href="https://issues.apache.org/jira/browse/CALCITE-1334">[CALCITE-1334]
   * Convert predicates on EXTRACT function calls into date ranges</a>. */
  @Test public void testFilterTimestamp() {
    String sql = "select count(*) as c\n"
        + "from \"foodmart\"\n"
        + "where extract(year from \"timestamp\") = 1997\n"
        + "and extract(month from \"timestamp\") in (4, 6)\n";
    final String explain = "DruidQuery(table=[[foodmart, foodmart]], "
        + "intervals=[[1900-01-09T00:00:00.000Z/2992-01-10T00:00:00.000Z]], "
        + "filter=[AND(=(EXTRACT(FLAG(YEAR), $0), 1997), OR(=(EXTRACT(FLAG(MONTH), $0), 4), "
        + "=(EXTRACT(FLAG(MONTH), $0), 6)))], groups=[{}], aggs=[[COUNT()]])";
    sql(sql)
        .explainContains(explain)
        .returnsUnordered("C=13500");
  }
{code} 


> DruidAdapterIT testFilterTimestamp does not test translating of extract fn to interval
> --------------------------------------------------------------------------------------
>
>                 Key: CALCITE-2091
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2091
>             Project: Calcite
>          Issue Type: Improvement
>            Reporter: Nishant Bangarwa
>            Assignee: Nishant Bangarwa
>            Priority: Major
>
> DruidAdapterIT testFilterTimestamp does not test translating of extract fn to interval.
> This test was added to verify that the extract function is transformed to a date range on timestamp column. But in this it does not seem to be pushing extract to interval. This task is to check the root cause and fix this. I guess this is possibly an issue with cost computation not accounting for interval being queried. 
> {code} 
> /** Tests that conditions applied to time units extracted via the EXTRACT
>    * function become ranges on the timestamp column
>    *
>    * <p>Test case for
>    * <a href="https://issues.apache.org/jira/browse/CALCITE-1334">[CALCITE-1334]
>    * Convert predicates on EXTRACT function calls into date ranges</a>. */
>   @Test public void testFilterTimestamp() {
>     String sql = "select count(*) as c\n"
>         + "from \"foodmart\"\n"
>         + "where extract(year from \"timestamp\") = 1997\n"
>         + "and extract(month from \"timestamp\") in (4, 6)\n";
>     final String explain = "DruidQuery(table=[[foodmart, foodmart]], "
>         + "intervals=[[1900-01-09T00:00:00.000Z/2992-01-10T00:00:00.000Z]], "
>         + "filter=[AND(=(EXTRACT(FLAG(YEAR), $0), 1997), OR(=(EXTRACT(FLAG(MONTH), $0), 4), "
>         + "=(EXTRACT(FLAG(MONTH), $0), 6)))], groups=[{}], aggs=[[COUNT()]])";
>     sql(sql)
>         .explainContains(explain)
>         .returnsUnordered("C=13500");
>   }
> {code} 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)