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

tidb_cast to Int16 is not supported #1727

Closed
lilinghai opened this issue Apr 6, 2021 · 3 comments
Closed

tidb_cast to Int16 is not supported #1727

lilinghai opened this issue Apr 6, 2021 · 3 comments
Labels
plan bugs related to plans severity/major type/bug The issue is confirmed as a bug.

Comments

@lilinghai
Copy link

Mini reproduce:

CREATE TABLE `t2` (
  `a` smallint NOT NULL,
  PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */
);
insert into t2 values(1);
select a,max(a) from t2 group by a having max(a)>1; -- expect successfully; but got ERROR 1105 (HY000): tidb_cast to Int16 is not supported

Cluster version:
Release Version: v4.0.0-beta.2-2561-g9c75cfa4e
Edition: Community
Git Commit Hash: 9c75cfa4e2bbb854ab90562ecec0409f84a989b0
Git Branch: master
UTC Build Time: 2021-04-02 18:50:29
GoVersion: go1.13
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false

@fzhedu
Copy link
Contributor

fzhedu commented Apr 9, 2021

similar to pingcap/tidb#23907

@windtalker
Copy link
Contributor

Both TiFlash and MySQL does not support cast as Int16, the plan generated by TiDB is not as expected.

mysql> explain select a,max(a) from t2 group by a having max(a)>1;
+------------------------------+---------+--------------+---------------+-------------------------------------------------------------------------------------------+
| id                           | estRows | task         | access object | operator info                                                                             |
+------------------------------+---------+--------------+---------------+-------------------------------------------------------------------------------------------+
| Projection_7                 | 0.80    | root         |               | test.t2.a, Column#2                                                                       |
| └─Projection_8               | 0.80    | root         |               | test.t2.a, cast(test.t2.a, smallint(6))->Column#2, cast(test.t2.a, smallint(6))->Column#2 |
|   └─TableReader_14           | 0.80    | root         |               | data:Selection_13                                                                         |
|     └─Selection_13           | 0.80    | cop[tiflash] |               | gt(cast(test.t2.a, smallint(6)), 1)                                                       |
|       └─TableFullScan_12     | 1.00    | cop[tiflash] | table:t2      | keep order:false, stats:pseudo                                                            |
+------------------------------+---------+--------------+---------------+-------------------------------------------------------------------------------------------+

The implicit cast cast(test.t2.a, smallint(6)) should be something like cast(test.t2.a, bigint(20))

@windtalker
Copy link
Contributor

close it as duplicated with pingcap/tidb#23907

@fzhedu fzhedu added the plan bugs related to plans label Nov 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plan bugs related to plans severity/major type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

3 participants