924060929 opened a new pull request, #71001:
URL: https://github.com/apache/doris/pull/71001

   ### Background
   
   Block-sampled OLAP statistics (`FIXED_BLOCK` and `KEY_RANGE_BLOCK`) already 
cover `DUPLICATE`, `UNIQUE` (MOW/MOR), and `AGGREGATE` (HASH/RANDOM) base 
tables, but several structural OLAP index and command boundaries still fall 
back to legacy scans, skip value columns, or misroute partition clauses: 
`CREATE MATERIALIZED VIEW` on MOR tables fails hidden-column and widened 
string-key checks, bucket-pruned `AGG_KEYS` Sync MVs/rollups and `RANDOM` 
`AGG_KEYS` expression Sync MVs are rejected, single-partition `RANDOM BUCKETS > 
512` falls back to scanning all rows, intermediate truncated `CHAR` short keys 
are rejected on BE, and `ANALYZE TABLE t PARTITION(p1)` ignores partition 
scoping when `enable_partition_analyze = false` or `WITH SAMPLE` is specified.
   
   ### What problem does this PR solve?
   
   Issue Number: None
   Related PR: #71000 (depends on)
   PR Type: Enhancement
   
   Problem Summary:
   
   Remaining OLAP internal-table sampling boundaries cause `CREATE MATERIALIZED 
VIEW` indexes on MOR tables and bucket-pruned or expression-defined `AGG_KEYS` 
Sync MVs/rollups to skip value columns or fall back to legacy scans, force 
`RANDOM BUCKETS > 512` `AGG_KEYS` partitions into 100% full-row scans, reject 
composite short keys with an intermediate truncated `CHAR` column, fail jobs 
during in-flight key Schema Changes, and silently overwrite whole-table 
`column_statistics` on `ANALYZE TABLE t PARTITION(p1)`. This PR completes 
`KEY_RANGE_BLOCK` admission and uniqueness accounting for MOR and `AGG_KEYS` 
Sync MVs/rollups, allows `RandomAggTabletSamplingMethod` to coordinate at least 
one whole partition up to SQL capacity, slices monotone short-key prefixes 
through truncated intermediate `CHAR` columns in `SegmentKeySeeker`, defers 
transient key Schema Change mismatches cleanly, and enforces explicit OLAP 
`PARTITION(...)` semantics.
   
   ### Details
   
   - **Change map:** 19 files (+680/-63): production code +276/-55 across 12 
files (41%), BE/FE unit and regression tests +404/-8 across 7 files (59%, tests 
outweigh production code):
     1. Sync MV / rollup `KEY_RANGE_BLOCK` admission, bucket-pruned uniqueness 
accounting, and `> 512`-bucket `RANDOM` `AGG_KEYS` partition allowance 
(`FixedBlockSampleSpec`, `HierarchicalFixedBudgetTabletSamplingMethod`, 
`RandomAggTabletSamplingMethod`, ~120 lines).
     2. Truncated intermediate `CHAR` short-key prefix slicing on BE and 
transient Schema Change deferral + explicit OLAP `PARTITION(...)` routing on FE 
(`segment_key_seeker.cpp`, `BaseAnalysisTask`, `OlapAnalysisTask`, 
`ColumnSampleBatchCollector`, `AnalyzeTableCommand`, ~155 lines).
   - **Before and after:**
     - `CREATE MATERIALIZED VIEW` and rollups on MOR tables validate 
merge-relevant hidden columns (`__DORIS_DELETE_SIGN__`, 
`__DORIS_SEQUENCE_COL__`, `__DORIS_TTL_COL__`, and column sequence mappings) 
while ignoring base-only `__DORIS_VERSION_COL__` / `__DORIS_ROW_STORE_COL__` 
and accepting lossless string `SlotRef` length widening 
(`MVColumnItem.setMaxLength()`).
     - Expression Sync MVs on `RANDOM` `AGG_KEYS` tables use shared 
`KEY_RANGE_BLOCK`, and bucket-pruned `AGG_KEYS` Sync MVs/rollups use 
multi-bucket `KEY_RANGE_BLOCK` (`minSeats = min(8, tabletCount)`) while 
disabling cross-bucket `singleUniqueKey` assumptions 
(`FixedBlockSampleSpec.guaranteesGlobalKeyUniqueness`).
     - `RandomAggTabletSamplingMethod` permits at least one full `RANDOM` 
partition up to internal SQL capacity even when bucket count exceeds 
`statistics_max_sample_tablets` (`512`), avoiding full-table `xxhash_64` scans 
on `1024+` bucket tables.
     - BE `SegmentKeySeeker` slices short-key index entries and row prefixes at 
the first truncated intermediate `CHAR` column (`index_length < length`) so 
`KEY_RANGE_BLOCK` remains monotonic, FE 
`FixedBlockSampleSpec.hasOrderedShortKeyPrefix` rejects intermediate 
`VARCHAR`/`STRING` short keys upfront, and transient BE `KEY_RANGE_BLOCK` 
key-schema `NotSupported` errors during in-flight Schema Changes defer via 
`AnalyzeSkipException` instead of failing jobs.
     - Explicit `ANALYZE TABLE t PARTITION(p1, ...)` full analyze routes to 
`doPartitionTable()` even when `enable_partition_analyze = false`, and `ANALYZE 
TABLE t PARTITION(p1, ...) WITH SAMPLE` on OLAP partition subsets raises a 
clear `AnalysisException` instead of overwriting table-wide `column_statistics`.
   - **Configs and defaults:** None.
   - **Impact on existing users:** Upgraded clusters automatically collect 
block-sampled statistics on MOR Sync MVs/rollups, bucket-pruned/expression 
`AGG_KEYS` Sync MVs and rollups, `RANDOM BUCKETS > 512` `AGG_KEYS` tables, and 
composite short keys with truncated `CHAR` columns; explicit `ANALYZE TABLE t 
PARTITION(p1) WITH SAMPLE` now errors clearly instead of silently ignoring 
`PARTITION(p1)`.
   
   ### Testing
   
   - `./build-support/check-build-hygiene.sh`: all checks passed (`0` 
violations).
   - `./build-support/check-format.sh` & `./build-support/run-clang-tidy.sh`: 0 
formatting or clang-tidy warnings across all 7 modified BE files.
   - `mvn checkstyle:check -pl fe-common,fe-core`: 0 Checkstyle violations.
   - `./run-be-ut.sh --run 
--filter="*KeyRangeBlockSampler*:*SegmentKeySeeker*:*KeyRangeSeeks*"`: 12/12 BE 
unit tests passed, including 
`VerticalSegmentWriterWritePathsTest.KeyRangeSeeksTruncatedIntermediateCharShortKey`.
   - `./run-fe-ut.sh --run ...`: 115/115 FE unit tests passed, including 
`KeyRangeBlockSamplingTest` and 
`AnalyzeTest.testPartitionAnalyzeValidationAndExplicitPartitionRouting`.
   - `./run-regression-test.sh` on local isolated cluster: 
`test_fixed_block_sample`, `test_key_range_block_sample`, 
`test_sample_minmax_batch`, `test_fixed_block_analyze`, 
`test_skip_agg_table_value_column`, `test_analyze_mv`, and 
`test_analyze_long_string` passed.
   
   ### Notes for Reviewers
   
   - Stacked on #71000; review top commit `9d33c8b97aa` for the standalone diff 
until #71000 merges.
   
   ### Release note
   
   Extend OLAP block-sampled statistics to MOR and bucket-pruned/expression 
`AGG_KEYS` synchronous materialized views, `RANDOM` `AGG_KEYS` partitions with 
more than 512 buckets, and composite short keys with truncated `CHAR` columns, 
and enforce explicit OLAP partition `ANALYZE` semantics.
   
   ### Check List (For Author)
   
   - Behavior changed: Yes (see Details)
   - Does this need documentation: No
   - Pre-submission status: Ready
   
   ### AI Disclosure
   
   - Tool: Antigravity
   - Generated: code, tests, this description
   - Human review: not stated
   


-- 
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]

Reply via email to