Repository navigation
feat(spark): cast crc32's argument to Spark's declared input type - #356
Merged
Merged
Conversation
Spark declares crc32's input type as BINARY. Use SparkInputTypes so a STRING argument is cast to BINARY and other types fail with Spark's UNEXPECTED_INPUT_TYPE and WRONG_NUM_ARGS errors. Part of apache#353.
11 tasks
Member
Author
|
Thanks @coderfender |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
Spark declares
crc32's input type as BINARY, and casts a STRING argument to it.crc32already accepts the same types, but it rejects the others with DataFusion's errors instead of Spark's:crc32(1::INT)Function 'crc32' requires Binary, but received Int32...[DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE] The first parameter of `crc32` requires the "BINARY" type, however it has the type "INT". SQLSTATE: 42K09crc32('a', 'b')Function 'crc32' expects 1 arguments but received 2...[WRONG_NUM_ARGS.WITHOUT_SUGGESTION] The `crc32` requires 1 parameters but the actual number is 2. ...What changes are included in this PR?
crc32declares Spark'sCrc32.inputTypeswithSparkInputTypesfrom #350, the same waysha2does.Are these changes tested?
Yes. New records in
hash/crc32.sltcover a dictionary-encoded string, a column with NULLs, the errors for other types and for the wrong number of arguments, and ANSI mode. The error records fail without this change. I checkedcrc32.sltagainst Spark 4.2.0 with the PySpark runner, and every record matches. The runner does not compare error messages, so I checked them against Spark by hand. Spark's message also names the argument's SQL text, as noted in #350.Are there any user-facing changes?
Only the error messages above. The results do not change.
This PR was prepared with AI assistance (Claude Code) and reviewed by me.