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
946 stars 409 forks source link

Avoid unnecessary implicit cast in TiFlash #5514

Open windtalker opened 2 years ago

windtalker commented 2 years ago

Background

Type deduction systems in TiFlash and TiDB are independent with each other, that means even for the same function with the same input arguments, the result type may be different in TiDB and TiFlash, in order to make TiFlash compatible with TiDB, after compiling a function, TiFlash will check if the return type is the same as TiDB, if not, an implicit cast will be added to force aligning the type.

Enhancement

These implicit cast brings a lot of redundant computation, we need to avoid this by improving the native type deduction system in TiDB/TiFlash

This is an umbrella issue for all the enhancement related to avoiding unnecessary implicit cast.

xzhangxian1008 commented 2 years ago

Affected tpch sql: q1 q2 q5 q6 q9 q11 q12 q13 q14 q15 q16 q19 q20 q22

Functions whose type needs to cast: