Skip to content

Support decimal rough set minmax filter - #11020

Merged
ti-chi-bot[bot] merged 7 commits into
pingcap:feature/release-8.5-materialized-viewfrom
windtalker:rough_set_filter_support_decimal
Aug 10, 2026
Merged

Support decimal rough set minmax filter#11020
ti-chi-bot[bot] merged 7 commits into
pingcap:feature/release-8.5-materialized-viewfrom
windtalker:rough_set_filter_support_decimal

Conversation

@windtalker

@windtalker windtalker commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: ref #11031

Problem Summary:

Decimal columns were not supported by rough set min/max filtering. The read-side comparison needs scale-aware decimal comparison, and the write-side must persist ordinary min/max indexes for decimal columns.

What is changed and how it works?

Support decimal rough set minmax filter
  • Add decimal dispatch in min/max rough set check paths.
  • Use existing execution-layer decimal comparison utility for Decimal-vs-Decimal comparisons across physical decimal types and scales.
  • Keep Decimal-vs-non-Decimal comparisons conservative by returning CanNotCompare.
  • Generate ordinary min/max index payloads for decimal columns in DMFileWriter.
  • Add a dev note and regression coverage for decimal min/max filtering and DMFile write-side index generation.

Check List

Tests

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

Manual test:

ninja -C cmake-build-debug dbms/gtests_dbms
./cmake-build-debug/dbms/gtests_dbms --gtest_filter=MinMaxIndexTest.*:MinMaxIndexWriteTest.* > /tmp/minmax_decimal.log 2>&1
git diff --check

Side effects

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

Documentation

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

Release note

Support rough set min/max filter for decimal columns in TiFlash.

Summary by CodeRabbit

  • New Features

    • Added min/max indexing and rough-set filtering for Decimal columns.
    • Enabled scale-aware Decimal comparisons across supported predicates and precisions.
    • Added Decimal index generation when writing data files.
  • Bug Fixes

    • Improved nullable and non-nullable filtering for Decimal values.
    • Preserved conservative handling for unsupported Decimal comparisons.
  • Tests

    • Expanded coverage for persisted indexes, comparisons, nullability, and varying Decimal widths.
  • Documentation

    • Added guidance on Decimal filtering behavior and supported comparisons.

@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. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Aug 7, 2026
@coderabbitai

coderabbitai Bot commented Aug 7, 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
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR adds decimal support to DMFile min-max index creation and rough-set predicate evaluation. It also updates parser classification, comparison logic, tests, and the design note.

Changes

Decimal min-max filtering

Layer / File(s) Summary
Scale-aware decimal comparison
dbms/src/Storages/DeltaMerge/Index/ValueComparison.h
ValueComparison classifies decimal fields and compares decimal operands with DecimalComparison using both operand scales.
Decimal index generation and predicate dispatch
dbms/src/Storages/DeltaMerge/File/DMFileWriter.cpp, dbms/src/Storages/DeltaMerge/FilterParser/FilterParser.cpp, dbms/src/Storages/DeltaMerge/Index/MinMaxIndex.cpp
DMFileWriter generates indexes for decimal columns. FilterParser accepts decimal types. MinMaxIndex reads decimal data from ColumnDecimal and dispatches decimal types across IN, comparison, equality, and nullable checks.
Decimal index and predicate regression coverage
dbms/src/Storages/tests/gtest_filter_parser.cpp, dbms/src/Storages/DeltaMerge/tests/gtest_dm_minmax_index.cpp
Tests cover decimal filter parsing, decimal DMFile persistence, nullable packs, predicates, cross-precision comparisons, and unsupported integer-versus-decimal comparisons.
Decimal filtering design note
docs/note/rough_set_filter_support_decimal.md
The note documents decimal representation, supported predicates, nullable semantics, comparison behavior, tests, and validation commands.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant FilterParser
  participant DMFileWriter
  participant MinMaxIndex
  participant ValueComparison
  FilterParser->>MinMaxIndex: accept TypeDecimal and TypeNewDecimal
  DMFileWriter->>MinMaxIndex: create decimal min-max index
  MinMaxIndex->>MinMaxIndex: read decimal data through ColumnDecimal
  MinMaxIndex->>ValueComparison: compare decimal predicate operands
  ValueComparison->>ValueComparison: apply DecimalComparison with operand scales
Loading

Suggested reviewers: jayson-huang

Poem

I’m a rabbit with bounds in my paws,
Decimal hops now follow the laws.
Min and max stand clear,
Scales compare without fear,
Tests thump approval with soft little claws.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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
Description check ✅ Passed The description covers the problem, implementation, tests, manual validation, side effects, documentation, and release note.
Title check ✅ Passed The title is concise and clearly describes the main change: decimal rough-set min/max filter support.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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.

@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: 2

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

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

Use std::string_view for read-only text parameters.

Change getDecimalField input s and check_results input test_case to std::string_view. Verify that ReadBufferFromString accepts a view, or adapt only the buffer boundary if it does not.

Also applies to: 2307-2313

🤖 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_minmax_index.cpp` around lines
309 - 315, Update getDecimalField and the check_results test_case parameter to
use std::string_view for read-only text inputs. Preserve existing parsing and
result-checking behavior, adapting only the ReadBufferFromString boundary if it
does not accept a view directly.

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/note/rough_set_filter_support_decimal.md`:
- Around line 86-88: Correct the misspelled ValueComparision type to
ValueComparison in every occurrence of the documented comparison calls,
including the referenced sections, so they match the ValueComparison definition.
- Around line 276-286: Correct the focused gtest command in the validation
documentation by removing the nonexistent MinMaxIndexTest.CheckNullEqual filter
and adding MinMaxIndexWriteTest.WriteDecimalMinMaxIndex, while preserving the
other focused test filters.

---

Nitpick comments:
In `@dbms/src/Storages/DeltaMerge/tests/gtest_dm_minmax_index.cpp`:
- Around line 309-315: Update getDecimalField and the check_results test_case
parameter to use std::string_view for read-only text inputs. Preserve existing
parsing and result-checking behavior, adapting only the ReadBufferFromString
boundary if it does not accept a view directly.
🪄 Autofix

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 Plus

Run ID: 76b07d07-0f8d-491c-a792-caa7b50a4537

📥 Commits

Reviewing files that changed from the base of the PR and between d813287 and acda6f4.

📒 Files selected for processing (5)
  • dbms/src/Storages/DeltaMerge/File/DMFileWriter.cpp
  • dbms/src/Storages/DeltaMerge/Index/MinMaxIndex.cpp
  • dbms/src/Storages/DeltaMerge/Index/ValueComparison.h
  • dbms/src/Storages/DeltaMerge/tests/gtest_dm_minmax_index.cpp
  • docs/note/rough_set_filter_support_decimal.md

Comment on lines +86 to +88
```cpp
ValueComparision<Op>::compare(left_field, type, right_value)
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Correct the ValueComparison type name.

Replace ValueComparision with ValueComparison in each occurrence. The current spelling does not match dbms/src/Storages/DeltaMerge/Index/ValueComparison.h.

Also applies to: 154-156, 205-207, 266-270

🤖 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/note/rough_set_filter_support_decimal.md` around lines 86 - 88, Correct
the misspelled ValueComparision type to ValueComparison in every occurrence of
the documented comparison calls, including the referenced sections, so they
match the ValueComparison definition.

Comment thread docs/note/rough_set_filter_support_decimal.md
Comment thread dbms/src/Storages/DeltaMerge/tests/gtest_dm_minmax_index.cpp Outdated
windtalker and others added 2 commits August 10, 2026 08:19
Signed-off-by: xufei <xufeixw@mail.ustc.edu.cn>

@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 (2)
dbms/src/Storages/DeltaMerge/tests/gtest_dm_minmax_index.cpp (2)

66-116: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Rename the new variables to camelCase.

The new fixture uses decimal_col_id, parent_path, file_provider, dm_file, column_data, del_mark, col_data, del_mark_col, check_results, and test_case. Rename them to decimalColId, parentPath, fileProvider, dmFile, columnData, delMark, colData, delMarkColumn, checkResults, and testCase.

As per coding guidelines, method and variable names should use camelCase.

Proposed rename
-    static constexpr ColId decimal_col_id = 100;
+    static constexpr ColId decimalColId = 100;

-    String parent_path;
-    FileProviderPtr file_provider;
+    String parentPath;
+    FileProviderPtr fileProvider;

-        std::vector<std::optional<String>> column_data;
-        std::vector<UInt64> del_mark;
+        std::vector<std::optional<String>> columnData;
+        std::vector<UInt64> delMark;

-        auto col_data = createColumn<Nullable<Decimal64>>(...);
-        auto del_mark_col = createColumn<UInt8>(...);
+        auto colData = createColumn<Nullable<Decimal64>>(...);
+        auto delMarkColumn = createColumn<UInt8>(...);

Update all references to the renamed identifiers.

Also applies to: 2277-2315

🤖 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_minmax_index.cpp` around lines 66
- 116, Rename the newly introduced snake_case variables throughout the
MinMaxIndexWriteTest fixture and its related test code to the specified
camelCase names: decimalColId, parentPath, fileProvider, dmFile, columnData,
delMark, colData, delMarkColumn, checkResults, and testCase. Update every
declaration and reference consistently, including the additional affected test
section.

Source: Coding guidelines


1989-2013: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Validate the restored index contents, not only its size.

WriteDecimalMinMaxIndex checks that index_bytes and the merged sub-file size are non-zero. These checks do not prove that Decimal min/max values deserialize correctly or that the restored index can answer predicates. After DMFile::restore, run a known decimal match and non-match through the same read path used by DMFilePackFilter, or inspect the restored MinMaxIndex directly.

🤖 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_minmax_index.cpp` around lines
1989 - 2013, The WriteDecimalMinMaxIndex test must validate restored Decimal
min/max index behavior, not just non-zero sizes. After DMFile::restore, use the
existing DMFilePackFilter read path or inspect the restored MinMaxIndex to
verify a known matching decimal predicate is accepted and a known non-matching
predicate is rejected, while preserving the current size assertions.
🧹 Nitpick comments (2)
dbms/src/Storages/DeltaMerge/tests/gtest_dm_minmax_index.cpp (2)

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

Rename isNullableDateType to match its scope.

The helper now covers nullable Int64, date/time types, and Decimal64. Rename it to isNullableType and update its call sites.

🤖 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_minmax_index.cpp` around lines
274 - 287, Rename the helper isNullableDateType to isNullableType to reflect
that it handles all nullable test datatypes, including Int64, date/time, and
Decimal64. Update every call site and declaration consistently, without changing
its switch logic or return behavior.

2283-2387: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add negative decimal coverage.

Every Decimal value and threshold in CheckDecimal is non-negative. Add a negative pack and scale-mismatched equality and range checks. This catches sign-sensitive min/max ordering and scale normalization errors.

🤖 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_minmax_index.cpp` around lines
2283 - 2387, Extend the decimal cases in CheckDecimal with a pack containing
negative values and add negative thresholds to equality and range checks.
Include scale-mismatched negative comparisons for checkCmp and checkIn, plus
direct RoughCheck::Cmp assertions, so signed min/max ordering and decimal scale
normalization are exercised while preserving existing positive and null cases.
🤖 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/tests/gtest_dm_minmax_index.cpp`:
- Around line 66-116: Rename the newly introduced snake_case variables
throughout the MinMaxIndexWriteTest fixture and its related test code to the
specified camelCase names: decimalColId, parentPath, fileProvider, dmFile,
columnData, delMark, colData, delMarkColumn, checkResults, and testCase. Update
every declaration and reference consistently, including the additional affected
test section.
- Around line 1989-2013: The WriteDecimalMinMaxIndex test must validate restored
Decimal min/max index behavior, not just non-zero sizes. After DMFile::restore,
use the existing DMFilePackFilter read path or inspect the restored MinMaxIndex
to verify a known matching decimal predicate is accepted and a known
non-matching predicate is rejected, while preserving the current size
assertions.

---

Nitpick comments:
In `@dbms/src/Storages/DeltaMerge/tests/gtest_dm_minmax_index.cpp`:
- Around line 274-287: Rename the helper isNullableDateType to isNullableType to
reflect that it handles all nullable test datatypes, including Int64, date/time,
and Decimal64. Update every call site and declaration consistently, without
changing its switch logic or return behavior.
- Around line 2283-2387: Extend the decimal cases in CheckDecimal with a pack
containing negative values and add negative thresholds to equality and range
checks. Include scale-mismatched negative comparisons for checkCmp and checkIn,
plus direct RoughCheck::Cmp assertions, so signed min/max ordering and decimal
scale normalization are exercised while preserving existing positive and null
cases.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 63af9f60-89bf-45cb-b8be-79398ef684c2

📥 Commits

Reviewing files that changed from the base of the PR and between 772580c and cff8656.

📒 Files selected for processing (2)
  • dbms/src/Storages/DeltaMerge/tests/gtest_dm_minmax_index.cpp
  • docs/note/rough_set_filter_support_decimal.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/note/rough_set_filter_support_decimal.md

Comment thread dbms/src/Storages/DeltaMerge/Index/MinMaxIndex.cpp
Signed-off-by: xufei <xufeixw@mail.ustc.edu.cn>

@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/tests/gtest_filter_parser.cpp (2)

1023-1047: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Cover both decimal type cases and scale-aware literals.

This fixture contains one decimal column definition and whole-number literals only. Add a second case for the other supported decimal type, use fractional literals with different scales, and assert the decoded value or index request domain. The current assertions can pass even if scale propagation is incorrect.

🤖 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 1023 - 1047,
Expand FilterParserTest.DecimalColumn to cover both supported decimal column
types, adding a second fixture with the alternate type metadata. Replace the
current whole-number predicates with fractional literals using different scales,
and assert the decoded decimal values or index request domains so scale
propagation is explicitly validated rather than relying only on operator names
and column IDs.

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

Rename the new C++ identifiers to camelCase.

Rename table_info_json, expect_rs_operator, rs_operator, and expected_name to tableInfoJson, expectRsOperator, rsOperator, and expectedName.

As per coding guidelines, method and variable names in **/*.{cpp,h,hpp} must use camelCase.

Proposed rename
-    const String table_info_json = ...
+    const String tableInfoJson = ...
-    auto expect_rs_operator = [&](const String & query, const String & expected_name) {
-        auto rs_operator = generateRsOperator(table_info_json, query);
+    auto expectRsOperator = [&](const String & query, const String & expectedName) {
+        auto rsOperator = generateRsOperator(tableInfoJson, query);
🤖 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 1026 - 1045,
Rename the identifiers in this test to camelCase: table_info_json to
tableInfoJson, expect_rs_operator to expectRsOperator, rs_operator to
rsOperator, and expected_name to expectedName, updating all references
consistently.

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 `@dbms/src/Storages/tests/gtest_filter_parser.cpp`:
- Around line 1035-1039: In the expect_rs_operator lambda, replace the non-fatal
size check for rs_operator->getColumnIDs() with a fatal assertion so execution
stops before indexing when the collection is empty; retain the existing index
assertion afterward.

---

Nitpick comments:
In `@dbms/src/Storages/tests/gtest_filter_parser.cpp`:
- Around line 1023-1047: Expand FilterParserTest.DecimalColumn to cover both
supported decimal column types, adding a second fixture with the alternate type
metadata. Replace the current whole-number predicates with fractional literals
using different scales, and assert the decoded decimal values or index request
domains so scale propagation is explicitly validated rather than relying only on
operator names and column IDs.
- Around line 1026-1045: Rename the identifiers in this test to camelCase:
table_info_json to tableInfoJson, expect_rs_operator to expectRsOperator,
rs_operator to rsOperator, and expected_name to expectedName, updating all
references consistently.
🪄 Autofix

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 Plus

Run ID: 4d5cb96b-588b-4c74-a8ee-0bf415d8a2f2

📥 Commits

Reviewing files that changed from the base of the PR and between cff8656 and 84e4e8b.

📒 Files selected for processing (2)
  • dbms/src/Storages/DeltaMerge/FilterParser/FilterParser.cpp
  • dbms/src/Storages/tests/gtest_filter_parser.cpp

Comment on lines +1035 to +1039
auto expect_rs_operator = [&](const String & query, const String & expected_name) {
auto rs_operator = generateRsOperator(table_info_json, query);
EXPECT_EQ(rs_operator->name(), expected_name) << rs_operator->toDebugString();
EXPECT_EQ(rs_operator->getColumnIDs().size(), 1);
EXPECT_EQ(rs_operator->getColumnIDs()[0], 5);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 3 \
  'EXPECT_EQ.*getColumnIDs\(\)\.size|getColumnIDs\(\)\[0\]' \
  dbms/src/Storages/tests/gtest_filter_parser.cpp

Repository: pingcap/tiflash

Length of output: 14927


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate GoogleTest defines to show local EXPECT_EQ/ASSERT_EQ semantics.
find . -path '*/gtest*.h' -print -quit
rg -n -C 4 '^`#define` (EXPECT_EQ|ASSERT_EQ)\(' .

Repository: pingcap/tiflash

Length of output: 208


🌐 Web query:

GoogleTest EXPECT_EQ vs ASSERT_EQ semantics nonfatal assertion continues execution

💡 Result:

In GoogleTest, the difference between EXPECT_EQ and ASSERT_EQ lies in how they handle failure within the current function [1][2]. EXPECT_EQ: This is a nonfatal assertion [1][3]. If the assertion fails, it reports a nonfatal failure and allows the current function to continue executing [1][2]. This is useful when you want to report multiple failures within the same test or when the subsequent code does not depend on the result of the assertion [2][4]. ASSERT_EQ: This is a fatal assertion [1][3]. If the assertion fails, it generates a fatal failure and immediately aborts the current function [1][2]. It should be used when it does not make sense to continue the test if the condition fails—for example, if you need to dereference a pointer that must not be null [2][5]. Key Rule of Thumb: Use EXPECT_* assertions as your default choice because they allow the test to continue and reveal more potential errors [2][4]. Only use ASSERT_* when continuing execution after a failure would be inappropriate, such as when it would cause a crash (e.g., a segmentation fault) or when the remaining test logic depends on the failed condition [2][4]. Note that because ASSERT_* returns from the current function, it cannot be used in functions that return a value, as it would cause compilation issues [4]. Regardless of which macro is used, if any assertion in a test fails, the entire test case is considered to have failed [2][5].

Citations:


Use a fatal size assertion before indexing getColumnIDs().

EXPECT_EQ reports a failure but continues execution. If getColumnIDs().size() is 0, the following getColumnIDs()[0] dereferences outside the vector. Use ASSERT_EQ(rs_operator->getColumnIDs().size(), 1) before indexing in expect_rs_operator.

🤖 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 1035 - 1039, In
the expect_rs_operator lambda, replace the non-fatal size check for
rs_operator->getColumnIDs() with a fatal assertion so execution stops before
indexing when the collection is empty; retain the existing index assertion
afterward.

@JaySon-Huang JaySon-Huang left a comment

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.

LGTM

@ti-chi-bot ti-chi-bot Bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Aug 10, 2026
Signed-off-by: xufei <xufeixw@mail.ustc.edu.cn>
@windtalker

Copy link
Copy Markdown
Contributor Author

/hold

@ti-chi-bot ti-chi-bot Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 10, 2026
@ti-chi-bot

ti-chi-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JaySon-Huang, xzhangxian1008

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

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

ti-chi-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

[LGTM Timeline notifier]

Timeline:

  • 2026-08-10 05:56:12.895147042 +0000 UTC m=+3025958.931242108: ☑️ agreed by JaySon-Huang.
  • 2026-08-10 07:53:36.791501745 +0000 UTC m=+3033002.827596831: ☑️ agreed by xzhangxian1008.

Signed-off-by: xufei <xufeixw@mail.ustc.edu.cn>
@windtalker

Copy link
Copy Markdown
Contributor Author

/hold cancel

@ti-chi-bot ti-chi-bot Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 10, 2026
case TiDB::TypeTimestamp: // For timestamp, should take time_zone into consideration while parsing `literal`
return true;
case TiDB::TypeDecimal:
case TiDB::TypeNewDecimal:

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.

Non-blocking: reject statically unsupported mixed-decimal predicates during parsing.

After decimal columns are admitted here, a predicate whose literal is encoded as Int64, Uint64, or Float64 can still be parsed into a normal Equal/Greater/In operator. During roughCheck, ValueComparision then returns CanNotCompare, so every pack becomes conservatively Some. This makes the filter look enabled while providing no pruning, and it may load an index that cannot be used.

Could we detect this in parseTiCompareExpr and create Unsupported when exactly one side is decimal? Checking child.tp() == tipb::ExprType::MysqlDecimal is preferable to relying on literal.field_type(), because the encoded decimal value is the authoritative source for its scale. NULL should remain allowed, including inside IN. For example:

-    bool is_timestamp_column = false;
+    bool is_timestamp_column = false;
+    bool is_decimal_column = false;
     for (const auto & child : expr.children())
     {
         if (isColumnExpr(child))
         {
-            is_timestamp_column = (child.field_type().tp() == TiDB::TypeTimestamp);
+            const auto column_type = child.field_type().tp();
+            is_timestamp_column = (column_type == TiDB::TypeTimestamp);
+            is_decimal_column
+                = column_type == TiDB::TypeDecimal || column_type == TiDB::TypeNewDecimal;
             break;
         }
     }
@@
         else if (isLiteralExpr(child))
         {
             Field value = decodeLiteral(child);
+            const bool is_decimal_literal = child.tp() == tipb::ExprType::MysqlDecimal;
+            if (!value.isNull() && is_decimal_column != is_decimal_literal)
+                return createUnsupported(fmt::format(
+                    "Mixed decimal comparison is not supported, sig={} column_decimal={} literal_type={}",
+                    tipb::ScalarFuncSig_Name(expr.sig()),
+                    is_decimal_column,
+                    tipb::ExprType_Name(child.tp())));

CanNotCompare -> Some should still remain as the runtime safety net for mismatches that are not knowable during parsing.

Source: rule/WINDTALKER-TYPE-002 | Second Opinion

@ti-chi-bot
ti-chi-bot Bot merged commit f5993b2 into pingcap:feature/release-8.5-materialized-view Aug 10, 2026
5 checks passed
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.

3 participants