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

Optimizer: Constant folding without CBO skips the aggregates

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • Logical Optimizer
    • 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

            Unassigned Unassigned
            gopalv Gopal Vijayaraghavan
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: