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

Not pushing postaggregations into Druid due to CAST on constant

Log workAgile BoardRank to TopRank to BottomAdd voteVotersWatch issueWatchersCreate sub-taskMoveLinkCloneLabelsUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Druid integration
    • Labels:
      None
    • Target Version/s:

      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

          $i18n.getText('security.level.explanation', $currentSelection) Viewable by All Users
          Cancel

            People

            • Assignee:
              Unassigned Assign to me
              Reporter:
              jcamachorodriguez Jesus Camacho Rodriguez

              Dates

              • Created:
                Updated:

                Issue deployment