Unexpected error: "expression eq(test_0.tb5.c4, cast(test_0.tb2.c0, json BINARY)) cannot be pushed down "
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
Please answer these questions before submitting your issue. Thanks!
### 1. Minimal reproduce step (Required)
```sql
DROP TABLE IF EXISTS tb2;
DROP TABLE IF EXISTS tb5;
CREATE TABLE tb2 (c0 FLOAT NOT NULL);
CREATE TABLE tb5 (c4 JSON NOT NULL);
INSERT INTO tb5 (c4) VALUES ('{"name": "aeEl9", "data": {"id": 199}}');
ALTER TABLE tb2 SET TIFLASH REPLICA 1;
ALTER TABLE tb5 SET TIFLASH REPLICA 1;
-- tikv: expression eq(test_0.tb5.c4, cast(test_0.tb2.c0, json BINARY)) cannot be pushed down
SELECT 1 FROM tb5 AS t3 WHERE (EXISTS (SELECT 1 FROM tb2 AS t0 WHERE (t3.c4 IN (SELECT t0.c0 FROM tb2 AS t0))));
```
### 2. What did you expect to see? (Required)
```
[HY000][1815] expression eq(test_0.tb5.c4, cast(test_0.tb2.c0, json BINARY)) cannot be pushed down
```
### 3. What did you see instead (Required)
This query runs successfully on both TiDB (using TiFlash) and MySQL
```
-- tiflash: success
SELECT 1 FROM tb5 AS t3 WHERE (EXISTS (SELECT /*+ read_from_storage(tiflash[t0]) */ 1 FROM tb2 AS t0 WHERE (t3.c4 IN (SELECT /*+ read_from_storage(tiflash[t0]) */ t0.c0 FROM tb2 AS t0))));
```
mysql result
```
mysql> DROP TABLE IF EXISTS tb2;
Query OK, 0 rows affected, 1 warning (0.006 sec)
mysql> DROP TABLE IF EXISTS tb5;
Query OK, 0 rows affected, 1 warning (0.001 sec)
mysql> CREATE TABLE tb2 (c0 FLOAT NOT NULL);
Query OK, 0 rows affected (0.014 sec)
mysql> CREATE TABLE tb5 (c4 JSON NOT NULL);
Query OK, 0 rows affected (0.009 sec)
mysql> INSERT INTO tb5 (c4) VALUES ('{"name": "aeEl9", "data": {"id": 199}}');
Query OK, 1 row affected (0.003 sec)
mysql>
mysql> SELECT 1 FROM tb5 AS t3 WHERE (EXISTS (SELECT 1 FROM tb2 AS t0 WHERE (t3.c4 IN (SELECT t0.c0 FROM tb2 AS t0))));
Empty set (0.004 sec)
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.4.6 |
+-----------+
1 row in set (0.001 sec)
```
### 4. What is your TiDB version? (Required)
```
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v8.5.3
Edition: Community
Git Commit Hash: dc2548aac79a712265e831cff2a3a896bc0a5a38
Git Branch: HEAD
UTC Build Time: 2025-07-31 13:54:59
GoVersion: go1.23.6
Race Enabled: false
Check Table Before Drop: false
Store: tikv |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
```
Contributor guide
Assessment
This issue has not been assessed yet.