pingcap / tiflash

The analytical engine for TiDB and TiDB Cloud. Try free: https://tidbcloud.com/free-trial
https://docs.pingcap.com/tidb/stable/tiflash-overview
Apache License 2.0
948 stars 410 forks source link

Union all pushdown unsupported scalar function CastJsonAsJson #3561

Open wshwsh12 opened 2 years ago

wshwsh12 commented 2 years ago

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

use test;
drop table if exists t;
drop table if exists t1;
create table t (a json not null, b json, c varchar(20));
create table t1 (a json, b json not null, c double);
alter table t set tiflash replica 1;
alter table t1 set tiflash replica 1;
set tidb_enforce_mpp=1; set tidb_isolation_read_engines='tiflash';
select count(*) from (select a , b from t union all select a , b from t1) tt;

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

3. What did you see instead (Required)

ERROR 1105 (HY000): other error for mpp stream: DB::TiFlashException: CastJsonAsJson is not supported.

[tidb]> desc select count(*) from (select a , b from t union all select a , b from t1) tt;
+------------------------------------+----------+--------------+---------------+----------------------------------------------------+
| id                                 | estRows  | task         | access object | operator info                                      |
+------------------------------------+----------+--------------+---------------+----------------------------------------------------+
| HashAgg_37                         | 1.00     | root         |               | funcs:count(Column#12)->Column#11                  |
| └─TableReader_39                   | 1.00     | root         |               | data:ExchangeSender_38                             |
|   └─ExchangeSender_38              | 1.00     | cop[tiflash] |               | ExchangeType: PassThrough                          |
|     └─HashAgg_14                   | 1.00     | cop[tiflash] |               | funcs:count(1)->Column#12                          |
|       └─Union_36                   | 20000.00 | cop[tiflash] |               |                                                    |
|         ├─Projection_64            | 10000.00 | cop[tiflash] |               | cast(test.t.a, json BINARY)->Column#9, test.t.b    |
|         │ └─TableFullScan_22       | 10000.00 | cop[tiflash] | table:t       | keep order:false, stats:pseudo                     |
|         └─Projection_65            | 10000.00 | cop[tiflash] |               | test.t1.a, cast(test.t1.b, json BINARY)->Column#10 |
|           └─TableFullScan_29       | 10000.00 | cop[tiflash] | table:t1      | keep order:false, stats:pseudo                     |
+------------------------------------+----------+--------------+---------------+----------------------------------------------------+
9 rows in set (0.001 sec)

4. What is your TiFlash version? (Required)

master

XuHuaiyu commented 2 years ago

Not reproducible for now.

XuHuaiyu commented 2 years ago

Fixed by https://github.com/pingcap/tidb/pull/31576

XuHuaiyu commented 2 years ago

Further verification is needed, the PR above might not be a common fix for this type of problem.

SeaRise commented 10 months ago

cast json as json has been supported in tiflash now, can this issue be closed?