Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-17716

Not pushing postaggregations into Druid due to CAST on constant

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • Druid integration
    • None

    Description

      After Calcite is upgraded to 1.14 and the rule to push post-aggregations to Druid is enabled, the following query fails to create a postaggregation:

      EXPLAIN
      SELECT language, sum(added) + 100 AS a
      FROM druid_table_1
      GROUP BY language
      ORDER BY a DESC;
      

      Problem seems to be that CAST is getting on the way for the rule to be applied. In particular, this is the final Calcite plan:

       HiveSortLimit(sort0=[$1], dir0=[DESC-nulls-last])
        HiveProject(language=[$0], a=[+($1, CAST(100):DOUBLE)])
          DruidQuery(table=[[default.druid_table_1]], intervals=[[1900-01-01T00:00:00.000/3000-01-01T00:00:00.000]], groups=[{6}], aggs=[[sum($10)]])
      

      There are two different parts to explore to seek a solution: 1) why CAST(100):DOUBLE) is not folded to 100.0d, and 2) whether the rule to push post-aggregations to Druid could handle the CAST in some particular cases.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jcamacho Jesús Camacho Rodríguez
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: