Hope the title clarifies what I actually want. I will try to describe the problem.
I am looking for something like this :
variable = "1"
%sql
DROP TABLE IF EXISTS database.table_{variable}
If you use Spark SQL within Python notebook you can easily achieve this with strings as below -
%python
spark.sql("DROP TABLE IF EXISTS database.table_{variable}".format(variable=variable))
Alternatively, you can follow the link below achieving the same using SQL as well -
Assign a variable a dynamic value in SQL in Databricks / Spark
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With