beliefer opened a new pull request #30479:
URL: https://github.com/apache/spark/pull/30479


   ### What changes were proposed in this pull request?
   In Spark, decode(bin, charset) - Decodes the first argument using the second 
argument character set.
   
   Unfortunately this is NOT what any other SQL vendor understands `DECODE` to 
do.
   `DECODE` generally is a short hand for a simple case expression:
   
   ```
   SELECT DECODE(c1, 1, 'Hello', 2, 'World', '!') FROM (VALUES (1), (2), (3)) 
AS T(c1)
   => 
   (Hello),
   (World)
   (!)
   ```
   There are some mainstream database support the syntax.
   **Oracle**
   
https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/DECODE.html#GUID-39341D91-3442-4730-BD34-D3CF5D4701CE
   **Vertica**
   
https://www.vertica.com/docs/9.2.x/HTML/Content/Authoring/SQLReferenceManual/Functions/String/DECODE.htm?tocpath=SQL%20Reference%20Manual%7CSQL%20Functions%7CString%20Functions%7C_____10
   **DB2**
   
https://www.ibm.com/support/knowledgecenter/SSGU8G_14.1.0/com.ibm.sqls.doc/ids_sqs_1447.htm
   **Redshift**
   https://docs.aws.amazon.com/redshift/latest/dg/r_DECODE_expression.html
   
   
   ### Why are the changes needed?
   It is very useful.
   
   
   ### Does this PR introduce _any_ user-facing change?
   Yes
   
   
   ### How was this patch tested?
   Jenkins test.
   


----------------------------------------------------------------
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]



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

Reply via email to