Skip to content

fix: #1487 ClickHouse temporal constructors (datetime/localdatetime/time) - #1557

Open
hari2353 wants to merge 1 commit into
genezhang:mainfrom
hari2353:fix/wave2-1487-temporal-constructors
Open

hari2353 wants to merge 1 commit into
genezhang:mainfrom
hari2353:fix/wave2-1487-temporal-constructors

Conversation

@hari2353

@hari2353 hari2353 commented Nov 9, 2026

Copy link
Copy Markdown

What

Fixes #1487: several Cypher temporal constructors fail in ClickHouse:

  • localdatetime('str') rendered as now64(parseDateTime64BestEffort(...)) (now64 takes precision, not a value) → Code 43. Fixed: parseDateTime64BestEffort(str, 3).
  • localdatetime() rendered as parseDateTime64BestEffort(now64(3)) → Code 43. Fixed: special case returns now64(3).
  • datetime() rendered as parseDateTime64BestEffort(now64(3)) → Code 43. Fixed: special case returns now64(3).
  • time('str') had no mapping → Code 46 (no function time). Fixed: added time → toTime(parseDateTime64BestEffort(concat('1970-01-01T', arg), 3)).
  • time() with no args → toTime(now()).

Map-argument forms (date({map}), datetime({map}), localdatetime({map})) still fail loudly (Code 43) — the component form (makeDate/makeDateTime64) is a follow-up.

Gates (local, 1.94.1, --no-default-features)

  • fmt: clean · clippy: clean · lib: 1489/0/4 · ratchet: 1/0 · corpus: 2/0

Spec-driven

Backward-compatible (only wrong-today queries change). Corpus goldens byte-identical (ratchet green).

Closes #1487

@genezhang genezhang left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for #1487. Part of this is a clear improvement and I'd like to land it. I ran this head against main on ClickHouse 26.7.1 and 25.8.33.

Works (both versions): RETURN datetime() (main: Code 43), RETURN localdatetime('2020-01-15T10:30:00') (main: Code 43). localdatetime(), datetime('…Z'), date('…') are unchanged.

Concerns about the new time mapping

  • RETURN time('10:30:00+01:00') now returns 09:30:00 on 26.7: the offset is dropped and the clock shifted to UTC. Neo4j keeps the offset (10:30:00+01:00). The query used to fail loudly, so it now silently answers with a different value.
  • On 25.8, toTime is the older function that returns a DateTime: time('10:30:00') gives 1970-01-02 10:30:00.
  • localtime('10:30:00') fails on 25.8 with toTime ("Illegal type String"). That is the same function as on main, so it is not new.

Suggestions

  • Split the PR. Keep the datetime() and localdatetime(...) changes, and leave time out until it can keep the offset (or keep it loud).
  • Add lowering tests for the cases that now work. None are included, and each of them fails on main.
  • The description says the map forms still fail loudly; if those remain open, please use Refs #1487 rather than Closes.

Stacking. This branch also carries the commits from #1555 and #1556 (1e1c1b09, 3635ddfc, deec51e1). Please rebase so it holds only its own change. Please also drop the osv-scanner.toml hunk, which replaces the reason text on main with an older wording.

If it's easier, we're happy to take the datetime()/localdatetime() part ourselves. Just say.

@hari2353
hari2353 force-pushed the fix/wave2-1487-temporal-constructors branch from 36f9195 to 7b99694 Compare November 15, 2026 04:54
@hari2353

Copy link
Copy Markdown
Author

Reworked per review: split out the #1490 (any_non_null complex) and #1436 (chdb quoting) changes and the osv-scanner hunk; this PR now carries only the #1487 datetime()/localdatetime() constructor fix. Verified live on CH 25.8/26.7: RETURN datetime(), RETURN localdatetime(), RETURN localdatetime('2020-01-15T10:30:00'), RETURN datetime('2020-01-15T10:30:00') all return rows (they failed with Code 43 on main). time/ localtime left as-is (loud failure) per review. Rebased onto latest main.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ClickHouse: temporal constructors localdatetime(string), date/datetime/localdatetime({map}) and time() fail (Code 43 / 46)

2 participants