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

codegen for compare structs fails

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.0.0, 2.1.0
    • 2.1.1, 2.2.0
    • SQL
    • None

    Description

      This (1 struct field)

      1 struct field
      spark.range(10)
            .selectExpr("named_struct('a', id) as col1", "named_struct('a', id+2) as col2")
            .filter("col1 = col2").count
      

      fails with

      [info]   Cause: java.util.concurrent.ExecutionException: java.lang.Exception: failed to compile: org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 144, Column 32: Expression "range_value" is not an rvalue
      

      This (2 struct fields)

      2 struct fields
      spark.range(10)
          .selectExpr("named_struct('a', id, 'b', id) as col1", "named_struct('a',id+2, 'b',id+2) as col2")
          .filter($"col1" === $"col2").count
      

      fails with

      Caused by: java.lang.IndexOutOfBoundsException: 1
        at scala.collection.LinearSeqOptimized$class.apply(LinearSeqOptimized.scala:65)
        at scala.collection.immutable.List.apply(List.scala:84)
        at org.apache.spark.sql.catalyst.expressions.BoundReference.doGenCode(BoundAttribute.scala:64)
      

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            bograd Bogdan Raducanu
            bograd Bogdan Raducanu
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment