chore: complete coverage for primitive to string casts#4009
Closed
parthchandra wants to merge 1 commit intoapache:mainfrom
Closed
chore: complete coverage for primitive to string casts#4009parthchandra wants to merge 1 commit intoapache:mainfrom
parthchandra wants to merge 1 commit intoapache:mainfrom
Conversation
Contributor
Author
|
This is already done in #3939 |
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?
Part of #286
Fixes: #1068
Rationale for this change
Comet had gaps in Decimal-to-String cast coverage:
Decimal -> String (LEGACY mode): cast_array was falling through to DataFusion's built-in cast for Decimal128 -> Utf8, which produces plain notation. Spark's LEGACY mode uses Java BigDecimal.toString(), which produces scientific notation when the adjusted exponent is less than -6. For example, Decimal(38,18) zero was cast as
"0.000000000000000000" by Comet but "0E-18" by Spark.
Decimal with negative scale: When spark.sql.legacy.allowNegativeScaleOfDecimal=true, Spark formats negative-scale decimals in scientific notation (e.g. Decimal(7,-2) unscaled=123 -> "1.23E+4"). Comet now matches this. When the config is disabled, CometCast.isSupported returns Incompatible since negative-scale decimals cannot be created
via normal SQL paths.
Other primitive types -> String: Boolean, integer, float, double, date, timestamp, and binary casts to String were already handled correctly by DataFusion's built-in cast. The existing castTest harness already exercises LEGACY, TRY, and ANSI modes for all of these types, so no new tests were needed.
What changes are included in this PR?
How are these changes tested?