LiBinfeng
0c39b88804
[Improvement](expr) fold child when const expr not folded (#38493) (#38961)
cherry-pick from master 38493
1. fold child when const expr not folded
2. do not fold function `sleep`
3. move all exceptional expression into shouldSkipFold
before
mysql [test]>explain select sleep(sign(1)*100);
+-----------------------------------------------+
| Explain String(Nereids Planner) |
+-----------------------------------------------+
| PLAN FRAGMENT 0 |
| OUTPUT EXPRS: |
| sleep(cast((sign(1.0) * 100) as INT))[#0] |
| PARTITION: UNPARTITIONED |
| |
| HAS_COLO_PLAN_NODE: false |
| |
| VRESULT SINK |
| MYSQL_PROTOCAL |
| |
| 0:VUNION(32) |
| constant exprs: |
| sleep(CAST((sign(1) * 100) AS int)) |
+-----------------------------------------------+
13 rows in set (15.02 sec)
mysql [test]>select sleep(sign(1)*100);
+-----------------------------------------------------+
| sleep(cast((sign(cast(1 as DOUBLE)) * 100) as INT)) |
+-----------------------------------------------------+
| 1 |
+-----------------------------------------------------+
1 row in set (1 min 55.34 sec)
after
mysql [test]>explain select sleep(sign(1)*100);
+---------------------------------+
| Explain String(Nereids Planner) |
+---------------------------------+
| PLAN FRAGMENT 0 |
| OUTPUT EXPRS: |
| sleep(100)[#0] |
| PARTITION: UNPARTITIONED |
| |
| HAS_COLO_PLAN_NODE: false |
| |
| VRESULT SINK |
| MYSQL_PROTOCAL |
| |
| 0:VUNION(32) |
| constant exprs: |
| sleep(100) |
+---------------------------------+
13 rows in set (0.23 sec)
mysql [test]> select sleep(sign(1)*100);
+-----------------------------------------------------+
| sleep(cast((sign(cast(1 as DOUBLE)) * 100) as INT)) |
+-----------------------------------------------------+
| 1 |
+-----------------------------------------------------+
1 row in set (1 min 40.37 sec)
Co-authored-by: Pxl <pxl290@qq.com>