Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/18236
  
    It looks we already throw the same exception with what this PR proposes as 
below:
    
    ```scala
    import org.apache.spark.sql.catalyst.expressions.GenericRowWithSchema
    import org.apache.spark.sql.types._
    
    val schema = StructType(
      StructField("col1", StringType) ::
      StructField("col2", StringType) ::
      StructField("col3", IntegerType) :: Nil)
    val values = Array("value1", "value2", 1)
    
    val sampleRow = new GenericRowWithSchema(values, schema)
    
    sampleRow.fieldIndex(null)
    ```
    
    ```
    java.lang.IllegalArgumentException: Field "null" does not exist.
      at 
org.apache.spark.sql.types.StructType$$anonfun$fieldIndex$1.apply(StructType.scala:292)
      at 
org.apache.spark.sql.types.StructType$$anonfun$fieldIndex$1.apply(StructType.scala:292)
      at scala.collection.MapLike$class.getOrElse(MapLike.scala:128)
      at scala.collection.AbstractMap.getOrElse(Map.scala:59)
      at org.apache.spark.sql.types.StructType.fieldIndex(StructType.scala:291)
      at 
org.apache.spark.sql.catalyst.expressions.GenericRowWithSchema.fieldIndex(rows.scala:186)
      ... 52 elided
    ```
    
    I think we should close this.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to