Skip to content

Fix TypeError in vacuum_lakehouse_tables() when retain_n_hours is None - #1325

Draft
Michael Kovalsky (m-kovalsky) with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-vacuum-lakehouse-tables-typeerror
Draft

Fix TypeError in vacuum_lakehouse_tables() when retain_n_hours is None#1325
Michael Kovalsky (m-kovalsky) with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-vacuum-lakehouse-tables-typeerror

Conversation

Copilot AI commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Since 0.16.0, vacuum_lakehouse_tables() builds the retention_period string via retain_n_hours // 24, which raises TypeError: unsupported operand type(s) for //: 'NoneType' and 'int' when retain_n_hours is left at its documented default of None. The documented behavior ("the default retention period configured for the Delta table will be used") was only true prior to 0.16.0, when the function passed retain_n_hours straight through to _vacuum_table().

Changes

  • src/sempy_labs/lakehouse/_lakehouse.py — compute retention_period once, before the loop, and only when retain_n_hours is provided:

    if retain_n_hours is None:
        retention_period = None
    else:
        days, hours = divmod(retain_n_hours, 24)
        retention_period = f"{days}:{hours:02d}:00:00"

    run_table_maintenance() already omits retentionPeriod from the API payload when it is None, so no change is needed there — the table's own configured retention applies. Zero-padding behavior from Fix vacuum_lakehouse_tables retention period formatting for single-digit hours #1309 is preserved.

  • tests/test_lakehouse.py — extracted the monkeypatch setup into a _patch_lakehouse helper and added a regression test asserting retention_period is None when the function is called without retain_n_hours.

Co-authored-by: m-kovalsky <29556918+m-kovalsky@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix TypeError in vacuum_lakehouse_tables() with retain_n_hours=None Fix TypeError in vacuum_lakehouse_tables() when retain_n_hours is None Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vacuum_lakehouse_tables() fails with TypeError when using documented default retain_n_hours=None (regression in 0.16.0)

2 participants