Skip to content

Time is rendered as DATETIME, so a time-of-day is silently stored as a 1970-01-01 timestamp #79

Open

Description

@ChrisGVE

Versions

  • databend-sqlalchemy 0.5.5
  • databend-driver 0.34.2
  • SQLAlchemy 2.0.51
  • Python 3.12.9, macOS
  • Server: datafuselabs/databend:v1.2.925-patch-4 in Docker

What happens

Databend has no time-of-day type. Its parser says so by listing what it will take:

CREATE TABLE probe (clock TIME)
-> unexpected `TIME`, expecting `TIMESTAMP`, `TIMESTAMP_TZ`, `TEXT`, … `DATE`, … `DATETIME`, …

The dialect renders Core's Time as DATETIME. The column is created, and the substitution is invisible from Core, because SQLAlchemy's own Time type re-derives the value on the way out:

  • typed select() on the column hands back time(14, 30) — looks correct
  • the same column read without the Core type in play is 1970-01-01T14:30:00Z
  • inspect() reports the column type as DATETIME

So it round-trips correctly through a typed Core select and is wrong through everything else: reflection, any consumer reading the column generically, anything comparing against another engine's storage of the same value.

Why this is the awkward failure mode

A column that couldn't be created is a five-minute problem. A column that exists and quietly holds a different type is the kind that surfaces months later, in whichever consumer wasn't going through Core's typed path. The date part isn't neutral either — it's a real 1970-01-01 sitting in the data, and it sorts and compares as one.

Suggested fix

Refuse Time at compile time on an engine that has no such type, the same way an unsupported type is refused elsewhere. If a substitution is preferred over a refusal, TEXT at least doesn't invent a date, but I'd rather it just raised.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions