-
Notifications
You must be signed in to change notification settings - Fork 123
feat: Add CreateTable API with typestate pattern #1504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| //! The `table_manager` module provides the entry point for creating and managing Delta tables. | ||
| //! | ||
| //! This module exposes the [`TableManager`] struct which provides static factory methods for | ||
| //! creating new Delta tables with a fluent builder API. | ||
|
|
||
| use crate::schema::SchemaRef; | ||
| use crate::transaction::create_table::CreateTableBuilder; | ||
|
|
||
| /// Entry point for creating and managing Delta tables. | ||
| /// | ||
| /// `TableManager` provides static factory methods that return builders for configuring | ||
| /// and creating new Delta tables. | ||
| pub struct TableManager; | ||
|
|
||
| impl TableManager { | ||
| /// Creates a builder for creating a new Delta table. | ||
| /// | ||
| /// This method returns a [`CreateTableBuilder`] that can be configured with table | ||
| /// properties and other options before building the transaction. | ||
| /// | ||
| /// # Arguments | ||
| /// | ||
| /// * `path` - The file system path where the Delta table will be created | ||
| /// * `schema` - The schema for the new table | ||
| /// * `engine_info` - Information about the engine creating the table (e.g., "MyApp/1.0") | ||
| /// | ||
| /// # Example | ||
| /// | ||
| /// ```rust,no_run | ||
| /// use delta_kernel::table_manager::TableManager; | ||
| /// use delta_kernel::schema::{StructType, StructField, DataType}; | ||
| /// use std::sync::Arc; | ||
| /// # use delta_kernel::Engine; | ||
| /// # fn example(engine: &dyn Engine) -> delta_kernel::DeltaResult<()> { | ||
| /// | ||
| /// let schema = Arc::new(StructType::try_new(vec![ | ||
| /// StructField::new("id", DataType::INTEGER, false), | ||
| /// StructField::new("name", DataType::STRING, true), | ||
| /// ])?); | ||
| /// | ||
| /// let create_txn = TableManager::create_table("/path/to/table", schema, "MyApp/1.0") | ||
| /// .build(engine)?; | ||
| /// # Ok(()) | ||
| /// # } | ||
| /// ``` | ||
| pub fn create_table( | ||
| path: impl AsRef<str>, | ||
| schema: SchemaRef, | ||
| engine_info: impl Into<String>, | ||
| ) -> CreateTableBuilder { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does Kernel Rust have TransctionBuilders yet? Though verbose, Kernel Java's CreateTableTransactionBuilder naming convention makes it clear that: this is a builder for a transaction (yields a Transaction) that should be used to create a table. The callout being: |
||
| CreateTableBuilder::new(path, schema, engine_info) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fly by comment:
So I encourage: either fully adopting TableManager, or not adopting TableManager, and deleting this
TableManager.create_tableAPI