HeartSaVioR opened a new pull request #27872: [SPARK-31115][SQL] Provide config 
to avoid using switch statement in generated code to avoid Janino bug
URL: https://github.com/apache/spark/pull/27872
 
 
   ### What changes were proposed in this pull request?
   
   This patch provides a new SQL configuration 
(`spark.sql.codegen.useSwitchStatement`) to avoid using `switch` statement in 
generated code, which may open the possibility to hit the known Janino bug 
janino-compiler/janino#113.
   
   `switch` statement is being used by default, as it makes the generated code 
more concise, and also more efficient in point of performance's view. Once the 
end users' query fails due to the Janino bug, end users can turn off the new 
configuration to change the generated code to use `if ~ else if ~ else` and try 
running their query again. 
   
   The conditions are below:
   
   * The generated code contains 'switch' statement.
   * Exception message contains 'Operand stack inconsistent at offset xxx: 
Previous size 1, now 0'.
   
   ### Why are the changes needed?
   
   We got some report on failure on user's query which Janino throws error on 
compiling generated code. The issue is here: janino-compiler/janino#113 It 
contains the information of generated code, symptom (error), and analysis of 
the bug, so please refer the link for more details.
   
   We provided the patch to Janino via janino-compiler/janino#114 and Janino 
3.1.1 was released which contains the patch, but we figured out lots of unit 
tests fail once we apply Janino 3.1.1.
   
   We have asked about releasing Janino 3.0.16 to Janino maintainer, but given 
there's no guarantee to get it, we'd be better to have our own workaround.
   
   ### Does this PR introduce any user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   New UT. Confirmed that changing `SQLConf.CODEGEN_USE_SWITCH_STATEMENT.key` 
to `"true"` made the new test fail.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to