← Back to Pull requests

feat(spark): add Spark-compatible make_time function #72

Closed
unknown closed this pull request without merging on Nov 17, 2026 12:40 UTC
View on GitHub
unknown unknown commented on Nov 12, 2026 16:11 UTC
Author

Closes #212.

Summary


  • Adds Spark 4.1+'s make_time(hour, minute, second), ported from DataFusion Comet's datetime_funcs/make_time.rs.

  • Returns Time64(Nanosecond) (Spark's TIME(6)). NULL if any argument is NULL. The result does not depend on the session time zone.

  • Out-of-range fields raise DATETIME_FIELD_OUT_OF_BOUNDS.WITHOUT_SUGGESTION with Spark's message, including the SQLSTATE (Invalid value for HourOfDay (valid values 0 - 23): -1. SQLSTATE: 22023), whatever the ANSI setting.

  • Check order follows Spark's DateTimeUtils.makeTime: seconds outside 0..=2147483647 are rejected first and reported truncated toward zero (-0.5 reports 0, 4294967297.5 reports 4294967297). Otherwise LocalTime.of order applies: hour, then minute, then second.

  • Arguments are coerced like Spark's ImplicitCastInputTypes: any numeric or string to INT for hour and minute, and to DECIMAL(16, 6) for seconds (extra fractional digits round half up). DataFusion types bare integer literals as BIGINT, so a strict INT signature would reject make_time(1, 18, 19.87).

  • The kernel returns an internal error, not a panic, if it is called without DataFusion's coercion (as Comet does), and requires seconds as Decimal128(_, 6).

  • Documents make_time with #[user_doc], following CONTRIBUTING.md.
  • Known gap


    The argument casts use DataFusion's cast, not Spark's, so values the cast cannot represent raise a cast error in both ANSI modes. With ANSI mode off Spark wraps an out-of-range integer (make_time(4294967297::BIGINT, 0, 0) is 01:00:00) and returns NULL for a malformed string or seconds that do not fit DECIMAL(16, 6); it returns NULL for NaN and Infinity seconds in both modes. With ANSI mode on both engines error, with different messages. Spark-compatible casts are tracked by #88. These cases are in the .slt file as commented-out queries carrying Spark's result, and the gap is stated in the docs.

    Testing


  • datetime/make_time.slt: cases from Spark's time.sql.out, issue #212 and Comet's make_time unit tests, with DECIMAL variants of the literal cases (DataFusion reads 19.87 as DOUBLE, see #97), seconds columns of INT, BIGINT, DECIMAL and DOUBLE, NULLs in each column, a non-UTC session time zone, and the bounds errors with ANSI mode on and off. Results and error messages were checked against PySpark 4.2.0; the PySpark runner passes every query it can run.

  • Rust unit tests for the uncoerced-argument errors and seconds with a precision other than 16.

  • cargo clippy --all-targets --all-features -- -D warnings, cargo test -p datafusion-spark and cargo test -p datafusion-spark-sqllogictest pass.
  • 🤖 Generated with Claude Code

    Diff: 341 lines (+255 / -86) across 4 files Reviewer: kosiew Review duration: 6988m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 341 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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.349
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #72"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.3% (MEDIUM) · Higher = larger blast radius
    42.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.7% · Safe to merge
    16.7%