You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by "codope (via GitHub)" <gi...@apache.org> on 2026/09/07 09:24:33 UTC
[PR] feat(cpp): forward read options through file slice reads [hudi-rs]
codope opened a new pull request, #767:
URL: https://github.com/apache/hudi-rs/pull/767
## Description
`read_file_slice` and `read_file_slice_from_paths` built `ReadOptions::new()` internally, so a C++ caller got no column projection, no filters and no read-optimized mode even though `FileGroupReader` supports all of them. A merge-on-read slice was always materialized with every column.
This adds two shared bridge structs and two entry points:
```cpp
struct HudiFilter { rust::String field; rust::String op; rust::String value; };
struct HudiReadOptions { rust::Vec<rust::String> projection; // empty = all columns
rust::Vec<HudiFilter> filters; // op: = != < <= > >= IN "NOT IN"
rust::Vec<rust::String> hudi_options; // "hoodie.read.*=value"
};
read_file_slice_with_options(slice, options);
read_file_slice_from_paths_with_options(base_file_path, log_file_paths, options);
```
Filters use the same `(field, op, value)` grammar as the Python binding so the two bindings stay in sync; `hudi_options` uses the same `key=value` shape as the reader constructor, which gives `hoodie.read.use.read_optimized.mode`, `hoodie.read.stream.batch_size` and `hoodie.read.as.of.timestamp` for free. The existing two entry points stay as wrappers over default options.
Behavior change for C++ callers: a `key=value` option without `=` now throws `rust::Error` from `new_file_group_reader_with_options` instead of being silently dropped, so both option surfaces in the header behave the same. The header doc says so.
Stacked on #766 (branch `cpp/catch-unwind-636`); review the last commit only until that merges. `cargo test -p hudi-cpp --doc` fails with a pre-existing `E0464: multiple candidates for rlib hudi` that is present on `main`; `make test-rust` runs `--all-targets`, which skips doctests.
Closes #637. Related: apache/hudi#18308.
## How are the changes test-covered
- [ ] N/A
- [x] Automated tests (unit and/or integration tests)
- [ ] Manual tests
- [ ] Details are described below
Unit tests in `cpp/src/lib.rs`: option mapping (defaults, every field, bad operator, option without `=`, and the `key=value` parser the constructor now shares); a MOR slice with real log files read through `read_file_slice_with_options` with a projection and an `id = <max>` filter; the paths entry point driven through real `CxxString`/`CxxVector` arguments with a projection and filter; and read-optimized mode proven by a slice whose only log file does not exist, which reads with the option set and fails naming the log file without it.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(cpp): forward read options through file slice reads [hudi-rs]
Posted by "codope (via GitHub)" <gi...@apache.org>.
codope commented on code in PR #767:
URL: https://github.com/apache/hudi-rs/pull/767#discussion_r4426843466
##########
cpp/src/lib.rs:
##########
@@ -68,86 +194,95 @@ pub struct HudiFileGroupReader {
pub fn new_file_group_reader_with_options(
base_uri: &CxxString,
options: &CxxVector<CxxString>,
-) -> std::result::Result<Box<HudiFileGroupReader>, String> {
- let base_uri = base_uri
- .to_str()
- .map_err(|e| format!("Failed to convert CxxString to str: {e}"))?;
-
- let mut opt_vec = Vec::new();
- for opt in options.iter() {
- let opt_str = opt
- .to_str()
- .map_err(|e| format!("Failed to convert CxxString to str: {e}"))?;
- if let Some((key, value)) = opt_str.split_once('=') {
- opt_vec.push((key, value))
- }
- }
+) -> Result<Box<HudiFileGroupReader>, String> {
+ guard("new_file_group_reader_with_options", || {
+ let base_uri = cxx_str(base_uri)?;
+
+ let opt_vec = key_values(cxx_strs(options)?)?;
Review Comment:
Done. It's out of this PR, and the constructor here drops a malformed option as before. I will create a separate `ficx(cpp)` PR
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(cpp): forward read options through file slice reads [hudi-rs]
Posted by "yihua (via GitHub)" <gi...@apache.org>.
yihua commented on code in PR #767:
URL: https://github.com/apache/hudi-rs/pull/767#discussion_r4393773974
##########
cpp/src/lib.rs:
##########
@@ -33,33 +36,156 @@ mod ffi {
type ArrowArrayStream;
}
+ /// One column predicate, `field op value`. `op` is one of `=`, `!=`, `<`,
+ /// `<=`, `>`, `>=`, `IN`, `NOT IN`; the last two take a comma-separated
+ /// `value`.
+ struct HudiFilter {
+ field: String,
+ op: String,
+ value: String,
+ }
+
+ /// Options for one read. An empty `projection` reads every column;
+ /// `hudi_options` are `key=value` read configs such as
Review Comment:
non-blocking: For the eager slice reads, the only per-read key the core reader acts on is `hoodie.read.use.read_optimized.mode`; `as.of.timestamp`, `start/end.timestamp` and `stream.batch_size` set here are accepted and ignored (see the doc on `FileGroupReader::read_file_slice_from_paths`), so a C++ caller passing a time window per read gets unfiltered rows back with no error. Could the doc here say that read-optimized mode is the one honored per read, and that time-window options belong on `new_file_group_reader_with_options`? The PR description's "for free" line for `batch_size` and `as.of.timestamp` probably wants the same correction.
##########
cpp/src/lib.rs:
##########
@@ -33,33 +36,156 @@ mod ffi {
type ArrowArrayStream;
}
+ /// One column predicate, `field op value`. `op` is one of `=`, `!=`, `<`,
+ /// `<=`, `>`, `>=`, `IN`, `NOT IN`; the last two take a comma-separated
+ /// `value`.
+ struct HudiFilter {
+ field: String,
+ op: String,
+ value: String,
+ }
+
+ /// Options for one read. An empty `projection` reads every column;
+ /// `hudi_options` are `key=value` read configs such as
+ /// `hoodie.read.use.read_optimized.mode=true`.
+ struct HudiReadOptions {
+ projection: Vec<String>,
+ filters: Vec<HudiFilter>,
+ hudi_options: Vec<String>,
Review Comment:
non-blocking: Is `hudi_options` needed on the per-read struct? A C++ caller can already get read-optimized mode by passing `hoodie.read.use.read_optimized.mode=true` to `new_file_group_reader_with_options`, since `resolve_read_options` carries reader-level read configs into every read, and that is the only per-read key the eager slice reads act on. Dropping it would keep the new surface to projection and filters and avoid a field where most keys are silently ignored; if a per-read toggle on a shared reader is the use case, a `bool read_optimized` would say so more precisely.
##########
cpp/src/lib.rs:
##########
@@ -68,86 +194,95 @@ pub struct HudiFileGroupReader {
pub fn new_file_group_reader_with_options(
base_uri: &CxxString,
options: &CxxVector<CxxString>,
-) -> std::result::Result<Box<HudiFileGroupReader>, String> {
- let base_uri = base_uri
- .to_str()
- .map_err(|e| format!("Failed to convert CxxString to str: {e}"))?;
-
- let mut opt_vec = Vec::new();
- for opt in options.iter() {
- let opt_str = opt
- .to_str()
- .map_err(|e| format!("Failed to convert CxxString to str: {e}"))?;
- if let Some((key, value)) = opt_str.split_once('=') {
- opt_vec.push((key, value))
- }
- }
+) -> Result<Box<HudiFileGroupReader>, String> {
+ guard("new_file_group_reader_with_options", || {
+ let base_uri = cxx_str(base_uri)?;
+
+ let opt_vec = key_values(cxx_strs(options)?)?;
Review Comment:
non-blocking: The constructor now throwing on an option without `=` is a behavior change to an existing entry point that the read-options feature doesn't depend on. Would you consider splitting it into its own `fix(cpp)` PR so it shows up on its own in the release notes? Its justification also leans on `hudi_options` existing on the per-read struct (see the comment on line 54).
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(cpp): forward read options through file slice reads [hudi-rs]
Posted by "codope (via GitHub)" <gi...@apache.org>.
codope commented on code in PR #767:
URL: https://github.com/apache/hudi-rs/pull/767#discussion_r4426851643
##########
cpp/src/lib.rs:
##########
@@ -33,33 +36,156 @@ mod ffi {
type ArrowArrayStream;
}
+ /// One column predicate, `field op value`. `op` is one of `=`, `!=`, `<`,
+ /// `<=`, `>`, `>=`, `IN`, `NOT IN`; the last two take a comma-separated
+ /// `value`.
+ struct HudiFilter {
+ field: String,
+ op: String,
+ value: String,
+ }
+
+ /// Options for one read. An empty `projection` reads every column;
+ /// `hudi_options` are `key=value` read configs such as
+ /// `hoodie.read.use.read_optimized.mode=true`.
+ struct HudiReadOptions {
+ projection: Vec<String>,
+ filters: Vec<HudiFilter>,
+ hudi_options: Vec<String>,
Review Comment:
agreed.. replaced it with `bool read_optimized`, since a per-read toggle on a shared reader is the use case (one reader per table across many splits).
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(cpp): forward read options through file slice reads [hudi-rs]
Posted by "yihua (via GitHub) via commits" <co...@hudi.apache.org>.
yihua commented on PR #767:
URL: https://github.com/apache/hudi-rs/pull/767#issuecomment-6716848954
Thanks for the contribution and for splitting out the constructor change into #942! LGTM, with a minor revision pushed in the latest commit that documents the `\,` and `\\` escapes for `IN` / `NOT IN` values on `HudiFilter`.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(cpp): forward read options through file slice reads [hudi-rs]
Posted by "codope (via GitHub)" <gi...@apache.org>.
codope commented on code in PR #767:
URL: https://github.com/apache/hudi-rs/pull/767#discussion_r4426944222
##########
cpp/src/lib.rs:
##########
@@ -68,86 +194,95 @@ pub struct HudiFileGroupReader {
pub fn new_file_group_reader_with_options(
base_uri: &CxxString,
options: &CxxVector<CxxString>,
-) -> std::result::Result<Box<HudiFileGroupReader>, String> {
- let base_uri = base_uri
- .to_str()
- .map_err(|e| format!("Failed to convert CxxString to str: {e}"))?;
-
- let mut opt_vec = Vec::new();
- for opt in options.iter() {
- let opt_str = opt
- .to_str()
- .map_err(|e| format!("Failed to convert CxxString to str: {e}"))?;
- if let Some((key, value)) = opt_str.split_once('=') {
- opt_vec.push((key, value))
- }
- }
+) -> Result<Box<HudiFileGroupReader>, String> {
+ guard("new_file_group_reader_with_options", || {
+ let base_uri = cxx_str(base_uri)?;
+
+ let opt_vec = key_values(cxx_strs(options)?)?;
Review Comment:
Created separate PR as dicussed above https://github.com/apache/hudi-rs/pull/942
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(cpp): forward read options through file slice reads [hudi-rs]
Posted by "codope (via GitHub) via commits" <co...@hudi.apache.org>.
codope commented on PR #767:
URL: https://github.com/apache/hudi-rs/pull/767#issuecomment-6951869103
@yihua gentle ping on this PR.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(cpp): forward read options through file slice reads [hudi-rs]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #767:
URL: https://github.com/apache/hudi-rs/pull/767#issuecomment-5569358339
## [Codecov](https://app.codecov.io/gh/apache/hudi-rs/pull/767?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 79.50%. Comparing base ([`06f17bf`](https://app.codecov.io/gh/apache/hudi-rs/commit/06f17bf646ca7f8d76230d86f365f171814720cb?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`155b774`](https://app.codecov.io/gh/apache/hudi-rs/commit/155b774bb598c05b6330d810996e4b3391344418?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## main #767 +/- ##
=======================================
Coverage 79.50% 79.50%
=======================================
Files 126 126
Lines 12371 12371
=======================================
Hits 9835 9835
Misses 2536 2536
```
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/hudi-rs/pull/767?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
</details>
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(cpp): forward read options through file slice reads [hudi-rs]
Posted by "codope (via GitHub) via commits" <co...@hudi.apache.org>.
codope commented on PR #767:
URL: https://github.com/apache/hudi-rs/pull/767#issuecomment-6718586122
Thanks @yihua ! The revision looks good. Could you please merge this PR?
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(cpp): forward read options through file slice reads [hudi-rs]
Posted by "codope (via GitHub)" <gi...@apache.org>.
codope commented on PR #767:
URL: https://github.com/apache/hudi-rs/pull/767#issuecomment-6530024103
> Thanks for the contribution. A few comments on how the read configs are read and applied.
>
> Separately, the release only publishes `hudi-core`, `hudi-datafusion` and `hudi` to crates.io. Does `hudi-cpp` need to be published as well, so C++ consumers can pick up these entry points from a release?
@yihua I have addressed the comments.
On publishing `hudi-cpp`: I don't think crates.io gets C++ consumers much. They build through `cpp/CMakeLists.txt`, which runs cargo and the cxx-generated header, so the ASF source release, which already contains `cpp/`, is what they'd pick up. The crate also sets `[lib] name = "hudi"`, which collides with its `hudi` dependency (probably that's why `cargo test -p hudi-cpp --doc` fails with E0464), so that would need sorting out before a publish anyway. I'd rather open a separate issue on how C++ artifacts get distributed (source release only, prebuilt per-platform libs, or a vcpkg/conan port) than grow this PR. Happy to file it if that sounds right.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(cpp): forward read options through file slice reads [hudi-rs]
Posted by "codope (via GitHub)" <gi...@apache.org>.
codope commented on code in PR #767:
URL: https://github.com/apache/hudi-rs/pull/767#discussion_r4426867029
##########
cpp/src/lib.rs:
##########
@@ -33,33 +36,156 @@ mod ffi {
type ArrowArrayStream;
}
+ /// One column predicate, `field op value`. `op` is one of `=`, `!=`, `<`,
+ /// `<=`, `>`, `>=`, `IN`, `NOT IN`; the last two take a comma-separated
+ /// `value`.
+ struct HudiFilter {
+ field: String,
+ op: String,
+ value: String,
+ }
+
+ /// Options for one read. An empty `projection` reads every column;
+ /// `hudi_options` are `key=value` read configs such as
Review Comment:
Good catch! the commit-time window comes from the reader's configs, so a per-read `as.of`/`start`/`end` was accepted and ignored. With the field now a `bool read_optimized` (see the next thread), there's no way to pass those per read anymore, and the struct doc points time-window options to `new_file_group_reader_with_options`. I've also corrected the "for free" line in the description.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(cpp): forward read options through file slice reads [hudi-rs]
Posted by "codope (via GitHub)" <gi...@apache.org>.
codope commented on PR #767:
URL: https://github.com/apache/hudi-rs/pull/767#issuecomment-6449844970
@yihua Thanks for landing #766 . I will rebase this PR and update it. If both can go in the upcoming 0.6.0 release, that would be great!
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(cpp): forward read options through file slice reads [hudi-rs]
Posted by "yihua (via GitHub) via commits" <co...@hudi.apache.org>.
yihua merged PR #767:
URL: https://github.com/apache/hudi-rs/pull/767
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org