I have a list and want to use in pyspark.sql statement.
VLIST=['afhjh', 'aikn5','hsa76']
INC=pyspark.sql("select * from table1 where VIG=$VLIST")
I tried to use like a sas statement(using $ instead of &) which failed. How can I use it correctly.
You can try something a bit different :
VLIST = ('afhjh', 'aikn5','hsa76')
INC = pyspark.sql(f"select * from table1 where VIG in {VLIST}")
or another way :
from pyspark.sql import functions as F
INC = pyspark.table("table1")
INC = INC.where(F.col("VIG").isin(*(F.lit(val) for val in VLIST)))