fix(spark): quote writes a timestamp with a space like Spark #422
All Vouch review confidence checks passed
Residual risk 0.23 = Change Risk (0.42) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 347 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.350
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #422"
general
weight: 0.35
andygrove
Which issue does this PR close?
Rationale for this change
quoteof a timestamp returned ISO 8601 with aTseparator and kept trailing fractional zeros (for example'2024-01-15T12:30:45.120'), because DataFusion coerced the argument toUtf8using Arrow's cast. Spark'sQuotetakes aSTRINGviaImplicitCastInputTypes, so Spark casts timestamps withyyyy-MM-dd HH:mm:ss[.fraction]in the session time zone and drops trailing zeros of the fraction.What changes are included in this PR?
Dictionarytypes inSparkQuote::coerce_types, keep timestamp inputs asTimestamp(Microsecond, tz), and format them withspark_castininvoke_with_argsusingdatafusion.execution.time_zone(UTC when unset). Other non-string types still use DataFusion's cast, and other functions that coerce timestamps to strings stay tracked under #347 and #95.SparkQuotefromVolatility::ImmutabletoVolatility::Stableto matchspark_castandtimestamp_micros, since timestamp output depends on the session time zone and should not be folded before execution in prepared statements or views.#[user_doc]onSparkQuoteand regeneratedocs/functions/scalar/string.md.Are these changes tested?
crates/sqllogictest/test_files/string/quote.sltcovers three areas: timestamp formatting across units, fractional seconds, pre-1970 dates, NULLs and multi-row batches; session time zone handling forTIMESTAMPandTIMESTAMP_NTZ(includingAmerica/Los_Angeles); and dictionary-encoded string and timestamp inputs.crates/spark/src/function/string/quote.rscheckVolatility::Stable, dictionary unwrapping incoerce_types(includingLargeUtf8andUtf8View), and unsupported session time zone handling (TIMESTAMP_NTZsucceeds while zonedTIMESTAMPerrors).crates/sqllogictest/scripts/pyspark_slt_runner.py: all translatable records ran and passed on Spark 4.2.0, while 5 Arrow-only records without a Spark equivalent (sub-microsecond nanosecond truncation, a column time zone differing from the session zone, and dictionary-encoded timestamps) are markedskipif spark.Are there any user-facing changes?
Yes.
quoteon timestamp inputs now follows Spark's string output instead of Arrow's ISO 8601 format; millisecond and nanosecond timestamps are cast to microseconds first, so nanosecond inputs drop digits below a microsecond. There are no breaking changes to the public Rust API.AI Disclosure
Grok Bot, working for dragonknightk, assisted with the changes, the description, and the verification. All content was reviewed by a human, and the submitter understands and can maintain these changes.