我希望将list作为参数传递给sparksql语句。
process_date = '2020-01-01'
df1 = spark.sql("""select '{0}', * from table1""".format(process_date))
This works for a string.
So df1 is created successfully.
But If I have List like this
list1 = ['a','b','c']
df2 = spark.sql("""select '{0}','{1}',* from table1""".format(process_date,list1))
This is not working for me.
1条答案
按热度按时间31moq8wy1#
你可以用
join
和列表理解,得到下面的sql语句