syun64 commented on code in PR #41: URL: https://github.com/apache/iceberg-python/pull/41#discussion_r1445440825
########## pyiceberg/table/snapshots.py: ########## @@ -277,23 +278,30 @@ def _truncate_table_summary(summary: Summary, previous_summary: Mapping[str, str }: summary[prop] = '0' - if value := previous_summary.get(TOTAL_DATA_FILES): - summary[DELETED_DATA_FILES] = value - if value := previous_summary.get(TOTAL_DELETE_FILES): - summary[REMOVED_DELETE_FILES] = value - if value := previous_summary.get(TOTAL_RECORDS): - summary[DELETED_RECORDS] = value - if value := previous_summary.get(TOTAL_FILE_SIZE): - summary[REMOVED_FILE_SIZE] = value - if value := previous_summary.get(TOTAL_POSITION_DELETES): - summary[REMOVED_POSITION_DELETES] = value - if value := previous_summary.get(TOTAL_EQUALITY_DELETES): - summary[REMOVED_EQUALITY_DELETES] = value + def get_prop(prop: str) -> int: + value = previous_summary.get(prop, '0') Review Comment: @Fokko I'm seeing that this logic doesn't work as is, because the keys actually exist in **summary** dictionary as null values, and therefore doesn't fallback to '0' value. ``` from pyiceberg.table.snapshots import Summary, TOTAL_DATA_FILES assert Summary("overwrite").get(TOTAL_DATA_FILES, '0') is None ``` ```suggestion value = previous_summary.get(prop) or '0' ``` -- 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