Xuanwo commented on code in PR #520: URL: https://github.com/apache/iceberg-rust/pull/520#discussion_r1704167334
########## crates/iceberg/src/io/storage_gcs.rs: ########## @@ -0,0 +1,74 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +//! Google Cloud Storage properties + +use std::collections::HashMap; + +use opendal::services::GcsConfig; +use opendal::Operator; + +use crate::{Error, ErrorKind, Result}; + +// Reference: https://github.com/apache/iceberg/blob/main/gcp/src/main/java/org/apache/iceberg/gcp/GCPProperties.java + +/// Google Cloud Storage bucket name +pub const GCS_BUCKET: &str = "gcs.bucket"; +/// Google Cloud Storage endpoint +pub const GCS_ENDPOINT: &str = "gcs.endpoint"; +/// Google Cloud Storage OAuth token +pub const GCS_OAUTH2_TOKEN: &str = "gcs.oauth2.token"; +/// Google Cloud Storage working (root) directory +pub const GCS_ROOT: &str = "gcs.root"; +/// Google Cloud Storage working (root) directory +pub const GCS_CREDENTIAL_PATH: &str = "gcs.credential-path"; + +/// Parse iceberg properties to [`GcsConfig`]. +pub(crate) fn gcs_config_parse(mut m: HashMap<String, String>) -> Result<GcsConfig> { + let mut cfg = GcsConfig::default(); + + if let Some(bucket) = m.remove(GCS_BUCKET) { + cfg.bucket = bucket; + } else { + return Err(Error::new( + ErrorKind::DataInvalid, + "Bucket name is required for GCS", + )); + } + + if let Some(root) = m.remove(GCS_ROOT) { + cfg.root = Some(root) + } + + if let Some(endpoint) = m.remove(GCS_ENDPOINT) { + cfg.endpoint = Some(endpoint); + } + + if let Some(cred_path) = m.remove(GCS_CREDENTIAL_PATH) { + cfg.credential_path = Some(cred_path); + } + + if let Some(token) = m.remove(GCS_OAUTH2_TOKEN) { + cfg.credential = Some(token); Review Comment: `credential` is the content of gcs `credential` not the oauth2 token. OpenDAL doesn't support setting token directly yet, we can add it in upstream first. At current stage, we can impelment our own TokenLoader by using [`customized_token_loader`](https://docs.rs/opendal/latest/opendal/services/struct.Gcs.html#method.customized_token_loader) ########## crates/iceberg/src/io/storage_gcs.rs: ########## @@ -0,0 +1,74 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +//! Google Cloud Storage properties + +use std::collections::HashMap; + +use opendal::services::GcsConfig; +use opendal::Operator; + +use crate::{Error, ErrorKind, Result}; + +// Reference: https://github.com/apache/iceberg/blob/main/gcp/src/main/java/org/apache/iceberg/gcp/GCPProperties.java + +/// Google Cloud Storage bucket name +pub const GCS_BUCKET: &str = "gcs.bucket"; +/// Google Cloud Storage endpoint +pub const GCS_ENDPOINT: &str = "gcs.endpoint"; Review Comment: Shoud be: ```java GCS_SERVICE_HOST = "gcs.service.host"; ``` ########## crates/iceberg/tests/file_io_gcs_test.rs: ########## @@ -0,0 +1,103 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//! Integration tests for FileIO Google Cloud Storage (GCS). + +use bytes::Bytes; +use iceberg::io::{FileIO, FileIOBuilder, GCS_BUCKET, GCS_CREDENTIAL_PATH}; +use iceberg_test_utils::set_up; + +// static DOCKER_COMPOSE_ENV: RwLock<Option<DockerCompose>> = RwLock::new(None); + +// TODO: use compose with fake-gcs-server Review Comment: opendal gcs doesn't support unauthenticated request yet, I'm happy to add it. ########## crates/iceberg/src/io/storage_gcs.rs: ########## @@ -0,0 +1,74 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +//! Google Cloud Storage properties + +use std::collections::HashMap; + +use opendal::services::GcsConfig; +use opendal::Operator; + +use crate::{Error, ErrorKind, Result}; + +// Reference: https://github.com/apache/iceberg/blob/main/gcp/src/main/java/org/apache/iceberg/gcp/GCPProperties.java + +/// Google Cloud Storage bucket name +pub const GCS_BUCKET: &str = "gcs.bucket"; +/// Google Cloud Storage endpoint +pub const GCS_ENDPOINT: &str = "gcs.endpoint"; +/// Google Cloud Storage OAuth token +pub const GCS_OAUTH2_TOKEN: &str = "gcs.oauth2.token"; +/// Google Cloud Storage working (root) directory +pub const GCS_ROOT: &str = "gcs.root"; Review Comment: Hi, we should not introduce props that doesn't exist in java impl. ########## crates/iceberg/src/io/storage_gcs.rs: ########## @@ -0,0 +1,74 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +//! Google Cloud Storage properties + +use std::collections::HashMap; + +use opendal::services::GcsConfig; +use opendal::Operator; + +use crate::{Error, ErrorKind, Result}; + +// Reference: https://github.com/apache/iceberg/blob/main/gcp/src/main/java/org/apache/iceberg/gcp/GCPProperties.java + +/// Google Cloud Storage bucket name +pub const GCS_BUCKET: &str = "gcs.bucket"; +/// Google Cloud Storage endpoint +pub const GCS_ENDPOINT: &str = "gcs.endpoint"; +/// Google Cloud Storage OAuth token +pub const GCS_OAUTH2_TOKEN: &str = "gcs.oauth2.token"; +/// Google Cloud Storage working (root) directory +pub const GCS_ROOT: &str = "gcs.root"; +/// Google Cloud Storage working (root) directory +pub const GCS_CREDENTIAL_PATH: &str = "gcs.credential-path"; Review Comment: The same. ########## crates/iceberg/src/io/storage_gcs.rs: ########## @@ -0,0 +1,74 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +//! Google Cloud Storage properties + +use std::collections::HashMap; + +use opendal::services::GcsConfig; +use opendal::Operator; + +use crate::{Error, ErrorKind, Result}; + +// Reference: https://github.com/apache/iceberg/blob/main/gcp/src/main/java/org/apache/iceberg/gcp/GCPProperties.java + +/// Google Cloud Storage bucket name +pub const GCS_BUCKET: &str = "gcs.bucket"; Review Comment: `bucket` is parsed during runtime. -- 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