Basically you are creating a dataframe (a dataframe is a *Dataset* organized into named columns. It is conceptually equivalent to a table in a relational database) out of RDD here.
scala> val rdd = sc.parallelize( List(3, 2, 1, 4, 0)) rdd: org.apache.spark.rdd.RDD[Int] = ParallelCollectionRDD[19] at parallelize at <console>:24 scala> // convert it to a dataframe scala> val df = rdd.toDF df: org.apache.spark.sql.DataFrame = [value: int] scala> df.filter('value > 2).show +-----+ |value| +-----+ | 3| | 4| +-----+ HTH view my Linkedin profile <https://www.linkedin.com/in/mich-talebzadeh-ph-d-5205b2/> *Disclaimer:* Use it at your own risk. Any and all responsibility for any loss, damage or destruction of data or any other property which may arise from relying on this email's technical content is explicitly disclaimed. The author will in no case be liable for any monetary damages arising from such loss, damage or destruction. On Sun, 6 Feb 2022 at 11:51, <capitnfrak...@free.fr> wrote: > for example, this work for RDD object: > > scala> val li = List(3,2,1,4,0) > li: List[Int] = List(3, 2, 1, 4, 0) > > scala> val rdd = sc.parallelize(li) > rdd: org.apache.spark.rdd.RDD[Int] = ParallelCollectionRDD[0] at > parallelize at <console>:24 > > scala> rdd.filter(_ > 2).collect() > res0: Array[Int] = Array(3, 4) > > > After I convert RDD to the dataframe, the filter won't work: > > scala> val df = rdd.toDF > df: org.apache.spark.sql.DataFrame = [value: int] > > scala> df.filter(_ > 2).show() > <console>:24: error: value > is not a member of org.apache.spark.sql.Row > df.filter(_ > 2).show() > > > But this can work: > > scala> df.filter($"value" > 2).show() > +-----+ > |value| > +-----+ > | 3| > | 4| > +-----+ > > > Where to check all the methods supported by dataframe? > > > Thank you. > Frakass > > > --------------------------------------------------------------------- > To unsubscribe e-mail: user-unsubscr...@spark.apache.org > >