awswrangler.s3.merge_upsert_table

awswrangler.s3.merge_upsert_table(delta_df: pandas.core.frame.DataFrame, database: str, table: str, primary_key: List[str], boto3_session: Optional[boto3.session.Session] = None) → None

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

Parameters
  • 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.

Returns

Return type

None

Examples

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