[TASK-251] Support Decimals in CPP#265
Open
fresh-borzoni wants to merge 2 commits intoapache:mainfrom
Open
Conversation
Contributor
Author
|
@luoyuxia @zhaohaidao |
There was a problem hiding this comment.
Pull request overview
Adds DECIMAL(p, s) support to the C++ bindings, aligning with the schema-driven approach used by other bindings.
Changes:
- Extend the C++/Rust FFI schema (
FfiColumn) to carry decimalprecision/scaleand map it into core metadata. - Add write-path decimal support from C++ via
GenericRow::SetDecimal(...)(string over FFI) and Rust-side parsing/validation. - Add read-path decimal support by converting Arrow
Decimal128columns intoDatumType::DecimalI64/DecimalI128and formatting viaDatum::DecimalToString().
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/fluss/Cargo.toml | Switch bigdecimal to workspace dependency. |
| Cargo.toml | Add bigdecimal to [workspace.dependencies] for shared use. |
| bindings/cpp/Cargo.toml | Add bigdecimal dependency for C++ binding Rust crate. |
| bindings/cpp/src/types.rs | Add decimal schema mapping, decimal write parsing, and decimal read conversion from Arrow. |
| bindings/cpp/src/lib.rs | Pass schema to row conversion for decimal validation by storing TableInfo in AppendWriter. |
| bindings/cpp/src/ffi_converter.hpp | Marshal new decimal-related fields across C++ <-> Rust FFI structs. |
| bindings/cpp/include/fluss.hpp | Add Decimal types/fields and decimal formatting helpers to the public C++ API. |
| bindings/cpp/examples/example.cpp | Add a C++ example demonstrating decimal schema + write/read. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
859b76b to
f0cb34d
Compare
Contributor
Author
|
rebased and addressed comments |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
closes #251
Add decimal type support to C++ bindings
Adds
DECIMAL(p, s)support to the C++ bindings, matching the Python bindings' schema-driven pattern.Write path
row.SetDecimal(idx, "123.45")— just a string, no precision/scale neededDATUM_TYPE_DECIMAL_STRING)BigDecimal::from_str, looks up(p, s)from the schema, validates, and creates theDecimalRead path
Decimal128values come back asDecimalI64(compact, p≤18) orDecimalI128(non-compact)Datum::DecimalToString()formats them for display