mattmartin14 commented on PR #1665: URL: https://github.com/apache/iceberg-python/pull/1665#issuecomment-2661420332
> actually this doesnt respect [`identifier_field_ids`](https://iceberg.apache.org/spec/#identifier-field-ids) columns' uniqueness > > > > For example, > > ```python > > def test_upsert_with_identifier_fields(catalog: Catalog) -> None: > > identifier = "default.test_upsert_with_identifier_fields" > > _drop_table(catalog, identifier) > > > > schema = Schema( > > NestedField(1, "city", StringType(), required=True), > > NestedField(2, "inhabitants", IntegerType(), required=True), > > # Mark City as the identifier field, also known as the primary-key > > identifier_field_ids=[1], > > ) > > > > tbl = catalog.create_table(identifier, schema=schema) > > > > arrow_schema = pa.schema( > > [ > > pa.field("city", pa.string(), nullable=False), > > pa.field("inhabitants", pa.int32(), nullable=False), > > ] > > ) > > > > # Write some data > > df = pa.Table.from_pylist( > > [ > > {"city": "Amsterdam", "inhabitants": 921402}, > > {"city": "San Francisco", "inhabitants": 808988}, > > {"city": "Drachten", "inhabitants": 45019}, > > {"city": "Paris", "inhabitants": 2103000}, > > ], > > schema=arrow_schema, > > ) > > tbl.append(df) > > > > df = pa.Table.from_pylist( > > [ > > {"city": "Paris", "inhabitants": 921402}, > > ], > > schema=arrow_schema, > > ) > > upd = tbl.upsert(df, join_cols=["inhabitants"], when_not_matched_insert_all=True) > > > > print(tbl.scan().to_pandas()) > > ``` @kevinjqliu , Not to sound blunt but the example above seems odd TBH. If I understand correctly, inhabitants is analogous to population count for a city. Thus, the join column should be city, not inhabitants. City identifies the unique record. Inhabitants is just an attribute of that record. -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org