Reputation: 29
I needed help in using Spark function ASCII(sparkSQl string function) by using scala
import org.apache.spark.sql.SparkSession
import spark.implicits._
import org.apache.spark.sql.functions
val a = sc.parallelize(Array("Santosh","Adithya"))
select ascii('Santosh')
I needed ascii value of santosh and ascii value of rdd a
Upvotes: 0
Views: 2239
Reputation: 4499
ascii is part of spark-sql api and can only be used on DataFrames/Datasets.
Convert your RDD to Dataset using then use the ascii function
import spark.implicits._
val a = sc.parallelize(Array("Santosh","Adithya"))
case class Person(val fullName: String)
val ds = a.map(Person).toDS.selectExpr("ascii(fullName)")
ds.show
Upvotes: 3