awswrangler.s3.merge_upsert_table(delta_df: DataFrame, database: str, table: str, primary_key: List[str], boto3_session: Optional[Session] = None) None

Perform Upsert (Update else Insert) onto an existing Glue table.

  • delta_df (pandas.DataFrame) – The delta dataframe has all the data which needs to be merged on the primary key

  • database (Str) – An existing database name

  • table (Str) – An existing table name

  • primary_key (List[str]) – Pass the primary key as a List of string columns List[‘column_a’, ‘column_b’]

  • boto3_session (boto3.Session(), optional) – Boto3 Session. The default boto3 session will be used if boto3_session receive None.

Return type



Reading all Parquet files under a prefix >>> import awswrangler as wr >>> import pandas as pd >>> delta_df = pd.DataFrame({“id”: [1], “cchar”: [“foo”], “date”: [, 1, 2)]}) >>> primary_key = [“id”, “cchar”] >>> wr.s3.merge_upsert_table(delta_df=delta_df, database=’database’, table=’table’, primary_key=primary_key)