how can I manage cases where I have a merge statement , and I want to use the df.write.option(schemaOverwrite,true) flavor
merge statement requires always that the tables is created beforehand, I want to avoid this
n
Nick Karpov
07/31/2023, 4:35 PM
you can't avoid it, only work around it... you'll need logic to check whether the table exists and act accordingly... presumably create if not exists, merge otherwise
b
Barny Self
08/01/2023, 10:43 AM
You can always do something like the following:
CREATE TABLE IF NOT EXISTS {TableName} AS SELECT * FROM {source} LIMIT 0
j
Jordan Fox
08/01/2023, 1:12 PM
Hah yeah that's how I create all my tables nowadays.