pingcap / tidb

TiDB - the open-source, cloud-native, distributed SQL database designed for modern applications.
https://pingcap.com
Apache License 2.0
37.42k stars 5.85k forks source link

The Tiflash mode is not supporting for ENUM data type #51097

Open 2b1sh opened 9 months ago

2b1sh commented 9 months ago

Bug Report

I have deployed a TiDB cluster and created a table that having datatype ENUM that is read by Tikv instead of TiFlash

1. Minimal reproduce step (Required)

MySQL [test]> use test;

MySQL [test]> create table user(id int PRIMARY KEY AUTO_INCREMENT,name VARCHAR(20),age INT,gender ENUM('male','female'));

MySQL [test]> alter table user set tiflash replica 1;

MySQL [test]> select * from information_schema.tiflash_replica where table_schema="test" and table_name="user";
+--------------+------------+----------+---------------+-----------------+-----------+----------+
| TABLE_SCHEMA | TABLE_NAME | TABLE_ID | REPLICA_COUNT | LOCATION_LABELS | AVAILABLE | PROGRESS |
+--------------+------------+----------+---------------+-----------------+-----------+----------+
| test         | user       |     7028 |             1 |                 |         1 |        1 |
+--------------+------------+----------+---------------+-----------------+-----------+----------+

MySQL [test]> select @@tidb_enforce_mpp;
+--------------------+
| @@tidb_enforce_mpp |
+--------------------+
|                  1 |
+--------------------+
1 row in set (0.01 sec)

2. What did you expect to see? (Required)

Whenever I filter the select by any other field name the data is loaded by tiflash

MySQL [test]> explain select * from user where age=29;
+-----------------------+---------+--------------+---------------+--------------------------------------------------------------------------+
| id                    | estRows | task         | access object | operator info                                                            |
+-----------------------+---------+--------------+---------------+--------------------------------------------------------------------------+
| TableReader_10        | 10.00   | root         |               | data:TableFullScan_8                                                     |
| └─TableFullScan_8     | 10.00   | cop[tiflash] | table:user    | pushed down filter:eq(test.user.age, 29), keep order:false, stats:pseudo |
+-----------------------+---------+--------------+---------------+--------------------------------------------------------------------------+
2 rows in set, 1 warning (0.00 sec)

I'm Expecting the same for the field that having datatype ENUM.

3. What did you see instead (Required)

Instead i'm getting the results as below. It's not read by the tiflash.

MySQL [test]> explain select * from user where gender='male';
+-------------------------+----------+-----------+---------------+--------------------------------+
| id                      | estRows  | task      | access object | operator info                  |
+-------------------------+----------+-----------+---------------+--------------------------------+
| TableReader_7           | 10.00    | root      |               | data:Selection_6               |
| └─Selection_6           | 10.00    | cop[tikv] |               | eq(test.user.gender, "male")   |
|   └─TableFullScan_5     | 10000.00 | cop[tikv] | table:user    | keep order:false, stats:pseudo |
+-------------------------+----------+-----------+---------------+--------------------------------+
3 rows in set, 2 warnings (0.00 sec)

MySQL [test]> show warnings;
+---------+------+------------------------------------------------------------------------------------------------------------------------------+
| Level   | Code | Message                                                                                                                      |
+---------+------+------------------------------------------------------------------------------------------------------------------------------+
| Warning | 1105 | Expression about 'test.user.gender' can not be pushed to TiFlash because it contains unsupported calculation of type 'enum'. |
| Warning | 1105 | Expression about 'test.user.gender' can not be pushed to TiFlash because it contains unsupported calculation of type 'enum'. |
+---------+------+------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

MySQL [test]> explain select /*+ READ_FROM_STORAGE(TIFLASH[master]) */ * from user where gender='male';
+-------------------------+----------+-----------+---------------+--------------------------------+
| id                      | estRows  | task      | access object | operator info                  |
+-------------------------+----------+-----------+---------------+--------------------------------+
| TableReader_7           | 10.00    | root      |               | data:Selection_6               |
| └─Selection_6           | 10.00    | cop[tikv] |               | eq(test.user.gender, "male")   |
|   └─TableFullScan_5     | 10000.00 | cop[tikv] | table:user    | keep order:false, stats:pseudo |
+-------------------------+----------+-----------+---------------+--------------------------------+
3 rows in set, 2 warnings (0.01 sec)

4. What is your TiDB version? (Required)

MySQL [(none)]> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v7.1.1
Edition: Community
Git Commit Hash: cf441574864be63938524e7dfcf7cc659edc3dd8
Git Branch: heads/refs/tags/v7.1.1
UTC Build Time: 2023-07-19 10:16:40
GoVersion: go1.20.6
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv
1 row in set (0.01 sec)
windtalker commented 9 months ago

It is a known issue, actually TiFlash does not support most calculations on Enum column. So it is kind of expected behavior. The issue is an enhancement request rather than a bug.

SeaRise commented 9 months ago

related issue: https://github.com/pingcap/tiflash/issues/1880