marvinlanhenke commented on code in PR #285: URL: https://github.com/apache/iceberg-rust/pull/285#discussion_r1531794765
########## crates/catalog/hms/src/catalog.rs: ########## @@ -287,31 +307,203 @@ impl Catalog for HmsCatalog { Ok(tables) } + /// Creates a new table within a specified namespace using the provided + /// table creation settings. + /// + /// # Returns + /// A `Result` wrapping a `Table` object representing the newly created + /// table. + /// + /// # Errors + /// This function may return an error in several cases, including invalid + /// namespace identifiers, failure to determine a default storage location, + /// issues generating or writing table metadata, and errors communicating + /// with the Hive Metastore. async fn create_table( &self, - _namespace: &NamespaceIdent, - _creation: TableCreation, + namespace: &NamespaceIdent, + creation: TableCreation, ) -> Result<Table> { - todo!() + let db_name = validate_namespace(namespace)?; + let table_name = creation.name.clone(); + + let location = match &creation.location { + Some(location) => location.clone(), + None => { + let ns = self.get_namespace(namespace).await?; + get_default_table_location(&ns, &table_name)? + } + }; + + let metadata = TableMetadataBuilder::from_table_creation(creation)?.build()?; + let metadata_location = create_metadata_location(&location, 0)?; + + let file_io = FileIO::from_path(&metadata_location)? + .with_props(&self.config.props) + .build()?; + let mut file = file_io.new_output(&metadata_location)?.writer().await?; + file.write_all(&serde_json::to_vec(&metadata)?).await?; + file.shutdown().await?; Review Comment: @liurenjie1024 I had troubles using `flush()` since no actual file was written - only when shutdown is used? -- 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