Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2022 09:57 AM
Hi @Christine Pedersen
I guess IF NOT EXISTS or IF EXISTS can be used in conjunction with DROP or PARTITIONS according to the documentation.
If you want to do this the same checking way, you can do using a try catch block in pyspark or as per your language requirement.
import pyspark.sql.utils
try:
spark.sql("""ALTER TABLE table-name ADD COLUMNS col-name data-type""")
except pyspark.sql.utils.AnalysisException:
print("Column already exists")Hope this helps...
Cheers.
Uma Mahesh D