Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-39039 Conditional expression evaluation ordering
  3. SPARK-39106

Correct conditional expression constant folding

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.4.0
    • 3.3.0
    • SQL
    • None

    Description

      For a conditional expression, we can not partially fold the constant inside it's children. For example if c1 or c2 is not null, the last branch should be never hit.

      SELECT COALESCE(c1, c2, 1/0);
      

      Besides, for CaseWhen and If, we should mark it as foldable if it's children are foldable. It is safe since the both non-codegen and codegen code path have already respected the evaluation order.

      Attachments

        Activity

          People

            ulysses XiDuo You
            ulysses XiDuo You
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: