test: add parity tests for spark.sql.legacy.timeParserPolicy#4181
Draft
andygrove wants to merge 2 commits intoapache:mainfrom
Draft
test: add parity tests for spark.sql.legacy.timeParserPolicy#4181andygrove wants to merge 2 commits intoapache:mainfrom
andygrove wants to merge 2 commits intoapache:mainfrom
Conversation
…olicy Adds parity tests for Spark's timeParserPolicy config (CORRECTED/LEGACY) across CAST(string AS date/timestamp), to_date, to_timestamp, unix_timestamp, from_unixtime, and date_format. Two tests for string-to-timestamp are marked ignore because Comet's native ISO parser rejects inputs like "2020-1-1 1:2:3" that Spark accepts under LEGACY. Flip ignore -> test once Comet honors the policy.
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.
Summary
Adds a new test suite (
CometTimeParserPolicySuite) that verifies Comet matches Spark under non-default values ofspark.sql.legacy.timeParserPolicy(CORRECTEDandLEGACY) for:CAST(string AS date/timestamp),to_date,to_timestamp,unix_timestamp,from_unixtime, anddate_format.This is draft / exploratory — the goal is to document current behavior gaps rather than fix them. It's part of a broader audit of Spark configs whose non-default values may produce divergent results in Comet.
Findings
Running on Spark 4.0:
CAST(string AS date)CAST(string AS timestamp)ignoredto_date(s)without patternto_date(s, pattern)ParseToDateserde)to_timestamp(s)without patternignoredto_timestamp(s, pattern)unix_timestamp(s, pattern)from_unixtime(long, pattern)Incompatible(None)default fallback)date_format(date, pattern)The two
ignored tests show concrete divergence:2020-1-1 1:2:32020-01-01 01:02:03.0nullComet's native ISO parser in
native/spark-expr/src/conversion_funcs/string.rsrejects the single-digit month/day/hour/minute/second formats that Spark'sSimpleDateFormataccepts under LEGACY. The config is not read anywhere in Comet.Passing tests mostly represent cases where Comet falls back to Spark (pattern-based functions with no serde handler, or
Incompatible(None)default). They're still useful as regression guards.Context
Follow-up to a broader audit of Spark configs whose non-default values can silently produce wrong results in Comet — other candidates:
parquet.datetimeRebaseModeInRead,parquet.int96RebaseModeInRead,parquet.binaryAsString,mapKeyDedupPolicy.Test plan
-Pspark-4.0 -Pscala-2.13CometTimeParserPolicySuitelocally — 7 pass, 2ignoreignored tests drive a fix (honor the policy) or explicit fallback (timeParserPolicy != CORRECTED→ fall back to Spark)