Skip to content
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

Avoid use of flatbuffers::size_prefixed_root, fix validation error in arrow-flight #7109

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

bkietz
Copy link
Member

@bkietz bkietz commented Feb 10, 2025

Which issue does this PR close?

Rationale for this change

flatbuffers::size_prefixed_root does not seem to do what was originally expected. Replacing it with more explicit code for handling an encapsulated message prefix seems to resolve the case of interest.

What changes are included in this PR?

Usage of size_prefixed_root ( there was only one call, introduced in #2586 ) is replaced with manual prefixed length wrangling. A unit test is added

Are there any user-facing changes?

No

Maybe the error messages?

@github-actions github-actions bot added the arrow Changes to the arrow crate label Feb 10, 2025
@bkietz bkietz marked this pull request as ready for review February 12, 2025 17:07
@bkietz bkietz force-pushed the 7058-avoid-use-of-size_prefixed_root branch 2 times, most recently from d689e17 to c225a02 Compare February 12, 2025 17:19
@bkietz bkietz force-pushed the 7058-avoid-use-of-size_prefixed_root branch from c225a02 to f9e091b Compare February 13, 2025 19:39
@bkietz bkietz requested a review from tustvold February 24, 2025 17:34
@XiangpengHao
Copy link
Contributor

XiangpengHao commented Mar 3, 2025

The change looks good to me, I've tested in in https://github.com/XiangpengHao/liquid-cache, and it indeed fixes the problem it tries to fix. cc @alamb

@@ -2617,4 +2619,43 @@ mod tests {
let err = read_ipc_with_decoder(buf).unwrap_err();
assert_eq!(err.to_string(), expected_err);
}

#[test]
fn test_roundtrip_schema() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Strangely this test passes for me on main (without the changes in this PR)

So I don't think it covers the issue somehow. I am looking into it a bit more

@github-actions github-actions bot added the arrow-flight Changes to the arrow-flight crate label Mar 6, 2025
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @bkietz and @XiangpengHao

I took the liberty of merging this PR up from main as well as adding the test case from @XiangpengHao 's original issue #7058

The reason the test in this PR might not be failing might be related to how it sets up the dictionary tracker where arrow-flight does this:

    let mut dict_tracker =
        writer::DictionaryTracker::new_with_preserve_dict_id(false, options.preserve_dict_id());

let mut dict_tracker =
writer::DictionaryTracker::new_with_preserve_dict_id(false, options.preserve_dict_id());

buffer.split_at(4)
};

let len = <i32>::from_le_bytes(len.try_into().unwrap());
Copy link
Contributor

Choose a reason for hiding this comment

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

this are very reasonable checks 👍

@alamb alamb changed the title Avoid use of flatbuffers::size_prefixed_root Avoid use of flatbuffers::size_prefixed_root, fix validation error in arrow-flight Mar 6, 2025
@alamb alamb changed the title Avoid use of flatbuffers::size_prefixed_root, fix validation error in arrow-flight Avoid use of flatbuffers::size_prefixed_root, fix validation error in arrow-flight Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate arrow-flight Changes to the arrow-flight crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect IPC schema encoding for multiple dictionaries
3 participants