kazdy commented on code in PR #163:
URL: https://github.com/apache/hudi-rs/pull/163#discussion_r1797727245


##########
crates/core/src/table/builder.rs:
##########
@@ -0,0 +1,172 @@
+/*
+ * 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.
+ */
+
+use crate::config::{HudiConfigs, HUDI_CONF_DIR};
+use crate::storage::utils::{parse_config_data, parse_uri};
+use crate::storage::Storage;
+use crate::table::fs_view::FileSystemView;
+use crate::table::timeline::Timeline;
+use crate::table::Table;
+use anyhow::Context;
+use std::collections::HashMap;
+use std::env;
+use std::path::PathBuf;
+use std::sync::Arc;
+use url::Url;
+
+#[derive(Debug)]
+pub struct TableBuilder {
+    base_url: Url,
+    hudi_options: Option<HashMap<String, String>>,
+    storage_options: Option<HashMap<String, String>>,
+}
+
+impl TableBuilder {
+    pub fn from_uri(uri: &str) -> Self {
+        let base_url = parse_uri(uri).unwrap(); // TODO: handle err
+        TableBuilder {
+            base_url,
+            storage_options: None,
+            hudi_options: None,
+        }
+    }
+    pub fn with_hudi_options(mut self, hudi_options: HashMap<String, String>) 
-> Self {
+        self.hudi_options = Some(hudi_options);
+        self
+    }
+
+    pub fn with_storage_options(mut self, storage_options: HashMap<String, 
String>) -> Self {
+        self.storage_options = Some(storage_options);
+        self
+    }

Review Comment:
   I think TableBuilder can give more control to the user and be more specific. 
I'm fine with having a generic API for ease of use, but I still think having 
this explicit distinction between hudi and storage options is nice and easy to 
understand when using the API. I was a bit confused at first and wondered 
if/where can I pass storage options.
   
   Still Table has ::new_with_options() which is generic so that TableBuilder 
can be more specific?
   
   I agree about validation being done in ::build().
   I'm not sure if I'll be able to add more validation now, but I can give it a 
try in the next PR?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to