test: cast negative zero to string#3829
Conversation
andygrove
left a comment
There was a problem hiding this comment.
@kazuyukitanimura Could you confirm the tests actually catch the negative zero case? The Rust format! macro still formats -0.0 as "-0.0" and I don't see a code change that normalizes it. It would be helpful to see the test output or add a more targeted assertion, for example a SQL file test like:
SELECT CAST(CAST('-0.0' AS FLOAT) AS STRING)This would make it clear that Comet returns "0.0" rather than "-0.0". I tried this yesterday and saw an incompatibility that I wasn't able to fix easily.
|
Thanks @andygrove The original analysis of #1036 is not quite right in my opinion, as I mentioned in #1036 (comment) The real reason for #1036 is (at least in the current main branch) due to #3825
Yes, it does.
Spark does not normalize for casting float/double to String. You can quickly see that the following test passes. test("cast negative zeros") {
withTable("t1") {
Seq(0.0f, -0.0f, 0.0f, -0.0f).toDF("a").write.saveAsTable("t1")
val df = sql("SELECT CAST(a AS STRING) FROM t1")
checkSparkAnswerAndOperator(df)
}
}
The following is the printout of
I do not think you meant this. |
andygrove
left a comment
There was a problem hiding this comment.
Thanks @kazuyukitanimura. Yes, the original issue was incorrect.
|
Thank you @andygrove |
Which issue does this PR close?
Closes #1036
Related #3811
Rationale for this change
The existing implementation is correct. This PR is for testing to confirm that.
The original analysis of #1036 is not quite right in my opinion, as I mentioned in #1036 (comment)
The real reason for #1036 is (at least in the current main branch) due to #3825
What changes are included in this PR?
How are these changes tested?