You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make sqlc's ClickHouse analysis agree with ClickHouse
testcheck showed sqlc disagreeing with ClickHouse on every analyze case
that went beyond plain column references. This makes the six ClickHouse
cases match the database byte for byte, and moves the testcheck command
under cmd/testcheck.
Types are carried as expressions. The ClickHouse converter keeps a
column's full spelling in the type name's Spelling, the schema stores it
as the attribute's declared type, and the analysis core writes each
column and parameter a TypeExpr from it, so Array(Nullable(String)),
Map(String, Nullable(UInt8)), Tuple(lat Float64, lon Float64) and
Decimal(10, 2) survive intact. The analyze command prints that
expression when the core produced one.
Functions are typed. A ClickHouse function seed of 581 signatures
replaces the single count() entry, with "$n" naming the type of the nth
argument and never_null marking results that stay non-null. The dialect
declares that functions propagate nullability, that comparisons yield
UInt8 while true is Bool, that LIMIT counts are UInt64, and that an
unconstrained placeholder is Nothing. The analyzer scores overloads,
types ORDER BY, LIMIT and OFFSET, follows IN (SELECT ...) into the
subquery, makes COALESCE null only when every argument is, and names a
placeholder compared with a function call after the function.
The converter gives unaliased expression columns ClickHouse's own names,
such as sum(amount) and plus(id, 1), captures aliases on every node
kind, converts a scalar subquery as a value rather than EXISTS, converts
coalesce and ifNull to COALESCE, handles WITH elements as the parser
produces them, and counts positions from zero so star expansion and
parameter renumbering line up. ClickHouse joins the preprocessed
engines, so sqlc.arg() and sqlc.narg() work with ? binding. A dialect
that names the second id of a join e.id says so in its seed and the
analyzer qualifies such columns.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y6XkyWnx7iJFEb8q3AnYps
0 commit comments