[SPARK-58740][SQL][TESTS] Add to_xml test coverage for nanosecond-precision timestamp types - #57963
Closed
stevomitric wants to merge 2 commits into
Closed
Conversation
…cision timestamp types ### What changes were proposed in this pull request? This PR adds test coverage for the `to_xml` write path with the nanosecond-precision timestamp types (`TIMESTAMP_NTZ(p)` / `TIMESTAMP_LTZ(p)`, `p in [7, 9]`). The write path exists in `StaxXmlGenerator` but had no dedicated tests, while `from_xml` (read) and both JSON directions were already covered. Two tests are added to `XmlFunctionsSuite`: - `to_xml with nanos timestamp types` — asserts the exact XML output for both NTZ and LTZ nanos types at every valid precision. - `roundtrip in to_xml and from_xml - nanos timestamps` — verifies the write -> read round-trip is loss-free at every valid precision. ### Why are the changes needed? The `to_xml` nanosecond write path was implemented but never exercised by a test, leaving a coverage gap for the XML datasource nanosecond support (SPARK-57458). ### Does this PR introduce _any_ user-facing change? No. Test-only change. ### How was this patch tested? `build/sbt "sql/testOnly org.apache.spark.sql.XmlFunctionsSuite"` — all tests pass. Co-authored-by: Isaac
Contributor
Author
|
cc @uros-b, @cloud-fan PTAL when you get a chance. |
uros-b
approved these changes
Aug 12, 2026
Member
|
Thank you @stevomitric! |
cloud-fan
approved these changes
Aug 12, 2026
cloud-fan
left a comment
Contributor
There was a problem hiding this comment.
0 blocking, 0 non-blocking, 1 nit.
The coverage is focused and matches the existing sibling test pattern; one terminology nit remains in a comment.
Nits: 1 minor item (see inline comments).
Verification
I traced the tested NTZ and LTZ values through StaxXmlGenerator's nanos formatting branches and compared the portfolio with the existing JSON nanos tests. I did not run the Spark test suite.
PR metadata suggestions
- Document how the PR title's SPARK-58740 relates to SPARK-57458, which appears in both new test names and is cited as the implementation whose coverage gap this PR closes.
….scala Co-authored-by: Wenchen Fan <cloud0fan@gmail.com>
uros-b
added a commit
that referenced
this pull request
Aug 13, 2026
…ision timestamp types ### What changes were proposed in this pull request? This PR adds test coverage for the `to_xml` write path with the nanosecond-precision timestamp types (`TIMESTAMP_NTZ(p)` / `TIMESTAMP_LTZ(p)`, `p in [7, 9]`). The write path exists in `StaxXmlGenerator` but had no dedicated tests, while `from_xml` (read) and both JSON directions were already covered. Two tests are added to `XmlFunctionsSuite`: - `to_xml with nanos timestamp types` — asserts the exact XML output for both NTZ and LTZ nanos types at every valid precision. - `roundtrip in to_xml and from_xml - nanos timestamps` — verifies the write -> read round-trip is loss-free at every valid precision. ### Why are the changes needed? The `to_xml` nanosecond write path was implemented but never exercised by a test, leaving a coverage gap for the XML datasource nanosecond support (SPARK-57458). ### Does this PR introduce _any_ user-facing change? No. Test-only change. ### How was this patch tested? `build/sbt "sql/testOnly org.apache.spark.sql.XmlFunctionsSuite"`. ### Was this patch authored or co-authored using generative AI tooling? Co-authored-by: Claude Code 4.8 Closes #57963 from stevomitric/stevomitric/spark-57458-to-xml-nanos-tests. Lead-authored-by: Stevo Mitric <stevomitric2000@gmail.com> Co-authored-by: Uros Bojanic <221401595+uros-b@users.noreply.github.com> Signed-off-by: Uros Bojanic <221401595+uros-b@users.noreply.github.com> (cherry picked from commit 94cbfba) Signed-off-by: Uros Bojanic <221401595+uros-b@users.noreply.github.com>
uros-b
added a commit
that referenced
this pull request
Aug 13, 2026
…ision timestamp types ### What changes were proposed in this pull request? This PR adds test coverage for the `to_xml` write path with the nanosecond-precision timestamp types (`TIMESTAMP_NTZ(p)` / `TIMESTAMP_LTZ(p)`, `p in [7, 9]`). The write path exists in `StaxXmlGenerator` but had no dedicated tests, while `from_xml` (read) and both JSON directions were already covered. Two tests are added to `XmlFunctionsSuite`: - `to_xml with nanos timestamp types` — asserts the exact XML output for both NTZ and LTZ nanos types at every valid precision. - `roundtrip in to_xml and from_xml - nanos timestamps` — verifies the write -> read round-trip is loss-free at every valid precision. ### Why are the changes needed? The `to_xml` nanosecond write path was implemented but never exercised by a test, leaving a coverage gap for the XML datasource nanosecond support (SPARK-57458). ### Does this PR introduce _any_ user-facing change? No. Test-only change. ### How was this patch tested? `build/sbt "sql/testOnly org.apache.spark.sql.XmlFunctionsSuite"`. ### Was this patch authored or co-authored using generative AI tooling? Co-authored-by: Claude Code 4.8 Closes #57963 from stevomitric/stevomitric/spark-57458-to-xml-nanos-tests. Lead-authored-by: Stevo Mitric <stevomitric2000@gmail.com> Co-authored-by: Uros Bojanic <221401595+uros-b@users.noreply.github.com> Signed-off-by: Uros Bojanic <221401595+uros-b@users.noreply.github.com> (cherry picked from commit 94cbfba) Signed-off-by: Uros Bojanic <221401595+uros-b@users.noreply.github.com>
Member
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.
What changes were proposed in this pull request?
This PR adds test coverage for the
to_xmlwrite path with the nanosecond-precision timestamp types (TIMESTAMP_NTZ(p)/TIMESTAMP_LTZ(p),p in [7, 9]). The write path exists inStaxXmlGeneratorbut had no dedicated tests, whilefrom_xml(read) and both JSON directions were already covered.Two tests are added to
XmlFunctionsSuite:to_xml with nanos timestamp types— asserts the exact XML output for both NTZ and LTZ nanos types at every valid precision.roundtrip in to_xml and from_xml - nanos timestamps— verifies the write -> read round-trip is loss-free at every valid precision.Why are the changes needed?
The
to_xmlnanosecond write path was implemented but never exercised by a test, leaving a coverage gap for the XML datasource nanosecond support (SPARK-57458).Does this PR introduce any user-facing change?
No. Test-only change.
How was this patch tested?
build/sbt "sql/testOnly org.apache.spark.sql.XmlFunctionsSuite".Was this patch authored or co-authored using generative AI tooling?
Co-authored-by: Claude Code 4.8