-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[fix](function) Preserve trailing zero bytes in string distances #66236
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,8 +50,7 @@ static StringRef string_ref_at(const ColumnString::Chars& data, | |
| const ColumnString::Offsets& offsets, size_t i) { | ||
| DCHECK_LT(i, offsets.size()); | ||
| const auto previous_offset = i == 0 ? 0 : offsets[i - 1]; | ||
| return StringRef(data.data() + previous_offset, offsets[i] - previous_offset) | ||
| .trim_tail_padding_zero(); | ||
| return StringRef(data.data() + previous_offset, offsets[i] - previous_offset); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P1] Do not evaluate retained payloads for NULL rows This function family uses the default nullable wrapper with |
||
| } | ||
|
|
||
| static void get_utf8_char_offsets(const StringRef& ref, Utf8Offsets& offsets) { | ||
|
|
@@ -390,15 +389,14 @@ struct StringDistanceImplBase { | |
| ResultPaddedPODArray& res) { | ||
| const size_t size = offsets.size(); | ||
| res.resize(size); | ||
| const auto constant_ref = constant.trim_tail_padding_zero(); | ||
| const bool constant_ascii = simd::VStringFunctions::is_ascii(constant_ref); | ||
| const bool constant_ascii = simd::VStringFunctions::is_ascii(constant); | ||
| Utf8Offsets constant_offsets; | ||
| get_utf8_char_offsets(constant_ref, constant_offsets); | ||
| get_utf8_char_offsets(constant, constant_offsets); | ||
| Utf8Offsets value_offsets; | ||
| for (size_t i = 0; i < size; ++i) { | ||
| RETURN_IF_ERROR(distance_with_const_offsets(string_ref_at(data, offsets, i), | ||
| value_offsets, constant_ref, | ||
| constant_offsets, constant_ascii, res[i])); | ||
| value_offsets, constant, constant_offsets, | ||
| constant_ascii, res[i])); | ||
| } | ||
| return Status::OK(); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] Add a regression that reaches the patched BE paths
These removals are the entire behavior change, but the changed-file list contains no test/output file and the existing distance suite never constructs a trailing NUL. Literal-only cases are insufficient because Nereids
StringArithmeticalready counts U+0000, so they can pass on the base revision without executing these BE branches. Please add generated regression coverage that fails on the base and passes here, using table-backed binary values to exercise runtime vector/nullable and const-vector paths for Hamming, Levenshtein, and Damerau-Levenshtein (for examplea\0vsaanda\0vsaX), plus a CHAR case proving storage padding stays invisible.