Skip to content

[SPARK-57810][SQL] Infer nanosecond-precision timestamp types in XML schema inference#56935

Open
yadavay-amzn wants to merge 2 commits into
apache:masterfrom
yadavay-amzn:SPARK-57810
Open

[SPARK-57810][SQL] Infer nanosecond-precision timestamp types in XML schema inference#56935
yadavay-amzn wants to merge 2 commits into
apache:masterfrom
yadavay-amzn:SPARK-57810

Conversation

@yadavay-amzn

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Extends XML schema inference (XmlInferSchema) to infer nanosecond-precision timestamp types. A timestamp string with more than 6 fractional-second digits (with timezone info) now infers as the nanosecond LTZ timestamp type, mirroring the existing nanosecond NTZ inference in the same file and the JSON/CSV nanosecond-inference approach. Behavior is gated on the existing nanosecond-timestamp config; values with <= 6 fractional digits still infer as the microsecond TimestampType.

Why are the changes needed?

Part of nanosecond-precision timestamp support (SPARK-56822). XML inference previously truncated sub-microsecond timestamps to microsecond precision; it should infer the nanosecond type when the data warrants it, consistent with JSON and CSV.

Does this PR introduce any user-facing change?

Yes - with nanosecond timestamp types enabled, XML schema inference can infer a nanosecond-precision timestamp type for sub-microsecond timestamps (previously inferred as microsecond TimestampType).

How was this patch tested?

XmlInferSchemaSuite: new tests covering pure-nanosecond inference, pure-microsecond (unchanged), mixed widening, and string fallback.

Was this patch authored or co-authored using generative AI tooling?

Authored with assistance by Claude Opus 4.8.

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.

1 participant