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

Avoid unnecessary cast when doing integral divide

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.0.0
    • 3.0.0
    • SQL
    • None

    Description

      This is a follow up of issue SPARK-15776

      Problem:

      For Integer divide operator div:

      scala> spark.sql("select 6 div 3").explain(true)
      ...
      == Analyzed Logical Plan ==
      CAST((6 / 3) AS BIGINT): bigint
      Project [cast((cast(6 as double) / cast(3 as double)) as bigint) AS CAST((6 / 3) AS BIGINT)#5L]
      +- OneRowRelation$
      ...
      

      For performance reason, we should not do unnecessary cast cast(xx as double)

      Attachments

        Activity

          People

            mgaido Marco Gaido
            clockfly Sean Zhong
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: