Skip to content

feat(io): accept the Java gcs.user-project property - #4626

Open
AllyNav wants to merge 1 commit into
apache:mainfrom
AllyNav:feat/gcs-user-project
Open

AllyNav wants to merge 1 commit into
apache:mainfrom
AllyNav:feat/gcs-user-project

Conversation

@AllyNav

@AllyNav AllyNav commented Dec 5, 2026

Copy link
Copy Markdown

Summary

Part of #4140 (Matching Catalog Properties with Java).

Accepts Java Iceberg's gcs.user-project property (GCPProperties.GCS_USER_PROJECT) as a fallback in FsspecFileIO (_gs) when Python's native gcs.requester-pays property is not set:

  • Adds GCS_USER_PROJECT = "gcs.user-project" to pyiceberg/io/__init__.py.
  • In pyiceberg/io/fsspec.py (_gs), passes gcs.user-project to GCSFileSystem(requester_pays=...) (which gcsfs accepts as either bool or a billing project str) when gcs.requester-pays is absent.
  • Preserves native-key precedence: when gcs.requester-pays is explicitly set, it takes precedence over gcs.user-project.
  • Documents gcs.user-project in mkdocs/docs/configuration.md.
  • Adds parametrized unit tests in tests/io/test_fsspec.py covering defaults, fallback, empty values, and native-key precedence.

Copilot AI balanced review requested due to automatic review settings December 5, 2026 15:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@Fokko Fokko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @AllyNav! Nice parity find, verified against GCPProperties.GCS_USER_PROJECT in Java where gcsUserProject is applied unconditionally on reads and writes. Left two small comments, mostly about matching property_as_bool's handling of empty values.

Comment thread pyiceberg/io/fsspec.py
Comment on lines +270 to +271
if GCS_REQUESTER_PAYS in properties:
requester_pays = property_as_bool(properties, GCS_REQUESTER_PAYS, False)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: property_as_bool treats an explicit empty string as unset (value not in (None, "")), so with gcs.requester-pays="" we'd take this branch and ignore gcs.user-project. Could you match that here? Suggests itself as a small change:

Suggested change
if GCS_REQUESTER_PAYS in properties:
requester_pays = property_as_bool(properties, GCS_REQUESTER_PAYS, False)
if (requester_pays_value := properties.get(GCS_REQUESTER_PAYS)) not in (None, ""):
requester_pays = property_as_bool(properties, GCS_REQUESTER_PAYS, False)
elif user_project := properties.get(GCS_USER_PROJECT):
requester_pays = user_project
else:
requester_pays = False

Might also be worth a test case for gcs.requester-pays="" next to gcs.user-project.

| gcs.consistency | md5 | Configure the check method when writing files. Must be one of 'none', 'size', or 'md5' |
| gcs.cache-timeout | 60 | Configure the cache expiration time in seconds for object metadata cache |
| gcs.requester-pays | False | Configure whether to use requester-pays requests |
| gcs.user-project | my-billing-project | Configure the user project billed for requester-pays requests (Java Iceberg fallback when `gcs.requester-pays` is not set). |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: in Java (GCSInputStream/GCSOutputStream) gcs.user-project is applied whenever it's set, not only as a fallback, so the doc row reads slightly stricter than the code below it (an explicit gcs.requester-pays=false also skips it here). Happy either way, just flagging the wording:

Suggested change
| gcs.user-project | my-billing-project | Configure the user project billed for requester-pays requests (Java Iceberg fallback when `gcs.requester-pays` is not set). |
| gcs.user-project | my-billing-project | Configure the user project billed for requester-pays requests, used when `gcs.requester-pays` is not set explicitly. |

This branch has not been deployed

No deployments
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.

3 participants