[ 
https://issues.apache.org/jira/browse/FLINK-38468?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jie Cheng updated FLINK-38468:
------------------------------
    Description: 
I have two flink tasks, using 1.12 and 1.18 respectively. flinksql contains the 
COALESCE function. I found that the performance of 1.18 is not as good as that 
of 1.12

 

use sql
{code:java}
  select COALESCE(level_type, GET_JSON_OBJECT(order_n_tuple, '$.level_type'), 
'0') as level_type {code}
1.12 will convert COALESCE to case when. When the first parameter is not null, 
the GET_JSON_OBJECT function will not be called, while 1.18 will always call 
the GET_JSON_OBJECT function

 

1.12 Plan
{code:java}
Calc(select=[CASE(IS NOT NULL(level_type), CAST(level_type), IS NOT 
NULL(GET_JSON_OBJECT(order_n_tuple, _UTF-16LE'$.level_type')), 
CAST(GET_JSON_OBJECT(order_n_tuple, _UTF-16LE'$.level_type')), 
_UTF-16LE'0':VARCHAR(2147483647) CHARACTER SET "UTF-16LE") AS level_type]) +- 
TableSourceScan(table=[[default_catalog, default_database, shadow_source]], 
fields=[order_n_tuple, level_type])
 {code}
 

1.18 Plan
{code:java}
Calc(select=[COALESCE(level_type, GET_JSON_OBJECT(order_n_tuple, 
'$.level_type'), '0') AS level_type])
+- TableSourceScan(table=[[default_catalog, default_database, shadow_source]], 
fields=[order_n_tuple, level_type])
 

{code}

  was:
I have two flink tasks, using 1.12 and 1.18 respectively. flinksql contains the 
COALESCE function. I found that the performance of 1.18 is not as good as that 
of 1.12

 

use sql
{code:java}
  select COALESCE(level_type, GET_JSON_OBJECT(order_n_tuple, '$.level_type'), 
'0') as level_type {code}
1.12 will convert COALESCE to case when. When the first parameter is not null, 
the GET_JSON_OBJECT function will not be called, while 1.18 will always call 
the GET_JSON_OBJECT function

 

1.12 Plan
{code:java}
Calc(select=[CASE(IS NOT NULL(level_type), CAST(level_type), IS NOT 
NULL(GET_JSON_OBJECT(order_n_tuple, _UTF-16LE'$.level_type')), 
CAST(GET_JSON_OBJECT(order_n_tuple, _UTF-16LE'$.level_type')), 
_UTF-16LE'0':VARCHAR(2147483647) CHARACTER SET "UTF-16LE") AS level_type]) +- 
TableSourceScan(table=[[default_catalog, default_database, shadow_source]], 
fields=[order_n_tuple, level_type])
 {code}
 

1.18 Plan
{code:java}
Calc(select=[COALESCE(level_type, GET_JSON_OBJECT(order_n_tuple, 
'$.level_type'), '0') AS level_type])
+- TableSourceScan(table=[[default_catalog, default_database, shadow_source]], 
fields=[order_n_tuple, level_type])
 {code}


> Performance drops when the coalesce parameter includes functions
> ----------------------------------------------------------------
>
>                 Key: FLINK-38468
>                 URL: https://issues.apache.org/jira/browse/FLINK-38468
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / Planner
>    Affects Versions: 1.18.0
>            Reporter: Jie Cheng
>            Priority: Major
>             Fix For: 2.2.0
>
>         Attachments: 1_12_StreamExecCalc$10.java, 1_18_StreamExecCalc$10.java
>
>
> I have two flink tasks, using 1.12 and 1.18 respectively. flinksql contains 
> the COALESCE function. I found that the performance of 1.18 is not as good as 
> that of 1.12
>  
> use sql
> {code:java}
>   select COALESCE(level_type, GET_JSON_OBJECT(order_n_tuple, '$.level_type'), 
> '0') as level_type {code}
> 1.12 will convert COALESCE to case when. When the first parameter is not 
> null, the GET_JSON_OBJECT function will not be called, while 1.18 will always 
> call the GET_JSON_OBJECT function
>  
> 1.12 Plan
> {code:java}
> Calc(select=[CASE(IS NOT NULL(level_type), CAST(level_type), IS NOT 
> NULL(GET_JSON_OBJECT(order_n_tuple, _UTF-16LE'$.level_type')), 
> CAST(GET_JSON_OBJECT(order_n_tuple, _UTF-16LE'$.level_type')), 
> _UTF-16LE'0':VARCHAR(2147483647) CHARACTER SET "UTF-16LE") AS level_type]) +- 
> TableSourceScan(table=[[default_catalog, default_database, shadow_source]], 
> fields=[order_n_tuple, level_type])
>  {code}
>  
> 1.18 Plan
> {code:java}
> Calc(select=[COALESCE(level_type, GET_JSON_OBJECT(order_n_tuple, 
> '$.level_type'), '0') AS level_type])
> +- TableSourceScan(table=[[default_catalog, default_database, 
> shadow_source]], fields=[order_n_tuple, level_type])
>  
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to