Skip to content

Commit e9b7bb0

Browse files
authored
Use decimal data type for the TRUNCATE argument to address the Truncated incorrect INTEGER value: '' warning (#18561)
1 parent 404732b commit e9b7bb0

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

predicate-push-down.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,18 @@ In addition, This SQL statement has an inner join executed, and the `ON` conditi
7474
### Case 4: predicates that are not supported by storage layers cannot be pushed down
7575

7676
```sql
77-
create table t(id int primary key, a varchar(10) not null);
78-
desc select * from t where truncate(a, " ") = '1';
79-
+-------------------------+----------+-----------+---------------+---------------------------------------------------+
80-
| id | estRows | task | access object | operator info |
81-
+-------------------------+----------+-----------+---------------+---------------------------------------------------+
82-
| Selection_5 | 8000.00 | root | | eq(truncate(cast(test.t.a, double BINARY), 0), 1) |
83-
| └─TableReader_7 | 10000.00 | root | | data:TableFullScan_6 |
84-
| └─TableFullScan_6 | 10000.00 | cop[tikv] | table:t | keep order:false, stats:pseudo |
85-
+-------------------------+----------+-----------+---------------+---------------------------------------------------+
77+
create table t(id int primary key, a decimal(10, 2) not null);
78+
desc select * from t where truncate(a, 0) = 1;
79+
+-------------------------+----------+-----------+---------------+--------------------------------+
80+
| id | estRows | task | access object | operator info |
81+
+-------------------------+----------+-----------+---------------+--------------------------------+
82+
| Selection_5 | 8000.00 | root | | eq(truncate(test.t.a, 0), 1) |
83+
| └─TableReader_7 | 10000.00 | root | | data:TableFullScan_6 |
84+
| └─TableFullScan_6 | 10000.00 | cop[tikv] | table:t | keep order:false, stats:pseudo |
85+
+-------------------------+----------+-----------+---------------+--------------------------------+
8686
```
8787

88-
In this query, there is a predicate `truncate(a, " ") = '1'`.
88+
In this query, there is a predicate `truncate(a, 0) = 1`.
8989

9090
From the `explain` results, you can see that the predicate is not pushed down to TiKV for calculation. This is because the TiKV coprocessor does not support the built-in function `truncate`.
9191

0 commit comments

Comments
 (0)