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

Exception when trying to access Row field using getAs method

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.1.2
    • None
    • SQL
    • Spark 3.1.2 (but this also may affect other versions as well)

    Description

      I have an input dataframe df with the following schema:

      |-- origin: string (nullable = true)
      |-- product: struct (nullable = true)
      |    |-- id: integer (nullable = true)

       

      when I try to select the first 20 rows of the id column I execute:

      df.select("product.id").show(20, false)
      

       

      and I manage to get the result. But when I execute the following: 

      df.map(_.getAs[Int]("product.id")).show(20, false)

       

      I get the following error:

      java.lang.IllegalArgumentException: Field "product.id" does not exist.

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            amavrommatis Alexandros Mavrommatis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: