Skip to content

[SPARK-58740][SQL][TESTS] Add to_xml test coverage for nanosecond-precision timestamp types - #57963

Closed
stevomitric wants to merge 2 commits into
apache:masterfrom
stevomitric:stevomitric/spark-57458-to-xml-nanos-tests
Closed

[SPARK-58740][SQL][TESTS] Add to_xml test coverage for nanosecond-precision timestamp types#57963
stevomitric wants to merge 2 commits into
apache:masterfrom
stevomitric:stevomitric/spark-57458-to-xml-nanos-tests

Conversation

@stevomitric

Copy link
Copy Markdown
Contributor

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

…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
@stevomitric stevomitric changed the title [WIP][SPARK-58740][SQL][TESTS] Add to_xml test coverage for nanosecond-precision timestamp types [SPARK-58740][SQL][TESTS] Add to_xml test coverage for nanosecond-precision timestamp types Aug 12, 2026
@stevomitric

Copy link
Copy Markdown
Contributor Author

cc @uros-b, @cloud-fan PTAL when you get a chance.

@uros-b

uros-b commented Aug 12, 2026

Copy link
Copy Markdown
Member

Thank you @stevomitric!

@cloud-fan cloud-fan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread sql/core/src/test/scala/org/apache/spark/sql/XmlFunctionsSuite.scala Outdated
….scala

Co-authored-by: Wenchen Fan <cloud0fan@gmail.com>
@uros-b uros-b closed this in 94cbfba Aug 13, 2026
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>
@uros-b

uros-b commented Aug 13, 2026

Copy link
Copy Markdown
Member

Merge Summary:

Posted by merge_spark_pr.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants