Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-29164

Rewrite coalesce(boolean, booleanLit) as boolean expression

Log workAgile BoardRank to TopRank to BottomAttach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskConvert to sub-taskLinkCloneLabelsUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 3.0.0
    • Fix Version/s: None
    • Component/s: SQL
    • Labels:
      None

      Description

      I propose the following expression rewrite optimizations:

      coalesce(x: Boolean, true)  -> x or isnull(x)
      coalesce(x: Boolean, false) -> x and isnotnull(x)

      This pattern appears when translating Dataset filters on Option[Boolean] columns: we might have a typed Dataset filter which looks like

       .filter(_.boolCol.getOrElse(DEFAULT_VALUE))

      and the most idiomatic, user-friendly translation of this in Catalyst is to use coalesce(). However, the coalesce() form of this expression is not eligible for Parquet / data source filter pushdown.

      (We should write out truth-tables to double-check this rewrite's correctness)

        Attachments

          Activity

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

            People

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment