You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "somil deshmukh (JIRA)" <ji...@apache.org> on 2015/09/07 14:25:46 UTC

[jira] [Commented] (SPARK-10460) fieldIndex method missing on spark.sql.Row

    [ https://issues.apache.org/jira/browse/SPARK-10460?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14733620#comment-14733620 ] 

somil deshmukh commented on SPARK-10460:
----------------------------------------

I think u need to import
"import org.apache.spark.sql.{Row, SQLContext}" in your code

> fieldIndex method missing on spark.sql.Row
> ------------------------------------------
>
>                 Key: SPARK-10460
>                 URL: https://issues.apache.org/jira/browse/SPARK-10460
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 1.4.1
>         Environment: I'm running on an Ubuntu 14.04 32-bit machine, Java 7, spark 1.4.1. Jar was created using sbt-assembly. I've tested both using spark submit and in spark-shell. Both time I had errors in the exact same spot.
>            Reporter: FELIPE Q B ALMEIDA
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> {code:title=foo.scala|borderStyle=solid}
> val sc       = new SparkContext(cnf)
> 		
> val sqlContext = new SQLContext(sc)
> import sqlContext.implicits._
> // initializing the dataframe from json file
> val reviewsDF = sqlContext.jsonFile(inputDir)
> val schema = reviewsDF.schema
> val cleanRDD = reviewsDF.rdd.filter{row:Row => 
>     // ***************************************************************************
>     //error: value fieldIndex is not a member of org.apache.spark.sql.row
>     val unixTimestampIndex = row.fieldIndex("unixReviewTime")
>     // ***************************************************************************
>     val tryLong = Try(row.getLong(unixTimestampIndex))
>      (row.anyNull == false && tryLong.isSuccess)
> }
> {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