[Enhancement] Route range-distribution OLAP tables by per-index distribution expressions (backport #74753)#75013
Conversation
|
Cherry-pick of 60a751b has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
|
@mergify[bot]: Backport conflict, please reslove the conflict and resubmit the pr |
b122aae to
5463a84
Compare
|
Resolved the backport conflict and force-pushed the clean cherry-pick ( Cause:
Resolution (the only two changed regions, verified against
Confirmed all P1a dependencies exist on 4.1 ( |
5463a84 to
3a3b681
Compare
Why I'm doing:
Range-distribution (shared-data) tables route rows to tablets by per-tablet boundaries stored in sort-key space, but the OLAP table sink could only carry a single partition-level distribution-column set. It therefore could not route different rows to materialized indexes that live in different key spaces. This is the missing sink piece for two future features — the K-tablet shadow-index rewrite job (key-column schema change) and range-distribution rollup — both of which need a base index and a new-key index to coexist in one partition and be routed independently.
What I'm doing:
Add per-index distribution routing to the sink:
TOlapTableIndexSchema.distributed_exprs(field 9) carrying per-index routing expression trees, evaluated at the sink sender. Sender-only:POlapTableIndexSchema(proto) is unchanged, so remote write channels never route by it.OlapTableSink.createSchemafillsdistributed_exprsfor range-distribution tables with slot-refs over each index's range sort-key columns, gated to the OLAP write-sink path (dictionary / non-write callers do not emit it). For today's base-only range tables this resolves to exactly the columns the partition-level path already used, so routing is behavior-preserving. Also adds an optionaltargetWriteIndexIdfilter (write only one index; schema, partition and loaded-index lists stay 1:1 by meta id).OlapTableSchemaParamparsesdistributed_exprsinto per-indexExprContexts (prepare/open/close lifecycle); the range sink sender evaluates them once per chunk per index and routes viaRangeRouter.RangeRouter::initvalidates routing-key types against the boundary types; a newroute_chunk_rowsoverload routes from pre-evaluated columns; an emptydistributed_exprs(K=1) routes to the single tablet. When an index has nodistributed_exprs, routing falls back to the partition-level path unchanged.No version gate is needed: StarRocks upgrades BE/CN before FE, so a newly-upgraded FE (the only one that emits the field) never runs against a BE that does not understand it, and an old FE never emits it. Non-range tables and any unset field are byte-for-byte unchanged. This is prerequisite-only: the new capability is dormant for existing tables and consumed by future work.
What type of PR is this:
Does this PR entail a change in behavior?
Checklist:
Bugfix cherry-pick branch check:
🤖 Generated with Claude Code
This is an automatic backport of pull request #74753 done by Mergify.