Baymine opened a new pull request, #66078:
URL: https://github.com/apache/doris/pull/66078
### What problem does this PR solve?
Issue Number: close #66077
Problem Summary:
Add a new table hint `BUCKET(<int>, ...)` that mirrors the existing
`TABLET(<int>, ...)` hint but at bucket-ordinal granularity. It is accepted
in
`FROM tbl [PARTITION(...)] BUCKET(0, 2) [TABLET(...)] alias`. A bucket id `k`
resolves to the k-th tablet (`partition.getBaseIndex().getTablets().get(k)`)
of
each selected partition, then reuses the existing
`LogicalOlapScan`/`withManuallySpecifiedTabletIds` path. This lets users
target
the buckets that hold specific keys for debugging and targeted scans without
having to look up raw tablet ids first, which change across schema changes
and
partitions.
Details:
- Grammar: add the `BUCKET` lexer token, a `bucketList` parser rule
(mirroring
`tabletList`), slot `bucketList?` into `relationPrimary #tableName` between
`specifiedPartition?` and `tabletList?`, and add `BUCKET` to `nonReserved`.
- `UnboundRelation` carries the parsed `bucketIds`; `LogicalPlanBuilder`
forwards them from `ctx.bucketList()`.
- `BindRelation` resolves bucket ids to tablet ids via new `OlapTable`
overloads (by bucketIds; partIds+bucketIds; indexId+bucketIds;
partIds+indexId+bucketIds), returning the `[-1L]` empty-scan sentinel when
no
tablet matches (same convention as `TABLET`).
- `BUCKET` and `TABLET` are mutually exclusive (both specified ->
AnalysisException).
- `BUCKET` is rejected on olap table stream scan, analogous to the existing
`TABLET` rejection there.
### Release note
Add a new query hint `BUCKET(id, ...)` to scan specific buckets of an olap
table, mirroring the existing `TABLET(id, ...)` hint at bucket-ordinal
granularity.
### Check List (For Author)
- Test:
- Unit Test: added `LogicalPlanBuilderBucketHintTest` (parser round-trip
for
`BUCKET(...)` into `UnboundRelation.getBucketIds()`) and new cases in
`BindRelationTest` (bucket ids -> expected tablet ids on a 3-bucket
table,
out-of-range bucket -> `[-1]` sentinel, and `BUCKET(..) TABLET(..)` ->
AnalysisException).
- Regression test: added
`regression-test/suites/query_p0/select_tablets/select_with_buckets.groovy`
(auto-generated `.out`) covering per-bucket scans on a 3-bucket table,
`BUCKET(0, 1, 2)` == full table, out-of-range bucket -> empty result,
`BUCKET(..)` + predicate, bucket ordinal across partitions,
`PARTITION ... BUCKET(..)`, and the `BUCKET(..) TABLET(..)`
mutual-exclusion
error.
- Behavior changed: No (adds a new optional hint; existing queries are
unaffected).
- Does this need documentation: Yes (a doc note for the new `BUCKET(...)`
hint
can follow).
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]