Skip to content

Align property helpers in pyiceberg/utils/properties.py with Java's PropertyUtil #4529

Backlog

Description

@Fokko

Follow-up from #4489, revisiting the discussion in #3801.

Java's PropertyUtil treats a property as unset only when its value is null, and parses every other value. The PyIceberg helpers still treat "" as unset, accept non-string values that Java never sees, and parse booleans differently.

Input Java PyIceberg after #4489
property_as_int / property_as_float with "" throws NumberFormatException returns default
property_as_int with False or 1.5 n/a, values are strings 0 / 1
property_as_bool with "" false returns default
property_as_bool with "1", "yes" or "on" false True
property_as_bool with "abc" false raises ValueError
get_first_property_value with "" for the first key no equivalent skips to the next key
  • Treat only None as unset. Use if (value := properties.get(property_name)) is not None: in all four helpers. An empty string then raises ValueError in property_as_int and property_as_float, where Java throws NumberFormatException. Update the for unset in (None, "") tests from Preserve falsy non-empty values in property helper functions #4489.
  • Parse the string form of the value. Use int(str(value)) and float(str(value)). Values like False or 1.5 for an int property then raise instead of becoming 0 or 1, which matches Java parsing the string.
  • Match Boolean.parseBoolean in property_as_bool. Return str(value).lower() == "true" instead of calling strtobool. Any other value, including "", "1", "yes" and typos, returns False without raising. This silently changes "1", "yes", "on", "y" and "t" from True to False, so for one release, emit a DeprecationWarning when strtobool and the new parsing disagree. Update test_property_as_bool_with_invalid_value.
  • Use property_as_bool wherever a boolean property is read. catalog/sql.py (pool_pre_ping, init_catalog_tables, and echo apart from its "debug" value), io/fsspec.py and io/pyarrow.py (s3.anonymous) call strtobool directly, so they would keep the old parsing.
  • Only skip None in get_first_property_value. Java has no equivalent. Java reads one key and checks for empty values where it uses them, for example Strings.isNullOrEmpty in AwsClientProperties#credentialsProvider. Return "" instead of skipping to the next key, and check the callers in io/pyarrow.py, io/fsspec.py, catalog/glue.py, catalog/dynamodb.py and catalog/rest/__init__.py, so an empty credential still falls back to the default credential chain.
  • Use Properties as the parameter type for all helpers. Preserve falsy non-empty values in property helper functions #4489 changed property_as_int and property_as_float to take Mapping[str, Any].
  • Fix the *_with_invalid_value tests. The assert ... in str(exc.value) is inside the with pytest.raises(...) block, so it never runs. Use pytest.raises(ValueError, match=...).
  • Mention the user-facing changes in the release notes. An empty string no longer means "unset", and boolean properties follow Java's parsing.

Activity

  1. changed the title [-]Follow-ups for property helpers in pyiceberg/utils/properties.py[/-] [+]Align property helpers in pyiceberg/utils/properties.py with Java's PropertyUtil[/+] on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions