expression: enable SHA2 function pushdown to TiKV#67088
expression: enable SHA2 function pushdown to TiKV#67088ti-chi-bot[bot] merged 2 commits intopingcap:masterfrom
Conversation
TiKV already implements SHA2 in its coprocessor (impl_encryption.rs), and TiDB has the PbCode mapping (ScalarFuncSig_SHA2) and distsql deserialization support, but SHA2 was missing from the scalarExprSupportedByTiKV allowlist. This adds it alongside the existing MD5 and SHA1 entries. Verified with tiup playground that all hash lengths (0/224/256/384/512) and all column types (varchar, char, text, blob, binary, int, bigint, double, decimal, datetime, date, time, bit, enum, set) produce identical results between TiDB-local and TiKV-pushdown evaluation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@joechenrh I've received your pull request and will start the review. I'll conduct a thorough review covering code quality, potential issues, and implementation details. ⏳ This process typically takes 10-30 minutes depending on the complexity of the changes. ℹ️ Learn more details on Pantheon AI. |
|
Hi @joechenrh. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with I understand the commands that are listed here. DetailsInstructions 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. |
📝 WalkthroughWalkthroughAdds Changes
Sequence Diagram(s)mermaid Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment Tip CodeRabbit can generate a title for your PR based on the changes.Add |
|
/ok-to-test |
|
/retest |
|
/retest-required |
|
/retest |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #67088 +/- ##
================================================
- Coverage 77.7026% 77.4730% -0.2296%
================================================
Files 2016 1936 -80
Lines 551903 540997 -10906
================================================
- Hits 428843 419127 -9716
- Misses 121314 121841 +527
+ Partials 1746 29 -1717
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
tests/integrationtest/t/planner/core/casetest/pushdown/push_down.test
Outdated
Show resolved
Hide resolved
tests/integrationtest/r/planner/core/casetest/pushdown/push_down.result
Outdated
Show resolved
Hide resolved
Change the integration test from a SELECT projection to a WHERE predicate so the explain plan shows Selection cop[tikv] with sha2(), proving the function is actually evaluated on TiKV. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ingress-bot
left a comment
There was a problem hiding this comment.
This review was generated by AI and should be verified by a human reviewer.
Manual follow-up is recommended before merge.
Summary
- Total findings: 3
- Inline comments: 3
- Summary-only findings (no inline anchor): 0
Findings (highest risk first)
⚠️ [Major] (1)
- SHA2 TiKV pushdown is enabled without mixed-version capability gating (pkg/expression/infer_pushdown.go:244; mixed-version rolling-upgrade path with new TiDB and not-yet-upgraded TiKV nodes)
🟡 [Minor] (1)
- New SHA2 pushdown coverage does not validate semantic parity or boundary modes (tests/integrationtest/t/planner/core/casetest/pushdown/push_down.test:38; tests/integrationtest/r/planner/core/casetest/pushdown/push_down.result:126)
🧹 [Nit] (1)
- Pushdown category comment no longer matches grouped function semantics (pkg/expression/infer_pushdown.go:243-244)
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: windtalker, zanmato1984 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
|
/retest |
1 similar comment
|
/retest |
What problem does this PR solve?
Issue Number: close #67087
Problem Summary: The
SHA2function is not pushed down to TiKV for coprocessor evaluation, even though TiKV already implements it. This causes unnecessary data transfer when SHA2 is used in WHERE clauses.Related: pingcap/tidb-tools#886 (from customer)
What changed and how does it work?
Added
ast.SHA2to thescalarExprSupportedByTiKVallowlist inpkg/expression/infer_pushdown.go, alongside the already-supportedMD5andSHA1.All infrastructure was already in place:
SHA2implemented incomponents/tidb_query_expr/src/impl_encryption.rs(SHA-0/224/256/384/512)ScalarFuncSig_SHA2defined in protobufbuiltin_encryption.go) and distsql deserialization (distsql_builtin.go) already existedCheck List
Tests
Side effects
Documentation
Release note
Summary by CodeRabbit
New Features
Tests