[Solved] How can I access a method which return Option object?

The most iconic way ot do it is to unwrap values with scala is to use pattern matching to unwrap the value. entities match { case Some(queryEntities: QueryEntities) => queryEntities.entities.foreach { case e => println(e.columnFamily) println(e.fromDate.getOrElse(“defaultFromDateHere”) println(e.toDate.getOrElse(“defaultToDateHere”)) } case None => println(“No value”) } 9 solved How can I access a method which return Option … Read more

[Solved] Get the highest price with smaller ID when two ID have the same highest price in Scala

Try this. scala> val df = Seq((4, 30),(2,50),(3,10),(5,30),(1,50),(6,25)).toDF(“id”,”price”) df: org.apache.spark.sql.DataFrame = [id: int, price: int] scala> df.show +—+—–+ | id|price| +—+—–+ | 4| 30| | 2| 50| | 3| 10| | 5| 30| | 1| 50| | 6| 25| +—+—–+ scala> df.sort(desc(“price”), asc(“id”)).show +—+—–+ | id|price| +—+—–+ | 1| 50| | 2| 50| | 4| … Read more