I'm trying to query snowflake using input variable from my function (run via aws glue).. Below are 3 things I've tried but I keep getting the following error:
An error occurred while calling o14310.load. SQL compilation error: error line 1 at position 94
Any ideas what the issue may be? Regular queries not using an input variable runs fine..
def s_counts(df, s_id):
what_to_query = "select R_ID FROM mytable WHERE S_ID ="+s_id
CurrentCount = spark.read.format(SNOWFLAKE_SOURCE_NAME)
.options(**sfOptions)
.option("query", what_to_query)
.load()
CurrentCount = spark.read.format(SNOWFLAKE_SOURCE_NAME)
.options(**sfOptions)
.option("query", "select R_ID FROM mytable WHERE S_ID = s_id")
.load()
CurrentCount = spark.read.format(SNOWFLAKE_SOURCE_NAME)
.options(**sfOptions)
.option("query", "select R_ID FROM mytable WHERE S_ID = "+s_id)
.load()
s_idis not passed properly, and you ended up with an incomplete queryselect R_ID FROM mytable WHERE S_ID =S_IDin your where clause beR_IDi.e.select R_ID FROM mytable WHERE R_ID =instead ofselect R_ID FROM mytable WHERE S_ID=?