Reputation: 77
I'm translating a spark query from Python to R in databricks.What is the equivalent of below code in R.
categories= spark.sql("select name,place from table where XYZ ")
I tried to replicate the above code as following categories <- sql(select name,place from table where XYZ)
but getting syntax error.
Upvotes: 0
Views: 700
Reputation: 77
Have to load data in a dataframe and create temp view and then access through the query.
df1 <- read.df("pass the path here",source="delta")
createOrReplaceTempView(df1, "temp")
result <- sql("SELECT name , place FROM temp")
Upvotes: 0
Reputation: 1563
It looks like you're just missing quotes around the query
categories <- sql("select name,place from table where XYZ")
Upvotes: 1