Skip to content

[TASK-251] Support Decimals in CPP#265

Open
fresh-borzoni wants to merge 2 commits intoapache:mainfrom
fresh-borzoni:decimals-cpp
Open

[TASK-251] Support Decimals in CPP#265
fresh-borzoni wants to merge 2 commits intoapache:mainfrom
fresh-borzoni:decimals-cpp

Conversation

@fresh-borzoni
Copy link
Contributor

@fresh-borzoni fresh-borzoni commented Feb 6, 2026

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

  • User calls row.SetDecimal(idx, "123.45") — just a string, no precision/scale needed
  • String crosses FFI as-is (DATUM_TYPE_DECIMAL_STRING)
  • Rust parses via BigDecimal::from_str, looks up (p, s) from the schema, validates, and creates the Decimal

Read path

  • Arrow Decimal128 values come back as DecimalI64 (compact, p≤18) or DecimalI128 (non-compact)
  • Datum::DecimalToString() formats them for display

@fresh-borzoni
Copy link
Contributor Author

@luoyuxia @zhaohaidao
Appreciate your review here. PTAL 🙏

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 decimal precision/scale and 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 Decimal128 columns into DatumType::DecimalI64 / DecimalI128 and formatting via Datum::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.

@fresh-borzoni
Copy link
Contributor Author

rebased and addressed comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Decimals support in CPP

1 participant