@@ -333,7 +333,7 @@ def save_as_table(
333333 Set to ``True`` if table exists, ``False`` if it doesn't, or ``None`` (default) for automatic detection.
334334 Primarily useful for "append", "truncate", and "overwrite" with overwrite_condition modes to avoid running query for automatic detection.
335335 overwrite_condition: Specifies the overwrite condition to perform atomic targeted delete-insert.
336- Can be used when ``mode`` is "append" or " overwrite" when the table exists. Rows matching the
336+ Can only be used when ``mode`` is "overwrite" and the table exists. Rows matching the
337337 condition are deleted from the target table, then all rows from the DataFrame are inserted.
338338
339339
@@ -380,7 +380,7 @@ def save_as_table(
380380 [Row(ID=1, VAL='a'), Row(ID=2, VAL='b'), Row(ID=3, VAL='c')]
381381
382382 >>> new_df = session.create_dataframe([[2, "updated2"], [5, "updated5"]], schema=["id", "val"])
383- >>> new_df.write.mode("append ").save_as_table("my_table", overwrite_condition="id = 1 or val = 'b'")
383+ >>> new_df.write.mode("overwrite ").save_as_table("my_table", overwrite_condition="id = 1 or val = 'b'")
384384 >>> session.table("my_table").order_by("id").collect()
385385 [Row(ID=2, VAL='updated2'), Row(ID=3, VAL='c'), Row(ID=5, VAL='updated5')]
386386 """
@@ -513,13 +513,10 @@ def save_as_table(
513513 f"Unsupported table type. Expected table types: { SUPPORTED_TABLE_TYPES } "
514514 )
515515
516- # overwrite_condition must be used with APPEND or OVERWRITE mode
517- if overwrite_condition is not None and save_mode not in (
518- SaveMode .APPEND ,
519- SaveMode .OVERWRITE ,
520- ):
516+ # overwrite_condition must be used with OVERWRITE mode only
517+ if overwrite_condition is not None and save_mode != SaveMode .OVERWRITE :
521518 raise ValueError (
522- f"'overwrite_condition' is only supported with mode='append' or mode=' overwrite'. "
519+ f"'overwrite_condition' is only supported with mode='overwrite'. "
523520 f"Got mode='{ save_mode .value } '."
524521 )
525522
0 commit comments