Skip to content

Commit

Permalink
Fix flaky test for WhenNotMatchedClause.insert
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-sfan committed Apr 18, 2023
1 parent 0d2c041 commit 3793e09
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/snowflake/snowpark/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,16 @@ def insert(
>>> source = session.create_dataframe([(12, "new")], schema=["key", "value"])
>>> target.merge(source, target["key"] == source["key"], [when_not_matched().insert([source["key"], source["value"]])])
MergeResult(rows_inserted=1, rows_updated=0, rows_deleted=0)
>>> target.collect() # the rows are inserted
[Row(KEY=12, VALUE='new'), Row(KEY=10, VALUE='old'), Row(KEY=10, VALUE='too_old'), Row(KEY=11, VALUE='old')]
>>> target.sort("key", "value").collect() # the rows are inserted
[Row(KEY=10, VALUE='old'), Row(KEY=10, VALUE='too_old'), Row(KEY=11, VALUE='old'), Row(KEY=12, VALUE='new')]
>>> # For all such rows, insert a row into target whose key is
>>> # assigned to the key of the not matched row.
>>> target_df.write.save_as_table("my_table", mode="overwrite", table_type="temporary")
>>> target.merge(source, target["key"] == source["key"], [when_not_matched().insert({"key": source["key"]})])
MergeResult(rows_inserted=1, rows_updated=0, rows_deleted=0)
>>> target.collect() # the rows are inserted
[Row(KEY=12, VALUE=None), Row(KEY=10, VALUE='old'), Row(KEY=10, VALUE='too_old'), Row(KEY=11, VALUE='old')]
>>> target.sort("key", "value").collect() # the rows are inserted
[Row(KEY=10, VALUE='old'), Row(KEY=10, VALUE='too_old'), Row(KEY=11, VALUE='old'), Row(KEY=12, VALUE=None)]
Note:
An exception will be raised if this method is called more than once
Expand Down

0 comments on commit 3793e09

Please sign in to comment.