0

I wrote the following SQL query in Jupyter notebook using Pyspark session -

MySparkSession.sql('''
    select ID
         , count(distinct transaction) as Txn_count
         , sum(revenue) as Total_sales
         , count(distinct product) as Total_products
      from merge_table
     where ( DATE between '2021-02-01' and '2021-03-31') 
       and (BRAND_NAME ='ADIDAS') 
''').show()

I need to pass the DATE and BRAND_NAME columns as parameters and have no idea how to do it so that only by changing the BRAND_NAME and DATE, I can get filtered data.

any help is appreciated.

Lamanus
  • 12,898
  • 4
  • 21
  • 47
  • why not using the f-string? – Lamanus Nov 20 '21 at 14:41
  • 1
    Does this answer your question? [How do I create a multiline Python string with inline variables?](https://stackoverflow.com/questions/10112614/how-do-i-create-a-multiline-python-string-with-inline-variables) – Lamanus Nov 20 '21 at 14:43

0 Answers0