Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-2098

Push filters to Druid Query Scan when we have OR of AND clauses

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.16.0
    • druid-adapter
    • None

    Description

      Currently Druid Filter Rule doesn't push filters like

       OR(AND(F1,F2), F3)


      This is due to optimization logic

      org.apache.calcite.adapter.druid.DruidRules.DruidFilterRule.splitFilters

      Here is an test example:

      /**
         * @TODO Fix this case, Druid can handel this kind of expression but the way
         * org.apache.calcite.adapter.druid.DruidRules.DruidFilterRule.splitFilters
         * works doesn't accept this filter
        */
        @Ignore
        @Test public void testFilterClauseWithMetric2() {
          String sql = "select sum(\"store_sales\")"
              + "from \"foodmart\" where \"product_id\" > 1555 or \"store_cost\" > 5 or extract(year "
              + "from \"timestamp\") = 1997 "
              + "group by floor(\"timestamp\" to DAY),\"product_id\"";
          sql(sql)
              .queryContains(druidChecker("\"queryType\":\"groupBy\"", "{\"type\":\"bound\","
                  + "\"dimension\":\"store_cost\",\"lower\":\"5\",\"lowerStrict\":true,"
                  + "\"ordering\":\"numeric\"}"))
              .returnsUnordered("to be computed");
        }
      

      FYI in this example

       extract(year from \"timestamp\") = 1997

      will be transformed to

      (year >= 1996) AND(year <= 1997)

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            bslim Slim Bouguerra
            bslim Slim Bouguerra
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment