Skip to content

[branch-4.2][fix](zonemap) Do not trust a cut string bound to prune or to answer MIN/MAX (#67642) - #68324

Open
selectdb-robot wants to merge 1 commit into
apache:branch-4.2from
selectdb-robot:pick-67642-branch-4.2
Open

selectdb-robot wants to merge 1 commit into
apache:branch-4.2from
selectdb-robot:pick-67642-branch-4.2

Conversation

@selectdb-robot

Copy link
Copy Markdown

What problem does this PR solve?

Related PR: #67642

Backport #67642 to branch-4.2, cherry-picked from b0f266a8ebc1a333f806831f5d2209f837fda5d5.

Fix string ZoneMap bounds at the 512-byte cutoff: carry when raising the maximum, discard an all-zero overflowed range on read, and fall back to reading rows for exact MIN/MAX when bounds were truncated. Preserve the original statistics-collection override and the old SQL variable name as an alias.

Branch compatibility adaptations

  • segment.cpp: retain branch-4.2's Schema signature and column-ID iteration; use schema.column(schema.column_id(i)) for the new string-type check. Add the original MIN/MAX forcing and fallback logic.
  • SessionVariable.java: use branch-4.2's VariableMgr.VarAttr with Chinese/English descriptions, preserving the new variable name, old alias, default, and Thrift mapping.
  • PaloInternalService.thrift: add only force_pushdown_zonemap_minmax with the original field ID 1006 and default false. Do not import the unrelated 1005 SNII option from master conflict context.
  • vgeneric_iterators_test.cpp: although this file auto-merged, adapt the added fixture to branch-4.2's Schema/SchemaSPtr, SegmentWriterOptions, TestSegmentWriter, and finalize() APIs. All original test cases remain.

Validation

  • Verified all 12 original files are included; added/deleted lines in the other 9 files match the original patch.
  • No unresolved conflicts, conflict markers, or unstaged edits. Code whitespace check passed. The generated .out retains the original final blank separator, which default git diff --check reports as a blank line at EOF.
  • Confirmed the target Schema/writer/annotation APIs and checked that TQueryOptions field IDs are unique.
  • Regression suite and expected output retain the original content; all added BE test cases are retained.
  • Compilation, BE unit tests, and runtime regression tests were not run in this session; CI validation remains pending.

Release note

Fix incorrect string ZoneMap pruning and MIN/MAX results for truncated string bounds.

Check List (For Author)

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

…MIN/MAX (apache#67642)

1. Write side: a max cut to 512 bytes was raised with str[511] += 1. A
string column holds arbitrary bytes, so a last byte of 0xff wraps to
0x00 and leaves the max below the rows it covers — pruning then skips
pages that do hold matching rows. The raise now carries into the
preceding byte until one does not wrap.
2. Read side: a max of all 0xff carries past its first byte and ends up
all zero, standing above nothing. ZoneMap::from_proto() spots that and
turns pass_all on for the zone, giving up its range instead of ruling
rows out with it — which also covers segments written before this fix.
3. MIN/MAX push-down: a cut bound is not a value the column holds (the
min is a prefix, the max is that prefix raised), so
segment_zone_maps_can_answer_agg() rejects a string bound reaching the
512-byte cut and reads the rows instead. The FE length blacklist is
dropped with it — it was both too strict (a VARCHAR(65533) of short
values was never pushed down) and too loose (a VARCHAR(512) filled to
512 bytes is cut just the same, yet was answered with a value never
inserted).
4. Switch: enable_pushdown_string_minmax → force_pushdown_zonemap_minmax
(old name kept as an alias), now meaning "force MIN/MAX onto the zone
map even when its bound is not a value the data holds right now" — a cut
bound, or one still covering rows a delete predicate removed. Statistics
collection turns it on, every other query leaves it off. It applies to
MIN/MAX only; COUNT and MIX keep the delete-predicate guard. The new
thrift field defaults to false, so an old FE leaves BE behaving as
before.

(cherry picked from commit b0f266a)

Adapt Schema and test writer APIs plus session-variable annotations to branch-4.2.
Keep Thrift field ID 1006 without importing the unrelated master field 1005.
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@selectdb-robot

Copy link
Copy Markdown
Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

Cloud UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 73.27% (1826/2492)
Line Coverage 61.14% (32891/53800)
Region Coverage 48.67% (31122/63943)
Branch Coverage 51.65% (9669/18720)

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.

3 participants