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

Optimizer: Constant folding without CBO skips the aggregates

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Logical Optimizer
    • Labels:
      None

      Description

      create temporary table foo (x int) ;
      insert into foo values(1),(2),(3),(4),(5);
      set hive.explain.user=false;
      
      explain vectorization detail select count(case when (x=1 or false) then 1 else 0 end ) from foo
      
      |                     Group By Operator              |
      |                       aggregations: count(CASE WHEN (((x = 1) or false)) THEN (1) ELSE (0) END) |
      |                       Group By Vectorization:      |
      |                           aggregators: VectorUDAFCount(IfExprLongScalarLongScalar(col 3:boolean, val 1, val 0)(children: VectorUDFAdaptor(((x = 1) or false))(children: LongColEqualLongScalar(col 0:int, val 1) -> 2:boolean) -> 3:boolean) -> 4:int) -> bigint |
      |                           className: VectorGroupByOperator |
      

      The pass-through Calcite fixes this.

      | OPTIMIZED SQL: SELECT COUNT(CASE WHEN `x` = 1 THEN 1 ELSE 0 END) AS `$f0` |
      | FROM `default`.`foo`     
      
      explain vectorization detail select count(true and false and true);
      
      |                     Group By Operator              |
      |                       aggregations: count((true and false and true)) |
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              gopalv Gopal Vijayaraghavan
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: