Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some error appears in explain results when pruning partition for TiFlash #25852

Closed
qw4990 opened this issue Jun 30, 2021 · 2 comments
Closed
Assignees
Labels
component/tablepartition This issue is related to Table Partition of TiDB. severity/moderate sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@qw4990
Copy link
Contributor

qw4990 commented Jun 30, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

CREATE TABLE `t` (
	`create_time` datetime NOT NULL,
	`id` varchar(64) NOT NULL,
	PRIMARY KEY (`id`, `create_time`)
) ENGINE = InnoDB CHARSET = utf8mb4 COLLATE utf8mb4_bin
PARTITION BY RANGE (TO_DAYS(`create_time`)) (
	PARTITION `p_min` VALUES LESS THAN (738322),
	PARTITION `p20210616` VALUES LESS THAN (738323),
	PARTITION `p20210617` VALUES LESS THAN (738324),
	PARTITION `p20210618` VALUES LESS THAN (738325),
	PARTITION `p20210619` VALUES LESS THAN (738326),
	PARTITION `p20210620` VALUES LESS THAN (738327),
	PARTITION `p20210621` VALUES LESS THAN (738328),
	PARTITION `p20210622` VALUES LESS THAN (738329),
	PARTITION `p20210623` VALUES LESS THAN (738330),
	PARTITION `p20210624` VALUES LESS THAN (738331),
	PARTITION `p20210625` VALUES LESS THAN (738332),
	PARTITION `p20210626` VALUES LESS THAN (738333),
	PARTITION `p20210627` VALUES LESS THAN (738334),
	PARTITION `p20210628` VALUES LESS THAN (738335),
	PARTITION `p20210629` VALUES LESS THAN (738336),
	PARTITION `p20210630` VALUES LESS THAN (738337)
);
alter table t set tiflash replica 1;

set tidb_partition_prune_mode = 'dynamic';
set tidb_opt_agg_push_down = 1;
set tidb_isolation_read_engines = 'tiflash';
explain select count(*) from t where t.create_time>='2021-06-25 00:00:00' and t.create_time<='2021-06-26 23:59:59';

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

Partition Pruning can work correctly.

3. What did you see instead (Required)

Some error appears in the result: error[planner:1054]Unknown column 'create_time' in 'expression'

mysql> explain select count(*) from t where t.create_time>='2021-06-25 00:00:00' and t.create_time<='2021-06-26 23:59:59';
+--------------------------------+----------+-------------------+-----------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------+
| id                             | estRows  | task              | access object                                                                     | operator info                                                                                          |
+--------------------------------+----------+-------------------+-----------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------+
| HashAgg_19                     | 1.00     | root              |                                                                                   | funcs:count(Column#6)->Column#4                                                                        |
| └─TableReader_21               | 1.00     | root              | partition pruning error[planner:1054]Unknown column 'create_time' in 'expression' | data:ExchangeSender_20                                                                                 |
|   └─ExchangeSender_20          | 1.00     | batchCop[tiflash] |                                                                                   | ExchangeType: PassThrough                                                                              |
|     └─HashAgg_8                | 1.00     | batchCop[tiflash] |                                                                                   | funcs:count(1)->Column#6                                                                               |
|       └─Selection_18           | 250.00   | batchCop[tiflash] |                                                                                   | ge(test.t.create_time, 2021-06-25 00:00:00.000000), le(test.t.create_time, 2021-06-26 23:59:59.000000) |
|         └─TableFullScan_17     | 10000.00 | batchCop[tiflash] | table:t                                                                           | keep order:false, stats:pseudo                                                                         |
+--------------------------------+----------+-------------------+-----------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------+
6 rows in set (0.00 sec)

4. What is your TiDB version? (Required)

v5.1

@qw4990 qw4990 added type/bug The issue is confirmed as a bug. sig/planner SIG: Planner severity/moderate labels Jun 30, 2021
@qw4990 qw4990 self-assigned this Jun 30, 2021
@mjonss
Copy link
Contributor

mjonss commented Feb 14, 2022

/component tablepartition

@ti-chi-bot ti-chi-bot added the component/tablepartition This issue is related to Table Partition of TiDB. label Feb 14, 2022
@mjonss
Copy link
Contributor

mjonss commented May 25, 2022

This seems to be fixed, current results:

tidb> explain select count(*) from t where t.create_time>='2021-06-25 00:00:00' and t.create_time<='2021-06-26 23:59:59';
+--------------------------------+----------+--------------+-------------------------------+--------------------------------------------------------------------------------------------------------+
| id                             | estRows  | task         | access object                 | operator info                                                                                          |
+--------------------------------+----------+--------------+-------------------------------+--------------------------------------------------------------------------------------------------------+
| HashAgg_21                     | 1.00     | root         |                               | funcs:count(Column#6)->Column#4                                                                        |
| └─TableReader_23               | 1.00     | root         | partition:p20210625,p20210626 | data:ExchangeSender_22                                                                                 |
|   └─ExchangeSender_22          | 1.00     | mpp[tiflash] |                               | ExchangeType: PassThrough                                                                              |
|     └─HashAgg_9                | 1.00     | mpp[tiflash] |                               | funcs:count(1)->Column#6                                                                               |
|       └─Selection_20           | 250.00   | mpp[tiflash] |                               | ge(test.t.create_time, 2021-06-25 00:00:00.000000), le(test.t.create_time, 2021-06-26 23:59:59.000000) |
|         └─TableFullScan_19     | 10000.00 | mpp[tiflash] | table:t                       | keep order:false, stats:pseudo, PartitionTableScan:true                                                |
+--------------------------------+----------+--------------+-------------------------------+--------------------------------------------------------------------------------------------------------+
6 rows in set (0,00 sec)

tidb> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v6.1.0-alpha
Edition: Community
Git Commit Hash: 7abf6f9696061c6ab6f09cb003282b39014bd067
Git Branch: heads/refs/tags/v6.1.0-alpha
UTC Build Time: 2022-05-24 14:58:32
GoVersion: go1.18.2
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
1 row in set (0,00 sec)

@mjonss mjonss closed this as completed May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/tablepartition This issue is related to Table Partition of TiDB. severity/moderate sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

3 participants