Yifeng-Wang opened a new issue, #9106:
URL: https://github.com/apache/incubator-gluten/issues/9106

   ### Description
   
   **Description**
   
   Gluten Velox Plan has below fallbacks caused by unsupported functions in 
spark's CharVarcharCodegenUtils. Such static functions are called by wrapping 
within a StaticInvoke, with fallback infos like :
   
   > Not supported to map spark function name to substrait function name: 
staticinvoke(class org.apache.spark.sql.catalyst.util.CharVarcharCodegenUtils, 
StringType, readSidePadding, id#109, 3, true, false, true), class name: 
StaticInvoke.;
   
   or sth like,
   
   > > Not supported to map spark function name to substrait function name: 
staticinvoke(class org.apache.spark.sql.catalyst.util.CharVarcharCodegenUtils, 
StringType, charTypeWriteSideCheck, staticinvoke(class 
org.apache.spark.sql.catalyst.util.CharVarcharCodegenUtils, StringType, 
readSidePadding, id#109, 3, true, false, true), 3, true, false, true), class 
name: StaticInvoke.
   
   The 3 functions in CharVarcharCodegenUtils are charTypeWriteSideCheck, 
varcharTypeWriteSideCheck and readSidePadding(introduced in Spark3.4) in 
org.apache.spark.sql.catalyst.util.CharVarcharCodegenUtils.
   
[CharVarcharCodegenUtils.java](https://github.com/apache/spark/blob/master/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/util/CharVarcharCodegenUtils.java)
   
   ---
   
   
   
   **How to trigger?**
   
   * `charTypeWriteSideCheck`, `varcharTypeWriteSideCheck` get triggered when 
try to insert string into varchar/char columns.
   * `readSidePadding` gets triggered when try to select or do filter 
predicates.
   
   ---
   
   
   
   **The minimum test case  can be given as:**
   
   ```sql
   create table src(id string) stored as parquet;
   create table tgtvarchar(id varchar(3)) stored as parquet;
   create table tgtchar(id char(3)) stored as parquet;
   
   insert into srcchar values ('ab');
   
   insert into tgtvarchar select id from src; -- fallback due to unsuported 
varcharTypeWriteSideCheck
   insert into tgtchar select id from src; -- fallback due to unsuported 
charTypeWriteSideCheck
   
   select id from tgtchar; -- fallback due to unsuported readSidePadding
   ```
   
   ---
   
   **What is the significance?**
   Inserting operations that triggered these functions are common in our users' 
production environments. Read-side padding for CHAR cols is a default behaviour 
since Spark 3.4.
   These fallbacks introduce R2C in the middle of the execution plan, which we 
observed, harms Spark gluten performance. Thus, offloading StaticInvokes 
functions in CharVarcharCodegenUtils to native need to be supported.
   
   ---
   
   
   
   **Describe the solution**
   
   1. Add expr matching pattern in Gluten;
   2. Register these functions and provide implementations in Velox.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to