Skip to content

Commit 0d927e1

Browse files
feat(c): add write/commit C FFI bindings (#522)
Add write-side C FFI bindings following the existing read-side patterns: API surface (14 functions): - WriteBuilder: new_write_builder, free, with_overwrite, new_write, new_commit - TableWrite: free, write_arrow_batch (via Arrow C Data Interface), prepare_commit - TableCommit: free, commit, overwrite, truncate_table, abort - CommitMessages: free
1 parent 40b199c commit 0d927e1

8 files changed

Lines changed: 2858 additions & 29 deletions

File tree

bindings/c/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ license.workspace = true
2525
version.workspace = true
2626

2727
[lib]
28-
crate-type = ["cdylib", "staticlib"]
28+
crate-type = ["cdylib", "staticlib", "rlib"]
2929
doc = false
3030

3131
[dependencies]
3232
paimon = { path = "../../crates/paimon" }
3333
tokio = { workspace = true, features = ["rt-multi-thread"] }
3434
futures = "0.3"
35+
arrow = { workspace = true }
3536
arrow-array = { workspace = true }
37+
arrow-schema = { workspace = true }

bindings/c/src/error.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ impl paimon_error {
5858
| paimon::Error::ColumnAlreadyExist { .. } => PaimonErrorCode::AlreadyExists,
5959
paimon::Error::ConfigInvalid { .. }
6060
| paimon::Error::DataTypeInvalid { .. }
61+
| paimon::Error::DataInvalid { .. }
6162
| paimon::Error::IdentifierInvalid { .. } => PaimonErrorCode::InvalidInput,
6263
paimon::Error::IoUnexpected { .. } => PaimonErrorCode::IoError,
6364
_ => PaimonErrorCode::Unexpected,

bindings/c/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ mod error;
2424
mod identifier;
2525
mod result;
2626
mod table;
27+
#[cfg(test)]
28+
mod tests;
2729
mod types;
30+
mod write;
2831

2932
use std::sync::OnceLock;
3033
use tokio::runtime::Runtime;

bindings/c/src/result.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,29 @@ pub struct paimon_result_next_batch {
7777
pub batch: paimon_arrow_batch,
7878
pub error: *mut paimon_error,
7979
}
80+
81+
// === Write/Commit result types ===
82+
83+
#[repr(C)]
84+
pub struct paimon_result_write_builder {
85+
pub write_builder: *mut paimon_write_builder,
86+
pub error: *mut paimon_error,
87+
}
88+
89+
#[repr(C)]
90+
pub struct paimon_result_table_write {
91+
pub write: *mut paimon_table_write,
92+
pub error: *mut paimon_error,
93+
}
94+
95+
#[repr(C)]
96+
pub struct paimon_result_table_commit {
97+
pub commit: *mut paimon_table_commit,
98+
pub error: *mut paimon_error,
99+
}
100+
101+
#[repr(C)]
102+
pub struct paimon_result_prepare_commit {
103+
pub messages: *mut paimon_commit_messages,
104+
pub error: *mut paimon_error,
105+
}

0 commit comments

Comments
 (0)