posit-dev / posit-dev/ggsql

TIME columns are never cast: needs_cast ignores a Time64 unit mismatch

Open Beginner friendly
#515 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

plot building
Dominant language
Rust
Stars
554
Forks
30
Avg merge
17h 27m
Merged PRs (30d)
8

Description

Summary

ggsql's Time convention is nanoseconds — casting.rs targets Time64(Nanosecond) and schema.rs reads through the strict as_time64_ns — but needs_cast (src/plot/scale/scale_type/mod.rs:2205) treats any (Time64(_), Time64(_)) pair as already being the target type, so DuckDB's native Time64(Microsecond) is never converted.

Reproduction
SELECT * FROM (VALUES (TIME '08:00:00', 1), (TIME '12:30:00', 4), (TIME '18:15:00', 2)) AS t(tm, v)
VISUALISE tm AS x, v AS y
DRAW point
Failed to generate Vega-Lite output: Internal error: Expected Time64(Nanosecond) array, got Time64(Microsecond)

The hephaestus writer does not error — it renders raw microsecond values against a domain ggsql could not resolve, which is worse.

Suggested fix

Treat a unit mismatch as needing a cast: (Time64(a), Time64(b)) is already-target only when a == b. The neighbouring (Timestamp(_, _), Timestamp(_, _)) arm has the same wildcard shape and should be audited at the same time.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at src/plot/scale/scale_type/mod.rs:2205 and inspect the needs_cast logic for Time64 unit pairs. Run the SQL reproduction from the issue, then verify that mismatched time units are converted to the convention used by casting.rs and accepted by schema.rs. Audit the neighboring Timestamp arm as requested and confirm the reproduction produces Vega-Lite output without the Time64 error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
data-visualization
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.