I get the following error:
18/03/14 15:31:11 ERROR ApplicationMaster: User class threw exception: org.apache.spark.sql.AnalysisException: Table or view not found: products; line 1 pos 42
This is my code:
val spark = SparkSession
.builder()
.appName("Test")
.getOrCreate()
val products = spark.read.parquet(productsPath)
products.createGlobalTempView("products")
val q1 = spark.sql("SELECT PERCENTILE(product_price, 0.25) FROM products").map(_.getAs[Double](0)).collect.apply(0)
What am I doing wrong?
Is it possible to do the same thing in Spark without using sql
?