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

Constant Folding: null > (expr) is not constant folded to NULL

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.1.0, 4.0.0
    • None
    • CBO
    • None

    Description

      
      create temporary table foo(col1 int, col2 int, col3 int, col5 int, col9 int) stored as orc;
      
      explain select count(1) from foo where 
      CASE WHEN (col5 is not null) THEN (((col1 / col5) > (col9 / col3))) ELSE ((null > (col9 / col3))) END;
      
      explain select count(1), max((col9/col3) > null) from foo where 
      CASE WHEN (col5 is not null) THEN (((col1 / col5) > (col9 / col3))) ELSE (((col9 / col3) > null)) END;
      

      There's no sane way to write this query, but this is actually generated by CBO for an expression which looks like

      case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end
                 > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end
      

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated: