CreateOrReplaceTempView will create a temporary representation of the table in memory, at the moment it is not a candidate, but you can run the sql query on top of this. if you want to save it, you can either save or save saveAsTable to save.
first we read the data in csv format, and then convert it to a data frame and create a temporary representation
Reading data in csv format
val data = spark.read.format("csv").option("header","true").option("inferSchema","true").load("FileStore/tables/pzufk5ib1500654887654/campaign.csv")
print circuit
data.printSchema

data.createOrReplaceTempView("Data")
Now we can run sql queries at the top of the table we just created
%sql select Week as Date,Campaign Type,Engagements,Country from Data order by Date asc

Rajdk source share