shrirangmhalgi opened a new pull request, #56634: URL: https://github.com/apache/spark/pull/56634
### What changes were proposed in this pull request? Add `TimeType` inference to `CSVInferSchema` and `JsonInferSchema`, following the existing `DateType/TimestampType` inference pattern. A `tryParseTime` step is inserted in the CSV type ladder between `DoubleType` and `DateType`, and an equivalent check is added to the JSON string inference path. Both are gated behind `spark.sql.timeType.enabled` (default false). ### Why are the changes needed? `CSVInferSchema` and `JsonInferSchema` infer `DateType` / `TimestampNTZType` / `TimestampType` but never `TimeType`. With an explicit schema, TIME read/write already works; only auto-inference is missing. Time-only columns (e.g., `12:13:14`) currently infer as `StringType` even when the TIME type feature is enabled. ### Does this PR introduce _any_ user-facing change? Yes. When `spark.sql.timeType.enabled` is set to `true`, `CSV` and `JSON` schema inference will recognize time-only string values (e.g., `12:13:14`, `23:59:59.123456`) as `TimeType` instead of `StringType`. When disabled (default), behavior is unchanged. ### How was this patch tested? New tests in CSVInferSchemaSuite and JsonInferSchemaSuite: - Time strings infer as `TimeType` when `spark.sql.timeType.enabled = true` - Time strings do NOT infer as `TimeType` when disabled (existing behavior preserved) - `Date` / `timestamp` strings are not misclassified as time - All existing + new tests pass for both CSV and JSON ### Was this patch authored or co-authored using generative AI tooling? Co-Authored using Claude Opus 4.6 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
