Untitled
unknown
plain_text
a year ago
433 B
10
Indexable
merge_columns = ["name", "value"]
# Create the dynamic merge query
merge_query = f"""
MERGE INTO hive_db.target_table AS target
USING temp_view AS source
ON target.id = source.id
WHEN MATCHED THEN
UPDATE SET {', '.join([f'target.{col} = source.{col}' for col in merge_columns])}
WHEN NOT MATCHED THEN
INSERT (id, {', '.join(merge_columns)})
VALUES (source.id, {', '.join([f'source.{col}' for col in merge_columns])})
"""Editor is loading...
Leave a Comment