Skip to content
Advertisement

PySpark: Adding elements from python list into spark.sql() statement

have list in python that is used throughout my code:

I also have have a simple spark.sql() line that I need to execute:

I want to replace the list of elements in the spark.sql() statment with the python list so that that last line in the SQL is

I am aware of using {} and str.format but I am struggling to understand if that’s the correct option here, and how that workd.

Advertisement

Answer

Okay, after some more research, I think I found the solution using .format(tuple(pylist))

The statement now is:

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement