shuch3ng commented on PR #2993:
URL: 
https://github.com/apache/datafusion-comet/pull/2993#issuecomment-3693891605

   Hi @coderfender.
   
   That's a good question. I implemented `spark_translate` here because Andy 
created issue #2976 in this project so I didn’t think too much at the time.
   
   Upon checking DataFusion 
[`translate`](https://github.com/apache/datafusion/blob/main/datafusion/functions/src/unicode/translate.rs),
 I noticed two differences compared to 
[Spark's](https://github.com/apache/spark/blob/eec092c9f9d1ad3df0390b1ea56340c1103ba887/common/unsafe/src/main/java/org/apache/spark/unsafe/types/UTF8String.java#L1593):
   1. It sets `graphemes(true)`, while Spark uses codepoints, which might lead 
to incompatibility
   2. It uses last-occurrence-wins for duplicates, while Spark uses 
first-occurrence-wins.
   
   For example:
   ```
   ❯ datafusion-cli
   DataFusion CLI v51.0.0
   > SELECT translate('abcbcb', 'bcbc', '1234') AS result;
   +--------+
   | result |
   +--------+
   | a34343 |
   +--------+
   1 row(s) fetched.
   Elapsed 0.005 seconds.
   ```
   
   ```
    ❯ spark-sql
   spark-sql (default)> SELECT translate('abcbcb', 'bcbc', '1234');
   a12121
   Time taken: 1.273 seconds, Fetched 1 row(s)
   ```
   
   I'm not very familiar with the DataFusion project so I could be wrong, but 
pushing the changes upstream could affect other use cases in DataFusion.


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