Skip to content

Storages: introduce trim min-max index for DATE/DATETIME/TIMESTAMP rough set filtering#10982

Merged
ti-chi-bot[bot] merged 20 commits into
pingcap:feature/release-8.5-materialized-viewfrom
JaySon-Huang:jayson/trim_datetime_minmax_index_mv
Jul 21, 2026
Merged

Storages: introduce trim min-max index for DATE/DATETIME/TIMESTAMP rough set filtering#10982
ti-chi-bot[bot] merged 20 commits into
pingcap:feature/release-8.5-materialized-viewfrom
JaySon-Huang:jayson/trim_datetime_minmax_index_mv

Conversation

@JaySon-Huang

@JaySon-Huang JaySon-Huang commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #10989

Problem Summary:

Applications sometimes use a far-future temporal value, such as 2100-01-01 00:00:00, as a sentinel for an unsettled record while normal DATE, DATETIME, or TIMESTAMP values remain concentrated in a recent range.

Although such sentinels are sparse, they pollute the ordinary pack-level min-max index. With 8,192 rows per pack and an independently distributed sentinel probability of 1/10000, about 55.9% of packs contain at least one sentinel. Their ordinary maximum is extended to 2100, so narrow recent-time predicates cannot exclude those packs and must read and filter more data.

The ordinary min-max index cannot simply ignore a particular application value because queries may intentionally access it. TiFlash needs an optional temporal index that improves pruning for eligible predicates without changing SQL semantics or weakening the ordinary fallback path.

What is changed and how it works?

Storages: introduce trim min-max index for DATE/DATETIME/TIMESTAMP rough set filtering

This PR adds an optional pack-level trim min-max index for user DATE, DATETIME, and TIMESTAMP columns in DeltaMerge DMFile V3 / MetaV2.

The effective interval for format V1 is the half-open range [1900-01-01 00:00:00, 2099-12-01 00:00:00). The ordinary min-max index remains unchanged and continues to cover every non-NULL, non-deleted value. The trim index covers only values inside the effective interval and records directional per-pack marks when values are trimmed below or above it.

Write path and disk format

  • Build the ordinary and trim min-max indexes in the same pack scan when dt_enable_trim_minmax=true.
  • Keep the ordinary .idx payload and its byte format unchanged.
  • Persist trim data in a separate deterministic <column-stream>.trim.idx merged subfile only when the DMFile contains trimmed outliers.
  • Store format version, the type-packed lower/upper bounds, and pack count in the independent optional protobuf field ColumnStat.trim_minmax_index = 105.
  • Reuse the existing min-max pack-mark byte: bit 0 is has_null, bit 1 is has_trimmed_low, and bit 2 is has_trimmed_high.
  • Treat logical metadata absence or mismatch as a soft fallback, while preserving the existing hard-failure policy for impossible merged-file geometry, checksum failure, or corrupt/reserved pack-mark bits.

Query-domain analysis and read path

  • Normalize supported temporal predicates into a query domain, including eligible Equal, IN, bounded ranges, and one-sided ranges.
  • Merge same-column top-level AND range bounds without sharing eligibility across OR or NOT branches.
  • Select trim min-max per predicate and per DMFile using the bounds persisted by that DMFile. A different predicate on the same column can still load and use the ordinary min-max index.
  • Convert TIMESTAMP constants through the request time zone into UTC-packed values before eligibility checks; compare DATETIME and DATE using calendar-value semantics.
  • Conservatively correct trim rough-check results using the directional pack marks, including None -> Some and All -> Some when trimmed values can invalidate the uncorrected result.
  • Fall back to ordinary min-max when the switch is disabled, metadata or the trim subfile is absent, the version or pack count is unsupported, the predicate is outside the persisted interval, or the expression shape is not supported.

Configuration and observability

  • Add the unified dt_enable_trim_minmax setting, defaulting to false. It controls both generation and query use of trim min-max indexes.
  • Add Prometheus counters for trim selection/fallback reasons, trim rough-check All/Some/None/AllNull results, and conservative correction counts.
  • Do not add SQL syntax or DDL. The feature is transparent to SQL results and is enabled only through the TiFlash profile setting.

Compatibility

  • Old readers ignore protobuf field 105 and the additional merged subfile, then continue using the unchanged ordinary min-max index.
  • New and old DMFiles can coexist; each predicate independently selects trim or falls back to ordinary min-max for each DMFile.
  • An old-version metadata rewrite may drop field 105. A new reader then ignores the orphan trim subfile and safely falls back to ordinary min-max.
  • Downgrading to a binary that predates dt_enable_trim_minmax requires removing that unknown setting from tiflash.toml before startup.

See the design document for the correctness proof, format details, and rollout constraints.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Unit coverage includes:

  • trim pack marks, protobuf round trips, unknown-field compatibility, metadata validation/fallback reasons, file naming, and cache-key separation;
  • ordinary/trim index construction in one pass, NULL/delete/empty packs, invalid masks, persistence only when outliers exist, and disabled-write behavior;
  • DATE, fractional DATETIME, and TIMESTAMP packed bounds and time-zone conversion;
  • query-domain eligibility and normalization, inclusive/exclusive and empty ranges, per-column parse failures, unsupported/NULL-sensitive shapes, mixed AND/OR trees, and per-predicate eligibility;
  • the complete RSResult correction matrix, trim/ordinary pack-filter selection, missing attribute types, and DMFile MetaV2 persistence/drop behavior.

The PR unit-test and integration-test CI jobs pass.

Manual validation used the same generated 500-million-row data set in two tables with different import/DMFile layouts: test.bc_bet_records_500m and test.bc_bet_records_500m_stream.

  1. Correctness: Ran Q01-Q33 through TiKV, TiFlash with trim disabled, and TiFlash with trim enabled. Q01-Q31 compare exact row counts and checksums, Q32 compares grouped rows, and Q33 compares a deterministic complete 100-row TopN result. All 133 normalized result rows matched exactly. The enabled run exercised trim selection, outside-range fallback, All/Some/None, none_to_some, and all_to_some; the disabled run exercised only fallback_disabled. See the 500M correctness report.
  2. Performance: For each table, ran one warm-up and five measured P01-P06 suites per setting, then disabled trim again for three reverse-order confirmation suites. The complete-suite median improved by 24.1% (2,125.5 ms -> 1,613.2 ms) on the regular-import table and by 24.9% (2,066.3 ms -> 1,552.7 ms) on the stream-import table. P04 physical scanned rows decreased by 52.4% and 52.6%, respectively. The P05 outside-range control had unchanged scanned rows and no meaningful benefit, as expected. See the 500M benchmark report.
  3. Downgrade read compatibility: After newer code generated and read trim indexes, downgraded the TiFlash node to 5d56de051244ac7c893de5ac029f0013098f95dc, removed the unknown dt_enable_trim_minmax setting, and forced both tables through TiFlash MPP. Both 500-million-row invariant scans and complete Q01-Q33 suites passed with zero differences from the TiKV oracle, and no post-start DMFile/index/checksum/corruption error was logged. This validates read compatibility only; it does not cover old-version writes or metadata rewrites. See the downgrade report.

The data generator, distributions, import paths, and SQL suites are documented in the dbgen trim min-max example.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

The feature is disabled by default. When enabled, DMFile writing performs additional min/max comparisons and may persist one optional trim subfile per eligible temporal column with outliers. Eligible reads load the trim index in preference to ordinary min-max; fallback queries retain the ordinary path.

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Enhance tiflash's table scan filtering performance when DATE/DATETIME/TIMESTAMP defaults to future times

Summary by CodeRabbit

  • New Features

    • Added optional trim min-max indexing for DATE, DATETIME, and TIMESTAMP data.
    • Improved rough-set filtering for eligible temporal equality, IN, and range predicates.
    • Added conservative fallback handling to preserve query correctness.
    • Added observability metrics for filtering, index selection, and corrections.
    • Added compatibility support for reading data with or without trim-index metadata.
  • Documentation

    • Added design documentation covering trim min-max indexing, compatibility, validation, and rollout considerations.
  • Tests

    • Added coverage for index persistence, temporal predicate normalization, fallback behavior, compatibility, and end-to-end filtering.

Signed-off-by: JaySon-Huang <tshent@qq.com>
Add ColumnStat field 105, pack-mark accessors, trim subfile naming, and
default-off read/write settings so Readers can safely ignore or fall back
without changing ordinary min-max behavior.
Build ordinary and trim indexes in one pack scan for V3 MyDate/MyDateTime
columns, and persist .trim.idx only when trimmed outliers exist.
Normalize temporal ranges into DateRange, select trim indexes per DMFile stored E, and apply conservative low/high flag corrections in roughCheck.
@ti-chi-bot

ti-chi-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot Bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. labels Jul 15, 2026
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • ✅ Review completed - (🔄 Check again to review again)
📝 Walkthrough

Walkthrough

DeltaMerge adds optional temporal trim min-max indexes for date-like columns, including metadata persistence, DMFile writing and reading, query-domain planning, rough-check correction, configuration propagation, compatibility handling, tests, metrics, and a design specification.

Changes

Temporal trim min-max indexing

Layer / File(s) Summary
Trim metadata and file layout
dbms/src/Interpreters/Settings.h, dbms/src/Storages/DeltaMerge/File/..., dbms/src/Storages/DeltaMerge/dtpb/dmfile.proto
Adds trim settings, protobuf metadata, optional ColumnStat fields, trim-index filenames, cache keys, encryption paths, and metadata handling.
Trim index representation and writing
dbms/src/Storages/DeltaMerge/Index/..., dbms/src/Storages/DeltaMerge/File/DMFileWriter.*
Adds pack-mark handling, temporal bounds, trim metadata validation, combined ordinary/trim pack generation, and separate trim index subfiles.
Temporal query-domain planning
dbms/src/Storages/DeltaMerge/Filter/..., dbms/src/Storages/DeltaMerge/FilterParser/...
Adds temporal query domains, DateRange, trim-preferred index requests, predicate normalization, eligibility checks, and conservative rough-check correction.
Trim index loading and setting propagation
dbms/src/Storages/DeltaMerge/File/DMFilePackFilter.*, dbms/src/Storages/DeltaMerge/Segment.*, dbms/src/Storages/StorageDisaggregatedRemote.cpp
Propagates trim-read configuration and loads, validates, caches, or falls back from trim indexes during pack filtering.
Compatibility tests, metrics, and design specification
dbms/src/Storages/DeltaMerge/tests/*, dbms/src/Storages/tests/gtest_filter_parser.cpp, dbms/src/Common/TiFlashMetrics.h, docs/design/*
Adds metadata, serialization, writing, query normalization, rough-check, end-to-end filtering tests, trim metrics, and the trim min-max design specification.

Estimated code review effort: 5 (Critical) | ~120 minutes

Poem

I’m a rabbit with bounds in my den,
Trimming old sentinels again.
Packs mark low, high, and null,
Queries hop through the index hull.
With tests and metadata neatly spun,
Temporal filtering now has fun!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 13.24% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes implement optional trim min-max indexing for DATE/DATETIME/TIMESTAMP with persistence, fallback, eligibility checks, and tests, matching #10989.
Out of Scope Changes check ✅ Passed I don't see unrelated code changes; the diff is centered on the trim min-max feature, supporting tests, metrics, and docs.
Title check ✅ Passed The title accurately summarizes the main change: adding trim min-max indexes for temporal rough-set filtering.
Description check ✅ Passed The description matches the template and includes problem summary, implementation details, checklist, side effects, and release note.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ti-chi-bot ti-chi-bot Bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jul 15, 2026
Prevent same-column OR branches from incorrectly sharing a loaded trim
index when only some query domains are trim-eligible, avoiding false
None pack pruning.
Gate trim range normalization behind dt_enable_trim_minmax_read, keep
original operators when bounds cannot be parsed, and never return All
for an empty DateRange domain.
Signed-off-by: JaySon-Huang <tshent@qq.com>
@JaySon-Huang
JaySon-Huang marked this pull request as ready for review July 16, 2026 08:32

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (6)
dbms/src/Storages/DeltaMerge/Index/TrimMinMaxIndex.h (1)

22-22: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Include the prescribed explicit-width type header.

Line 22 should use Core/Types.h rather than relying on the legacy type header.

Proposed fix
-#include <common/types.h>
+#include <Core/Types.h>

As per coding guidelines, explicit-width types must come from dbms/src/Core/Types.h.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@dbms/src/Storages/DeltaMerge/Index/TrimMinMaxIndex.h` at line 22, Replace the
legacy common types include in TrimMinMaxIndex.h with the prescribed
Core/Types.h header, ensuring explicit-width types are sourced from the standard
Core type definitions.

Source: Coding guidelines

dbms/src/Storages/DeltaMerge/tests/gtest_dm_trim_minmax_index.cpp (1)

784-820: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Make this test distinguish trim from ordinary filtering.

The current [2020, 2021] query yields Some with the ordinary min-max index too, so EXPECT_NE(r, All) passes even if trim loading is broken.

Use an in-range gap such as [2050, 2051], then assert:

  • trim read disabled: Some
  • trim read enabled: None
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@dbms/src/Storages/DeltaMerge/tests/gtest_dm_trim_minmax_index.cpp` around
lines 784 - 820, The test PackFilterUsesTrimWhenReadEnabled must distinguish
trim behavior from ordinary min-max filtering. Change the query range to an
in-range gap such as [2050, 2051], add or reuse a scan with
enable_trim_minmax_read disabled and assert its pack result is Some, then keep
the enabled scan and assert its result is None rather than merely not All.
dbms/src/Storages/DeltaMerge/Index/MinMaxIndex.cpp (1)

108-147: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Variable naming convention mismatch with guidelines.

While the introduced variables align with the historical snake_case style used heavily throughout this repository, the coding guidelines prescribe camelCase for variables. Consider refactoring the variables in these blocks to camelCase to comply with the project standards.

  • dbms/src/Storages/DeltaMerge/Index/MinMaxIndex.cpp#L108-L147: Rename pack_mark, has_value, allowed_mask, min_idx, max_idx, and trimmed_mask to camelCase.
  • dbms/src/Storages/DeltaMerge/Index/MinMaxIndex.cpp#L184-L195: Rename pack_mark to camelCase.
  • dbms/src/Storages/DeltaMerge/Index/MinMaxIndex.cpp#L214-L217: Rename pack_marks and has_value_marks to camelCase.
  • dbms/src/Storages/DeltaMerge/Index/MinMaxIndex.h#L35-L38: Rename pack_marks_ and has_value_marks_ to camelCase.
  • dbms/src/Storages/DeltaMerge/Index/MinMaxIndex.h#L169-L171: Rename pack_marks and has_value_marks to camelCase.
  • dbms/src/Storages/DeltaMerge/File/DMFileWriter.h#L106-L110: Rename trim_minmaxes, trim_lower, and trim_upper to camelCase.
  • dbms/src/Storages/DeltaMerge/File/DMFileWriter.h#L131-L143: Rename enable_trim_minmax_write to camelCase.
  • dbms/src/Storages/DeltaMerge/File/DMFileWriter.cpp#L116-L124: Rename can_trim and do_index_stream to camelCase.
  • dbms/src/Storages/DeltaMerge/File/DMFileWriter.cpp#L133-L139: Rename do_index_stream to camelCase.
  • dbms/src/Storages/DeltaMerge/File/DMFileWriter.cpp#L224-L239: Rename effective_del_mark to camelCase.
  • dbms/src/Storages/DeltaMerge/File/DMFileWriter.cpp#L366-L395: Rename trim_index_bytes to camelCase.

As per coding guidelines:

Method and variable names should use camelCase (e.g., readBlock, totalBytes)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@dbms/src/Storages/DeltaMerge/Index/MinMaxIndex.cpp` around lines 108 - 147,
Rename the listed variables and member variables to camelCase while preserving
behavior and updating every declaration, definition, reference, and call site:
in dbms/src/Storages/DeltaMerge/Index/MinMaxIndex.cpp ranges 108-147, 184-195,
and 214-217; dbms/src/Storages/DeltaMerge/Index/MinMaxIndex.h ranges 35-38 and
169-171; dbms/src/Storages/DeltaMerge/File/DMFileWriter.h ranges 106-110 and
131-143; and dbms/src/Storages/DeltaMerge/File/DMFileWriter.cpp ranges 116-124,
133-139, 224-239, and 366-395. Specifically convert pack_mark, has_value,
allowed_mask, min_idx, max_idx, trimmed_mask, pack_marks, has_value_marks,
pack_marks_, has_value_marks_, trim_minmaxes, trim_lower, trim_upper,
enable_trim_minmax_write, can_trim, do_index_stream, effective_del_mark, and
trim_index_bytes to camelCase.

Source: Coding guidelines

dbms/src/Storages/tests/gtest_filter_parser.cpp (1)

459-460: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use fmt::format for string construction.

These lines construct queries using string concatenation. As per coding guidelines, C++ code should prefer fmt::format for string construction, similar to the other test cases further down in this file.

  • dbms/src/Storages/tests/gtest_filter_parser.cpp#L459-L460: Refactor this concatenation to use fmt::format.
  • dbms/src/Storages/tests/gtest_filter_parser.cpp#L484-L485: Refactor this concatenation to use fmt::format.
  • dbms/src/Storages/tests/gtest_filter_parser.cpp#L509-L510: Refactor this concatenation to use fmt::format.
♻️ Proposed refactors for all affected sites

For dbms/src/Storages/tests/gtest_filter_parser.cpp#L459-L460:

-        const auto query = String("select * from default.t_111 where col_timestamp > cast_string_datetime('")
-            + datetime + String("')");
+        const auto query = fmt::format("select * from default.t_111 where col_timestamp > cast_string_datetime('{}')", datetime);

For dbms/src/Storages/tests/gtest_filter_parser.cpp#L484-L485:

-        const auto query = String("select * from default.t_111 where col_timestamp > cast_string_datetime('")
-            + datetime + String("')");
+        const auto query = fmt::format("select * from default.t_111 where col_timestamp > cast_string_datetime('{}')", datetime);

For dbms/src/Storages/tests/gtest_filter_parser.cpp#L509-L510:

-        const auto query = String("select * from default.t_111 where col_timestamp > cast_string_datetime('")
-            + datetime + String("')");
+        const auto query = fmt::format("select * from default.t_111 where col_timestamp > cast_string_datetime('{}')", datetime);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@dbms/src/Storages/tests/gtest_filter_parser.cpp` around lines 459 - 460,
Replace the query string concatenation in
dbms/src/Storages/tests/gtest_filter_parser.cpp at lines 459-460, 484-485, and
509-510 with fmt::format, preserving each query’s existing text and datetime
substitution.

Source: Coding guidelines

dbms/src/Storages/DeltaMerge/Filter/RSOperator.h (1)

145-155: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

Avoid copying elements when appending vectors.

Since child->getIndexRequests() returns RSIndexRequests by value, you can move its elements into reqs instead of copying them. RSIndexRequest contains an std::optional<DateQueryDomain>, which dynamically allocates its std::vector<Field>, so moving avoids unnecessary allocations.

♻️ Proposed refactor
     RSIndexRequests getIndexRequests() override
     {
         RSIndexRequests reqs;
         for (const auto & child : children)
         {
             auto child_reqs = child->getIndexRequests();
-            reqs.insert(reqs.end(), child_reqs.begin(), child_reqs.end());
+            reqs.insert(reqs.end(), std::make_move_iterator(child_reqs.begin()), std::make_move_iterator(child_reqs.end()));
         }
         return reqs;
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@dbms/src/Storages/DeltaMerge/Filter/RSOperator.h` around lines 145 - 155,
Update RSOperator::getIndexRequests to move elements from each temporary
child_reqs into reqs when appending, using move-aware range insertion while
preserving the existing aggregation behavior.
docs/design/2026-07-14-trim-minmax-for-date-types.md (1)

513-513: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Escape pipe characters in Markdown tables.

The || operator inside the inline code block is interpreted as a table column delimiter by some Markdown parsers and linters, resulting in "Too many cells" rendering issues. Consider using or instead to ensure the table renders correctly across all tools.

♻️ Proposed refactor
-| Equality / IN / bounded range with `Q ⊆ E` | false | `has_trimmed_low || has_trimmed_high` |
+| Equality / IN / bounded range with `Q ⊆ E` | false | `has_trimmed_low or has_trimmed_high` |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/design/2026-07-14-trim-minmax-for-date-types.md` at line 513, Update the
table entry for “Equality / IN / bounded range with Q ⊆ E” to replace the
inline-code `||` operator with `or`, preserving the existing condition meaning
while preventing Markdown table parsing issues.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@dbms/src/Storages/DeltaMerge/Filter/RSOperator.h`:
- Around line 145-155: Update RSOperator::getIndexRequests to move elements from
each temporary child_reqs into reqs when appending, using move-aware range
insertion while preserving the existing aggregation behavior.

In `@dbms/src/Storages/DeltaMerge/Index/MinMaxIndex.cpp`:
- Around line 108-147: Rename the listed variables and member variables to
camelCase while preserving behavior and updating every declaration, definition,
reference, and call site: in dbms/src/Storages/DeltaMerge/Index/MinMaxIndex.cpp
ranges 108-147, 184-195, and 214-217;
dbms/src/Storages/DeltaMerge/Index/MinMaxIndex.h ranges 35-38 and 169-171;
dbms/src/Storages/DeltaMerge/File/DMFileWriter.h ranges 106-110 and 131-143; and
dbms/src/Storages/DeltaMerge/File/DMFileWriter.cpp ranges 116-124, 133-139,
224-239, and 366-395. Specifically convert pack_mark, has_value, allowed_mask,
min_idx, max_idx, trimmed_mask, pack_marks, has_value_marks, pack_marks_,
has_value_marks_, trim_minmaxes, trim_lower, trim_upper,
enable_trim_minmax_write, can_trim, do_index_stream, effective_del_mark, and
trim_index_bytes to camelCase.

In `@dbms/src/Storages/DeltaMerge/Index/TrimMinMaxIndex.h`:
- Line 22: Replace the legacy common types include in TrimMinMaxIndex.h with the
prescribed Core/Types.h header, ensuring explicit-width types are sourced from
the standard Core type definitions.

In `@dbms/src/Storages/DeltaMerge/tests/gtest_dm_trim_minmax_index.cpp`:
- Around line 784-820: The test PackFilterUsesTrimWhenReadEnabled must
distinguish trim behavior from ordinary min-max filtering. Change the query
range to an in-range gap such as [2050, 2051], add or reuse a scan with
enable_trim_minmax_read disabled and assert its pack result is Some, then keep
the enabled scan and assert its result is None rather than merely not All.

In `@dbms/src/Storages/tests/gtest_filter_parser.cpp`:
- Around line 459-460: Replace the query string concatenation in
dbms/src/Storages/tests/gtest_filter_parser.cpp at lines 459-460, 484-485, and
509-510 with fmt::format, preserving each query’s existing text and datetime
substitution.

In `@docs/design/2026-07-14-trim-minmax-for-date-types.md`:
- Line 513: Update the table entry for “Equality / IN / bounded range with Q ⊆
E” to replace the inline-code `||` operator with `or`, preserving the existing
condition meaning while preventing Markdown table parsing issues.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 80025a71-60f0-42c1-9527-1cbd354a2b5b

📥 Commits

Reviewing files that changed from the base of the PR and between 4b2815a and c1f3ebd.

📒 Files selected for processing (39)
  • dbms/src/Interpreters/Settings.h
  • dbms/src/Storages/DeltaMerge/File/ColumnStat.h
  • dbms/src/Storages/DeltaMerge/File/DMFile.cpp
  • dbms/src/Storages/DeltaMerge/File/DMFile.h
  • dbms/src/Storages/DeltaMerge/File/DMFileBlockInputStream.cpp
  • dbms/src/Storages/DeltaMerge/File/DMFileBlockInputStream.h
  • dbms/src/Storages/DeltaMerge/File/DMFileBlockOutputStream.cpp
  • dbms/src/Storages/DeltaMerge/File/DMFileMeta.cpp
  • dbms/src/Storages/DeltaMerge/File/DMFileMetaV2.cpp
  • dbms/src/Storages/DeltaMerge/File/DMFileMetaV2.h
  • dbms/src/Storages/DeltaMerge/File/DMFilePackFilter.cpp
  • dbms/src/Storages/DeltaMerge/File/DMFilePackFilter.h
  • dbms/src/Storages/DeltaMerge/File/DMFileUtil.cpp
  • dbms/src/Storages/DeltaMerge/File/DMFileUtil.h
  • dbms/src/Storages/DeltaMerge/File/DMFileWriter.cpp
  • dbms/src/Storages/DeltaMerge/File/DMFileWriter.h
  • dbms/src/Storages/DeltaMerge/Filter/DateQueryDomain.cpp
  • dbms/src/Storages/DeltaMerge/Filter/DateQueryDomain.h
  • dbms/src/Storages/DeltaMerge/Filter/DateRange.h
  • dbms/src/Storages/DeltaMerge/Filter/Equal.h
  • dbms/src/Storages/DeltaMerge/Filter/In.h
  • dbms/src/Storages/DeltaMerge/Filter/PushDownFilter.cpp
  • dbms/src/Storages/DeltaMerge/Filter/RSOperator.cpp
  • dbms/src/Storages/DeltaMerge/Filter/RSOperator.h
  • dbms/src/Storages/DeltaMerge/FilterParser/FilterParser.cpp
  • dbms/src/Storages/DeltaMerge/FilterParser/FilterParser.h
  • dbms/src/Storages/DeltaMerge/Index/MinMaxIndex.cpp
  • dbms/src/Storages/DeltaMerge/Index/MinMaxIndex.h
  • dbms/src/Storages/DeltaMerge/Index/RSIndex.h
  • dbms/src/Storages/DeltaMerge/Index/TrimMinMaxIndex.cpp
  • dbms/src/Storages/DeltaMerge/Index/TrimMinMaxIndex.h
  • dbms/src/Storages/DeltaMerge/Segment.cpp
  • dbms/src/Storages/DeltaMerge/Segment.h
  • dbms/src/Storages/DeltaMerge/dtpb/dmfile.proto
  • dbms/src/Storages/DeltaMerge/tests/gtest_dm_meta_version.cpp
  • dbms/src/Storages/DeltaMerge/tests/gtest_dm_trim_minmax_index.cpp
  • dbms/src/Storages/StorageDisaggregatedRemote.cpp
  • dbms/src/Storages/tests/gtest_filter_parser.cpp
  • docs/design/2026-07-14-trim-minmax-for-date-types.md

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
dbms/src/Storages/DeltaMerge/File/DMFileBlockOutputStream.cpp (1)

29-34: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Propagate dt_enable_trim_minmax into DMFileWriter::Options

DMFileWriter::addStreams only builds trim-minmax indexes when options.enable_trim_minmax_write is true, but this call site leaves it at the default false. Pass context.getSettingsRef().dt_enable_trim_minmax here so writers actually emit the trim artifacts that readers expect.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@dbms/src/Storages/DeltaMerge/File/DMFileBlockOutputStream.cpp` around lines
29 - 34, Update the DMFileWriter::Options construction in
DMFileBlockOutputStream to pass context.getSettingsRef().dt_enable_trim_minmax
as enable_trim_minmax_write, ensuring addStreams creates the expected
trim-minmax indexes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@dbms/src/Storages/DeltaMerge/File/DMFileBlockOutputStream.cpp`:
- Around line 29-34: Update the DMFileWriter::Options construction in
DMFileBlockOutputStream to pass context.getSettingsRef().dt_enable_trim_minmax
as enable_trim_minmax_write, ensuring addStreams creates the expected
trim-minmax indexes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: fcd98fa9-8ed4-489c-a453-1fd670a76b11

📥 Commits

Reviewing files that changed from the base of the PR and between c1f3ebd and 73caf04.

📒 Files selected for processing (12)
  • dbms/src/Interpreters/Settings.h
  • dbms/src/Storages/DeltaMerge/File/DMFileBlockInputStream.cpp
  • dbms/src/Storages/DeltaMerge/File/DMFileBlockInputStream.h
  • dbms/src/Storages/DeltaMerge/File/DMFileBlockOutputStream.cpp
  • dbms/src/Storages/DeltaMerge/File/DMFilePackFilter.cpp
  • dbms/src/Storages/DeltaMerge/File/DMFilePackFilter.h
  • dbms/src/Storages/DeltaMerge/Filter/PushDownFilter.cpp
  • dbms/src/Storages/DeltaMerge/Index/TrimMinMaxIndex.cpp
  • dbms/src/Storages/DeltaMerge/Segment.cpp
  • dbms/src/Storages/DeltaMerge/Segment.h
  • dbms/src/Storages/DeltaMerge/tests/gtest_dm_trim_minmax_index.cpp
  • dbms/src/Storages/StorageDisaggregatedRemote.cpp
🚧 Files skipped from review as they are similar to previous changes (10)
  • dbms/src/Storages/DeltaMerge/Segment.h
  • dbms/src/Storages/StorageDisaggregatedRemote.cpp
  • dbms/src/Storages/DeltaMerge/File/DMFileBlockInputStream.cpp
  • dbms/src/Storages/DeltaMerge/Filter/PushDownFilter.cpp
  • dbms/src/Storages/DeltaMerge/File/DMFileBlockInputStream.h
  • dbms/src/Storages/DeltaMerge/Segment.cpp
  • dbms/src/Storages/DeltaMerge/File/DMFilePackFilter.h
  • dbms/src/Storages/DeltaMerge/tests/gtest_dm_trim_minmax_index.cpp
  • dbms/src/Storages/DeltaMerge/Index/TrimMinMaxIndex.cpp
  • dbms/src/Storages/DeltaMerge/File/DMFilePackFilter.cpp

@JaySon-Huang
JaySon-Huang force-pushed the jayson/trim_datetime_minmax_index_mv branch from 73caf04 to 3dd7261 Compare July 16, 2026 14:55

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@dbms/src/Storages/DeltaMerge/File/DMFileWriter.cpp`:
- Line 392: Update TrimMinMax::makeDefaultProps to persist the supplied pack
count via set_pack_count before returning the default properties. Ensure the
metadata created by the DMFileWriter call includes dmfile->getPacks(), allowing
readers to validate and load non-empty trim indexes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 3746cbc8-080b-4371-87a5-3d60a40b1608

📥 Commits

Reviewing files that changed from the base of the PR and between 73caf04 and 3dd7261.

📒 Files selected for processing (20)
  • dbms/src/Interpreters/Settings.h
  • dbms/src/Storages/DeltaMerge/File/ColumnStat.h
  • dbms/src/Storages/DeltaMerge/File/DMFileBlockInputStream.cpp
  • dbms/src/Storages/DeltaMerge/File/DMFileBlockInputStream.h
  • dbms/src/Storages/DeltaMerge/File/DMFileBlockOutputStream.cpp
  • dbms/src/Storages/DeltaMerge/File/DMFilePackFilter.cpp
  • dbms/src/Storages/DeltaMerge/File/DMFilePackFilter.h
  • dbms/src/Storages/DeltaMerge/File/DMFileUtil.cpp
  • dbms/src/Storages/DeltaMerge/File/DMFileUtil.h
  • dbms/src/Storages/DeltaMerge/File/DMFileWriter.cpp
  • dbms/src/Storages/DeltaMerge/File/DMFileWriter.h
  • dbms/src/Storages/DeltaMerge/Filter/DateRange.h
  • dbms/src/Storages/DeltaMerge/Filter/PushDownFilter.cpp
  • dbms/src/Storages/DeltaMerge/Index/TrimMinMaxIndex.cpp
  • dbms/src/Storages/DeltaMerge/Segment.cpp
  • dbms/src/Storages/DeltaMerge/Segment.h
  • dbms/src/Storages/DeltaMerge/tests/gtest_dm_meta_version.cpp
  • dbms/src/Storages/DeltaMerge/tests/gtest_dm_trim_minmax_index.cpp
  • dbms/src/Storages/StorageDisaggregatedRemote.cpp
  • dbms/src/Storages/tests/gtest_filter_parser.cpp
🚧 Files skipped from review as they are similar to previous changes (17)
  • dbms/src/Storages/DeltaMerge/File/DMFileUtil.cpp
  • dbms/src/Storages/DeltaMerge/File/DMFileUtil.h
  • dbms/src/Interpreters/Settings.h
  • dbms/src/Storages/DeltaMerge/File/DMFileBlockInputStream.cpp
  • dbms/src/Storages/StorageDisaggregatedRemote.cpp
  • dbms/src/Storages/DeltaMerge/Segment.h
  • dbms/src/Storages/DeltaMerge/File/DMFileBlockInputStream.h
  • dbms/src/Storages/DeltaMerge/File/DMFileBlockOutputStream.cpp
  • dbms/src/Storages/DeltaMerge/File/DMFilePackFilter.h
  • dbms/src/Storages/DeltaMerge/Filter/DateRange.h
  • dbms/src/Storages/tests/gtest_filter_parser.cpp
  • dbms/src/Storages/DeltaMerge/Segment.cpp
  • dbms/src/Storages/DeltaMerge/File/DMFilePackFilter.cpp
  • dbms/src/Storages/DeltaMerge/tests/gtest_dm_meta_version.cpp
  • dbms/src/Storages/DeltaMerge/Index/TrimMinMaxIndex.cpp
  • dbms/src/Storages/DeltaMerge/tests/gtest_dm_trim_minmax_index.cpp
  • dbms/src/Storages/DeltaMerge/File/ColumnStat.h

Comment thread dbms/src/Storages/DeltaMerge/File/DMFileWriter.cpp
Signed-off-by: JaySon-Huang <tshent@qq.com>
@JaySon-Huang
JaySon-Huang force-pushed the jayson/trim_datetime_minmax_index_mv branch from 3dd7261 to 99b9016 Compare July 16, 2026 15:10
@JaySon-Huang JaySon-Huang changed the title [WIP] Storages: introduce trim min-max index for DATE/DATETIME/TIMESTAMP rough set filtering Jul 17, 2026
@ti-chi-bot ti-chi-bot Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 17, 2026
Signed-off-by: JaySon-Huang <tshent@qq.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
dbms/src/Storages/DeltaMerge/tests/gtest_dm_trim_minmax_index.cpp (1)

158-171: 🗄️ Data Integrity & Integration | 🔵 Trivial | 🏗️ Heavy lift

Exercise an actual legacy protobuf reader instead of manually clearing the field.

Using the current generated dtpb::ColumnStat and calling clear_trim_minmax_index() does not verify that an old reader can parse and rewrite field 105 or tolerate the additional merged subfile. Add a legacy-schema fixture or serialized old-reader round trip; retain this case separately to test fallback after metadata loss.

Based on PR objectives, old-reader and old-version metadata-rewrite compatibility must be validated.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@dbms/src/Storages/DeltaMerge/tests/gtest_dm_trim_minmax_index.cpp` around
lines 158 - 171, Replace the manual clear_trim_minmax_index() simulation in this
test with a legacy-schema fixture or serialized round trip using a protobuf
definition that omits field 105 and the additional merged subfile, then parse
and rewrite the bytes before calling ColumnStat::mergeFromProto. Keep this
scenario separate from the existing metadata-loss fallback test, which should
continue explicitly validating behavior after trim metadata is removed.
dbms/src/Storages/DeltaMerge/Index/TrimMinMaxIndex.cpp (1)

282-282: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use explicit width type UInt8.

For consistency with pack_marks (PaddedPODArray<UInt8>) and to adhere to the coding guidelines, use UInt8 instead of unsigned char.

♻️ Proposed refactor
-    for (unsigned char pack_mark : pack_marks)
+    for (UInt8 pack_mark : pack_marks)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@dbms/src/Storages/DeltaMerge/Index/TrimMinMaxIndex.cpp` at line 282, Update
the range-based loop over pack_marks in the surrounding index logic to declare
pack_mark as UInt8 instead of unsigned char, preserving the existing iteration
behavior and matching pack_marks’ element type.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/design/2026-07-14-trim-minmax-for-date-types.md`:
- Around line 607-615: Replace the single dt_enable_trim_minmax setting with
independent write and read rollout controls: one governing trim-index generation
by writers and one governing trim metadata/subfile consumption by readers.
Update the documented enabled/disabled behavior and rollout sequence to support
write-first/read-later deployment and independent read rollback, including the
corresponding PreferTrim temporal-range normalization behavior.

---

Nitpick comments:
In `@dbms/src/Storages/DeltaMerge/Index/TrimMinMaxIndex.cpp`:
- Line 282: Update the range-based loop over pack_marks in the surrounding index
logic to declare pack_mark as UInt8 instead of unsigned char, preserving the
existing iteration behavior and matching pack_marks’ element type.

In `@dbms/src/Storages/DeltaMerge/tests/gtest_dm_trim_minmax_index.cpp`:
- Around line 158-171: Replace the manual clear_trim_minmax_index() simulation
in this test with a legacy-schema fixture or serialized round trip using a
protobuf definition that omits field 105 and the additional merged subfile, then
parse and rewrite the bytes before calling ColumnStat::mergeFromProto. Keep this
scenario separate from the existing metadata-loss fallback test, which should
continue explicitly validating behavior after trim metadata is removed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 171ba54e-0792-44ee-858d-ecadc1fe5944

📥 Commits

Reviewing files that changed from the base of the PR and between 99b9016 and c637776.

📒 Files selected for processing (18)
  • dbms/src/Common/TiFlashMetrics.h
  • dbms/src/Interpreters/Settings.h
  • dbms/src/Storages/DeltaMerge/File/DMFileBlockOutputStream.cpp
  • dbms/src/Storages/DeltaMerge/File/DMFilePackFilter.cpp
  • dbms/src/Storages/DeltaMerge/File/DMFilePackFilter.h
  • dbms/src/Storages/DeltaMerge/File/DMFileWriter.h
  • dbms/src/Storages/DeltaMerge/Filter/DateQueryDomain.cpp
  • dbms/src/Storages/DeltaMerge/Filter/DateQueryDomain.h
  • dbms/src/Storages/DeltaMerge/Filter/DateRange.h
  • dbms/src/Storages/DeltaMerge/Filter/Equal.h
  • dbms/src/Storages/DeltaMerge/Filter/In.h
  • dbms/src/Storages/DeltaMerge/Filter/RSOperator.h
  • dbms/src/Storages/DeltaMerge/Index/MinMaxIndex.cpp
  • dbms/src/Storages/DeltaMerge/Index/TrimMinMaxIndex.cpp
  • dbms/src/Storages/DeltaMerge/Index/TrimMinMaxIndex.h
  • dbms/src/Storages/DeltaMerge/tests/gtest_dm_trim_minmax_index.cpp
  • dbms/src/Storages/tests/gtest_filter_parser.cpp
  • docs/design/2026-07-14-trim-minmax-for-date-types.md
🚧 Files skipped from review as they are similar to previous changes (12)
  • dbms/src/Storages/DeltaMerge/File/DMFileWriter.h
  • dbms/src/Storages/DeltaMerge/Filter/Equal.h
  • dbms/src/Storages/DeltaMerge/File/DMFilePackFilter.h
  • dbms/src/Storages/DeltaMerge/Filter/DateQueryDomain.h
  • dbms/src/Interpreters/Settings.h
  • dbms/src/Storages/DeltaMerge/Filter/DateRange.h
  • dbms/src/Storages/DeltaMerge/Index/TrimMinMaxIndex.h
  • dbms/src/Storages/DeltaMerge/Filter/In.h
  • dbms/src/Storages/DeltaMerge/Filter/DateQueryDomain.cpp
  • dbms/src/Storages/DeltaMerge/Filter/RSOperator.h
  • dbms/src/Storages/DeltaMerge/File/DMFilePackFilter.cpp
  • dbms/src/Storages/DeltaMerge/Index/MinMaxIndex.cpp

Comment thread docs/design/2026-07-14-trim-minmax-for-date-types.md
Convert missing column types to Unsupported at parse time, and guard getIndexRequests/getRSIndex against empty Attr.type.
Signed-off-by: JaySon-Huang <tshent@qq.com>
…policy.

Cover NULL/delete/empty packs and DATE/DATETIME/TIMESTAMP temporal cases; document that invalid MergedSubFileInfo must throw rather than soft-fallback.
Unify DateRange/Equal/In on shared packs and cover AllNull for {NULL,2021}.
Cover != / NOT / OR / CAST with no PreferTrim, and out-of-E ranges that stay ineligible.
Keep the RSResult matrix on non-nullable indexes and isolate AllNull; replace unsupported cast SQL with a bitand stand-in.
Signed-off-by: JaySon-Huang <tshent@qq.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>
@ti-chi-bot ti-chi-bot Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Jul 21, 2026
Comment thread dbms/src/Interpreters/Settings.h Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
dbms/src/Storages/tests/gtest_filter_parser.cpp (1)

1068-1129: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider reusing generateRsOperator via an injectable attr-creator.

This test re-implements ~40 lines of generateRsOperator's setup (compile → traverse → build DAGQueryInfoparseDAGQuery) only to swap in a creator that always returns an empty Attr.type. Extracting an optional AttrCreatorByColumnID parameter on the helper would let this test call it directly and keep the two paths from drifting.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@dbms/src/Storages/tests/gtest_filter_parser.cpp` around lines 1068 - 1129,
Refactor the test setup to reuse generateRsOperator instead of duplicating query
compilation, executor traversal, DAGQueryInfo construction, and parseDAGQuery
calls. Add an optional injectable AttrCreatorByColumnID parameter to
generateRsOperator, defaulting to its existing creator, then pass the empty-type
creator from MissingAttrTypeBecomesUnsupported while preserving the current
unsupported-operator assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@dbms/src/Storages/tests/gtest_filter_parser.cpp`:
- Around line 1068-1129: Refactor the test setup to reuse generateRsOperator
instead of duplicating query compilation, executor traversal, DAGQueryInfo
construction, and parseDAGQuery calls. Add an optional injectable
AttrCreatorByColumnID parameter to generateRsOperator, defaulting to its
existing creator, then pass the empty-type creator from
MissingAttrTypeBecomesUnsupported while preserving the current
unsupported-operator assertions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 9df83f3e-0993-4f05-989b-d648a826238e

📥 Commits

Reviewing files that changed from the base of the PR and between 99b9016 and 3782282.

📒 Files selected for processing (20)
  • dbms/src/Common/TiFlashMetrics.h
  • dbms/src/Interpreters/Settings.h
  • dbms/src/Storages/DeltaMerge/File/DMFileBlockOutputStream.cpp
  • dbms/src/Storages/DeltaMerge/File/DMFilePackFilter.cpp
  • dbms/src/Storages/DeltaMerge/File/DMFilePackFilter.h
  • dbms/src/Storages/DeltaMerge/File/DMFileWriter.h
  • dbms/src/Storages/DeltaMerge/Filter/DateQueryDomain.cpp
  • dbms/src/Storages/DeltaMerge/Filter/DateQueryDomain.h
  • dbms/src/Storages/DeltaMerge/Filter/DateRange.h
  • dbms/src/Storages/DeltaMerge/Filter/Equal.h
  • dbms/src/Storages/DeltaMerge/Filter/In.h
  • dbms/src/Storages/DeltaMerge/Filter/Not.h
  • dbms/src/Storages/DeltaMerge/Filter/RSOperator.h
  • dbms/src/Storages/DeltaMerge/FilterParser/FilterParser.cpp
  • dbms/src/Storages/DeltaMerge/Index/MinMaxIndex.cpp
  • dbms/src/Storages/DeltaMerge/Index/TrimMinMaxIndex.cpp
  • dbms/src/Storages/DeltaMerge/Index/TrimMinMaxIndex.h
  • dbms/src/Storages/DeltaMerge/tests/gtest_dm_trim_minmax_index.cpp
  • dbms/src/Storages/tests/gtest_filter_parser.cpp
  • docs/design/2026-07-14-trim-minmax-for-date-types.md
🚧 Files skipped from review as they are similar to previous changes (18)
  • dbms/src/Interpreters/Settings.h
  • dbms/src/Storages/DeltaMerge/File/DMFileBlockOutputStream.cpp
  • dbms/src/Storages/DeltaMerge/Filter/DateQueryDomain.h
  • dbms/src/Common/TiFlashMetrics.h
  • dbms/src/Storages/DeltaMerge/FilterParser/FilterParser.cpp
  • dbms/src/Storages/DeltaMerge/Filter/Equal.h
  • dbms/src/Storages/DeltaMerge/File/DMFilePackFilter.h
  • dbms/src/Storages/DeltaMerge/File/DMFileWriter.h
  • dbms/src/Storages/DeltaMerge/Filter/DateQueryDomain.cpp
  • dbms/src/Storages/DeltaMerge/Filter/DateRange.h
  • dbms/src/Storages/DeltaMerge/Filter/RSOperator.h
  • dbms/src/Storages/DeltaMerge/Filter/In.h
  • docs/design/2026-07-14-trim-minmax-for-date-types.md
  • dbms/src/Storages/DeltaMerge/Index/TrimMinMaxIndex.cpp
  • dbms/src/Storages/DeltaMerge/Index/TrimMinMaxIndex.h
  • dbms/src/Storages/DeltaMerge/File/DMFilePackFilter.cpp
  • dbms/src/Storages/DeltaMerge/tests/gtest_dm_trim_minmax_index.cpp
  • dbms/src/Storages/DeltaMerge/Index/MinMaxIndex.cpp

@ti-chi-bot ti-chi-bot Bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jul 21, 2026
close pingcap#10923\n\ntest: cover dropped table schema sync race
test: remove flaky alter drop table case
tests: use failpoint instead\n\nSigned-off-by: JaySon-Huang <tshent@qq.com>
M(SettingFloat, dt_bg_gc_delta_delete_ratio_to_trigger_gc, 0.3, "Trigger segment's gc when the ratio of delta delete range to stable exceeds this ratio.") \
M(SettingBool, dt_enable_logical_split, false, "Enable logical split or not in DeltaTree Engine.") \
M(SettingBool, dt_enable_rough_set_filter, true, "Whether to parse where expression as Rough Set Index filter or not.") \
M(SettingBool, dt_enable_trim_minmax, true, "Whether to generate and use trim min-max index for DATE/DATETIME/TIMESTAMP Rough Set filtering.") \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enabled by default?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Set default to true for this feature branch after discussed with @windtalker so that user don't need to add extra param when doing POC using this branch.

@JaySon-Huang

Copy link
Copy Markdown
Contributor Author

/test pull-unit-test

@ti-chi-bot ti-chi-bot Bot added lgtm approved and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jul 21, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

[LGTM Timeline notifier]

Timeline:

  • 2026-07-21 04:18:20.202781983 +0000 UTC m=+1292086.238877039: ☑️ agreed by yudongusa.
  • 2026-07-21 06:24:26.91896343 +0000 UTC m=+1299652.955058476: ☑️ agreed by JinheLin.

@ti-chi-bot

ti-chi-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

@yongman: adding LGTM is restricted to approvers and reviewers in OWNERS files.

Details

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot

ti-chi-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JinheLin, yongman, yudongusa

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@JaySon-Huang

Copy link
Copy Markdown
Contributor Author

/test pull-unit-test

@ti-chi-bot
ti-chi-bot Bot merged commit 1bab99c into pingcap:feature/release-8.5-materialized-view Jul 21, 2026
5 checks passed
@JaySon-Huang
JaySon-Huang deleted the jayson/trim_datetime_minmax_index_mv branch July 21, 2026 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants