pingcap / pingcap/tidb

expression: support pushing down TRIM to TiKV

Open
#67,520 1 comment 0 reactions 0 assignees View on GitHub
type/enhancement
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Enhancement

`TRIM` is currently not pushed down to TiKV, while related functions such as `LTRIM` and `RTRIM` can already be pushed down.

From the current code and history, `TRIM` appears to have been disabled as part of a broader rollback of high-risk string function pushdown due to correctness concerns. At the same time, TiKV already has the
related execution support for `TRIM`, so the current gap is mainly that TiDB does not allow it to be pushed down.

This issue is to track re-evaluating and restoring `TRIM` pushdown to TiKV.

## Background

- `TRIM` is not pushed down to TiKV today.
- `LTRIM` / `RTRIM` are already supported for TiKV pushdown.
- Historically, `TRIM` was removed together with some other string functions when there were correctness concerns around string function pushdown.
- The rollback context can be found in:
- issue #33391: https://github.com/pingcap/tidb/issues/33391
- PR #33401: https://github.com/pingcap/tidb/pull/33401
- Earlier related history for `TRIM` pushdown can be found in:
- PR #26786: https://github.com/pingcap/tidb/pull/26786
- A more recent example of restoring a string function pushdown capability independently is:
- issue #48170: https://github.com/pingcap/tidb/issues/48170
- PR #49045: https://github.com/pingcap/tidb/pull/49045

## What we want

Support pushing down `TRIM` to TiKV, with correctness as the first priority.

## Scope

This issue is only for `TRIM` pushdown support.

It does **not** aim to restore all previously disabled string function pushdown in one batch.

## Notes

Before enabling it again, we should make sure pushdown and non-pushdown paths return the same results for representative `TRIM` cases.

Contributor guide

Open the contributing guide

Research direction

Start by reading issue #33391, PR #33401, PR #26786, and the independent restoration example in issue #48170 and PR #49045 to understand the pushdown history and correctness concerns. Compare TiDB's pushdown and non-pushdown results for representative TRIM cases, and consider the work complete when TRIM is safely pushed to TiKV with matching results.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sql
Domain
databases, distributed-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.