Vyrham opened a new pull request, #457: URL: https://github.com/apache/datafusion-spark/pull/457
Closes #198. Implements Spark-compatible `rpad(str, len[, pad])` with both the string and binary forms in one function. Lengths count UTF-8 code points for strings (a surrogate pair is one character, combining marks count separately) and bytes for binary input. `len` is INT (unlike DataFusion's `rpad`, which takes BIGINT), binary input is accepted with a default pad of X'00', and other atomic values are cast to STRING. A negative `len` returns an empty string for strings and raises an error for binary input, mirroring Spark's `NegativeArraySizeException`. The binary kernel (`rpad_binary_value`) is `pub(crate)` so the sibling `lpad` implementation can reuse it instead of duplicating it. Includes Rust unit tests and sqllogictest coverage (`string/rpad.slt`) and updates the function docs. Notes for reviewers: - The docs in `docs/functions/` were updated by hand following the docgen format; please let me know if `dev/update_function_docs.sh` produces anything different and I will align them. - Open questions: the legacy switch `spark.sql.legacy.lpadRpadAlwaysReturnString` is a builder flag (`with_legacy_always_return_string`), not wired to the session config — is that acceptable, or should it read the session setting? The >2^31-1-byte overflow message (`rpad result exceeds the maximum length of 2147483647 bytes`) is invented; Spark throws `ArithmeticException` (`Math.toIntExact`) but its exact message was not confirmed — please correct it if you know it. The binary negative-`len` message is likewise a design choice, since Spark's `NegativeArraySizeException` carries no message. -- 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]
