Fix vacuum_lakehouse_tables retention period formatting for single-digit hours - #1309
Merged
Michael Kovalsky (m-kovalsky) merged 2 commits intoAug 4, 2026
Merged
Conversation
Copilot
AI
changed the title
[WIP] Fix retention_period format for hours less than 10
Fix Aug 3, 2026
vacuum_lakehouse_tables retention period formatting for single-digit hours
Michael Kovalsky (m-kovalsky)
marked this pull request as ready for review
August 4, 2026 05:48
Copilot started reviewing on behalf of
Michael Kovalsky (m-kovalsky)
August 4, 2026 05:48
View session
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes vacuum_lakehouse_tables() so that the generated retention_period string always conforms to the required d:hh:mm:ss format by zero-padding the hours component when retain_n_hours % 24 is a single digit.
Changes:
- Zero-pad the hours segment in the
retention_periodstring passed torun_table_maintenance. - Add a regression unit test asserting
retain_n_hours=49produces2:01:00:00.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/test_lakehouse.py | Adds a regression test to ensure single-digit hour values are zero-padded in retention_period. |
| src/sempy_labs/lakehouse/_lakehouse.py | Updates vacuum_lakehouse_tables() to format retention_period hours with :02d. |
Suppressed comments (1)
src/sempy_labs/lakehouse/_lakehouse.py:244
vacuum_lakehouse_tables()unconditionally computes and passesretention_periodusingretain_n_hours, butretain_n_hoursis optional (defaultNone) and the docstring says that when it’s not specified the table’s default retention should be used. As written, callingvacuum_lakehouse_tables()with the defaultretain_n_hours=Nonewill raise aTypeError(NoneTypein///%) and will never allow the “use default retention” behavior.
run_table_maintenance(
table_name=table_name,
vacuum=True,
retention_period=f"{retain_n_hours // 24}:{retain_n_hours % 24:02d}:00:00",
schema=schema_name,
lakehouse=lakehouse,
workspace=workspace,
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Tian Wei (whiskyboy)
approved these changes
Aug 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
vacuum_lakehouse_tables()could generate an invalidretention_periodwhenretain_n_hours % 24 < 10(for example2:1:00:00), which fails downstream validation requiringd:hh:mm:ss. This change ensures the hours segment is always zero-padded to two digits.Root cause and behavior
retention_periodwas built with an unpadded hour component in the vacuum helper path.ValueError.Code change
Regression coverage
retain_n_hours=49is translated to2:01:00:00before callingrun_table_maintenance.