pkhetrapal commented on issue #7005:
URL: https://github.com/apache/iceberg/issues/7005#issuecomment-1454981586
```
merge_insert_sql = f"""
MERGE INTO table1 t
USING (SELECT * FROM global_temp.table2) s
ON t._ID = s._ID
WHEN NOT MATCHED THEN INSERT *
"""
spark.sql(merge_insert_sql)
```
This inserts the records twice - not sure why though
```
merge_sql = f"""
MERGE INTO table1 t
USING (SELECT * FROM global_temp.table2) s
ON t._ID = s._ID
WHEN MATCHED AND s.UPDATED_AT > t.UPDATED_AT THEN UPDATE SET *
WHEN MATCHED AND s.UPDATED_AT <= t.UPDATED_AT THEN UPDATE SET t._ID =
s._ID
WHEN NOT MATCHED THEN INSERT *
spark.sql(merge_sql)
```
This inserts the records twice as well but the below one works fine
```
merge_sql = f"""
MERGE INTO table1 t
USING (SELECT * FROM global_temp.table2) s
ON t._ID = s._ID
WHEN MATCHED AND s.UPDATED_AT > t.UPDATED_AT THEN UPDATE SET *
WHEN MATCHED THEN UPDATE SET t._ID = s._ID
WHEN NOT MATCHED THEN INSERT *
spark.sql(merge_sql)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]