SubQueries in R

Dear friends,
i'm trying to connect R to Presto. finally connected but now i need to select column from a dataframe to get its details from the database as a lookup column , how can i insert it in the Query although the Query is in double qoutes as this Query

 query1<-paste0("
               SELECT *
               FROM dev_bi.checkmarket_survey_agg
               where ID in *******
               ")

the place of ******* is the column that selected from the dataframe
appreciate your usual support my friends :slight_smile:
thanks

2 Likes

Easiest thing to do is to use single quotes ' on the outside, so double quotes are available for easy use inside. There are all kinds of crazy string manipulation you can do to force the issue, too.

query1<-paste0('
               SELECT *
               FROM dev_bi.checkmarket_survey_agg
               where ID in (select ID from "myothertable")
               ')

Honestly, you might look at the glue package, which is designed for this type of thing. I don't think dbplyr has a Presto translation, but if you can figure out some good docs on the SQL language engine, what other engines is close to, etc., opening an issue and contributing to the translations in dbplyr would also be welcome!

(Disclaimer: I know nothing about Presto SQL syntax)

2 Likes