kevinjqliu commented on code in PR #2251: URL: https://github.com/apache/iceberg-python/pull/2251#discussion_r2238652766
########## pyiceberg/io/pyarrow.py: ########## @@ -512,59 +597,111 @@ def _initialize_azure_fs(self) -> FileSystem: from pyarrow.fs import AzureFileSystem - client_kwargs: Dict[str, str] = {} - - if account_name := self.properties.get(ADLS_ACCOUNT_NAME): - client_kwargs["account_name"] = account_name - - if account_key := self.properties.get(ADLS_ACCOUNT_KEY): - client_kwargs["account_key"] = account_key - - if blob_storage_authority := self.properties.get(ADLS_BLOB_STORAGE_AUTHORITY): - client_kwargs["blob_storage_authority"] = blob_storage_authority + # Mapping from PyIceberg properties to AzureFileSystem parameter names + property_mapping = { + ADLS_ACCOUNT_NAME: "account_name", + ADLS_ACCOUNT_KEY: "account_key", + ADLS_BLOB_STORAGE_AUTHORITY: "blob_storage_authority", + ADLS_DFS_STORAGE_AUTHORITY: "dfs_storage_authority", + ADLS_BLOB_STORAGE_SCHEME: "blob_storage_scheme", + ADLS_DFS_STORAGE_SCHEME: "dfs_storage_scheme", + ADLS_SAS_TOKEN: "sas_token", + } - if dfs_storage_authority := self.properties.get(ADLS_DFS_STORAGE_AUTHORITY): - client_kwargs["dfs_storage_authority"] = dfs_storage_authority + client_kwargs: Dict[str, Any] = {} - if blob_storage_scheme := self.properties.get(ADLS_BLOB_STORAGE_SCHEME): - client_kwargs["blob_storage_scheme"] = blob_storage_scheme + for prop_name, prop_value in self.properties.items(): + if prop_value is None: + continue - if dfs_storage_scheme := self.properties.get(ADLS_DFS_STORAGE_SCHEME): - client_kwargs["dfs_storage_scheme"] = dfs_storage_scheme + # Map known property names to AzureFileSystem parameter names + if prop_name in property_mapping: + param_name = property_mapping[prop_name] + client_kwargs[param_name] = prop_value - if sas_token := self.properties.get(ADLS_SAS_TOKEN): - client_kwargs["sas_token"] = sas_token + # Pass through any other adls.* properties that might be used by AzureFileSystem + elif prop_name.startswith("adls."): + param_name = prop_name.split(".", 1)[1] + client_kwargs[param_name] = prop_value return AzureFileSystem(**client_kwargs) def _initialize_hdfs_fs(self, scheme: str, netloc: Optional[str]) -> FileSystem: from pyarrow.fs import HadoopFileSystem - hdfs_kwargs: Dict[str, Any] = {} if netloc: return HadoopFileSystem.from_uri(f"{scheme}://{netloc}") - if host := self.properties.get(HDFS_HOST): - hdfs_kwargs["host"] = host - if port := self.properties.get(HDFS_PORT): - # port should be an integer type - hdfs_kwargs["port"] = int(port) - if user := self.properties.get(HDFS_USER): - hdfs_kwargs["user"] = user - if kerb_ticket := self.properties.get(HDFS_KERB_TICKET): - hdfs_kwargs["kerb_ticket"] = kerb_ticket + + # Mapping from PyIceberg properties to S3FileSystem parameter names + property_mapping = { + HDFS_HOST: "host", + HDFS_PORT: "port", + HDFS_USER: "user", + HDFS_KERB_TICKET: "kerb_ticket", + } + + hdfs_kwargs: Dict[str, Any] = {} + + for prop_name, prop_value in self.properties.items(): + if prop_value is None: + continue + + # Map known property names to HadoopFileSystem parameter names + if prop_name in property_mapping: + param_name = property_mapping[prop_name] + + if param_name == "port": + hdfs_kwargs[param_name] = int(prop_value) + else: + hdfs_kwargs[param_name] = prop_value + + # Pass through any other hdfs.* properties used to be used by HadoopFileSystem + elif prop_name.startswith("hdfs."): + param_name = prop_name.split(".", 1)[1] + hdfs_kwargs[param_name] = prop_value return HadoopFileSystem(**hdfs_kwargs) def _initialize_gcs_fs(self) -> FileSystem: from pyarrow.fs import GcsFileSystem + # Mapping from PyIceberg properties to GcsFileSystem parameter names + property_mapping = { + GCS_TOKEN: "access_token", Review Comment: i think CI is failing because this is missing the `GCS_PROJECT_ID` mapping -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org