fix: treat empty property strings as present in helpers - #3801
daviddallakyan2005 wants to merge 4 commits into
Conversation
Walrus `.get` truthiness treated "" as missing. Match the is-not-None check from apache#3660/apache#3745 so a present empty value is parsed (or returned) instead of falling back.
|
Thanks for raising this PR @daviddallakyan2005. I think this one is debatable. What's the added value of having an empty string? I think unsetting the property is the right thing to do. |
|
That makes sense, thanks. Looking at it again, I agree that an empty string is not useful for typed properties. Unlike I also noticed that I can close this PR, or change the checks to be more explicit without changing the current behavior. Which would you prefer? |
Keep the behavior introduced on main while resolving the property helper conflict.
|
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that's incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions. |
Closes #3713
Rationale for this change
property_as_int,property_as_float, andget_first_property_valueused a truthy walrus check (if value := properties.get(...)). An empty string is falsy in Python, so a present""was treated as a missing key: the typed helpers returned the default instead of parsing, andget_first_property_valueskipped to the next name.This is the same class of bug as #3660 (falsy
0collapsed to unset) and #3745 (CLI property lookup reported""as missing). These helpers now useis not None, matching those PRs and the typed getters already inConfig.get_int/get_bool. A missing key still returns the default. A present empty string is a value: int and float properties raiseValueError(same as any other unparseable string), andget_first_property_valuereturns"".property_as_boolkeeps the empty-string fallback behavior added onmainin #3492.Other walrus
.getsites (IO, catalog, table locations/metadata) are left for follow-ups.Are these changes tested?
Yes. Regression tests cover empty strings for int and float properties and for
get_first_property_value, while preserving the boolean fallback from #3492.make lintmake test→ 3933 passed, 3 skipped, 1569 deselecteduv run pytest tests/utils/test_properties.py -v→ 14 passed after resolving the conflictAre there any user-facing changes?
Yes. An explicitly empty int or float property now raises
ValueErrorinstead of silently using the default, andget_first_property_valueno longer skips an empty string. Changelog label requested.