You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Jacek Laskowski (JIRA)" <ji...@apache.org> on 2016/04/01 13:43:25 UTC

[jira] [Created] (SPARK-14329) "fieldIndex on a Row without schema is undefined." when accessing fields of Row by name

Jacek Laskowski created SPARK-14329:
---------------------------------------

             Summary: "fieldIndex on a Row without schema is undefined." when accessing fields of Row by name
                 Key: SPARK-14329
                 URL: https://issues.apache.org/jira/browse/SPARK-14329
             Project: Spark
          Issue Type: Improvement
          Components: SQL
    Affects Versions: 2.0.0
         Environment: today's local build
            Reporter: Jacek Laskowski
            Priority: Minor


It appears as if the exception message were not related to the issue that..._a field "hello" could not be found_.

Moreover the scaladoc of {{Row.getAs(String)}} says:

{quote}
   * For primitive types if value is null it returns 'zero value' specific for primitive
   * ie. 0 for Int - use isNullAt to ensure that value is not null
{quote}

which is not the case either.

{code}
scala> import org.apache.spark.sql.Row
import org.apache.spark.sql.Row

scala> val row = Row(1, "hello")
row: org.apache.spark.sql.Row = [1,hello]

scala> row.getAs[String]("hello")
java.lang.UnsupportedOperationException: fieldIndex on a Row without schema is undefined.
  at org.apache.spark.sql.Row$class.fieldIndex(Row.scala:344)
  at org.apache.spark.sql.catalyst.expressions.GenericRow.fieldIndex(rows.scala:192)
  at org.apache.spark.sql.Row$class.getAs(Row.scala:335)
  at org.apache.spark.sql.catalyst.expressions.GenericRow.getAs(rows.scala:192)
  ... 49 elided

scala> row.getAs[String](null)
java.lang.UnsupportedOperationException: fieldIndex on a Row without schema is undefined.
  at org.apache.spark.sql.Row$class.fieldIndex(Row.scala:344)
  at org.apache.spark.sql.catalyst.expressions.GenericRow.fieldIndex(rows.scala:192)
  at org.apache.spark.sql.Row$class.getAs(Row.scala:335)
  at org.apache.spark.sql.catalyst.expressions.GenericRow.getAs(rows.scala:192)
  ... 49 elided
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org