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
{{ message }}
Repository navigation
Commit 002e9f6
Browse filesBrowse the repository at this point in the historyBrowse files
docs: explain dialect typing gaps and MSSQL conversion boundaries
Compare all seven seeded engines' common-type semantics and explain why SQL Server settings must not be copied to them. Clarify converter dispatch and the metadata needed to replace its recognition maps.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: docs/howto/analyze.md
+39Lines changed: 39 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,45 @@ engine's own analysis path, so the two can report a type differently — most
19
19
visibly, `analyze` reports type names as the catalog stores them, in lower
20
20
case.
21
21
22
+
## Common-type inference
23
+
24
+
The shared core does not give every database the same coercion rules. SQL
25
+
Server explicitly enables its type-combination policy for set operations and
26
+
alternative-valued expressions such as `CASE`, `COALESCE`, `GREATEST`, `LEAST`
27
+
and `CHOOSE`. `ISNULL` instead keeps its first typed argument's type; both
28
+
arguments must be nullable for its result to be nullable.
29
+
30
+
Other dialects currently keep the existing core fallback: a set-operation
31
+
column takes its type from the left branch, and an alternative-valued
32
+
expression takes the first typed candidate. **This is incomplete static
33
+
inference, not those databases' common-type semantics.** It does not change
34
+
their normal `generate` paths.
35
+
36
+
The database rules differ in ways that need separate policies:
37
+
38
+
| Dialect | Database behavior and current core gap |
39
+
| --- | --- |
40
+
| SQL Server | Uses type precedence and combines decimal scale/integer digits with a precision limit of 38. The enabled policy models these rules, but is not a general implicit-cast validator. |
41
+
| PostgreSQL | Selects common types using categories, implicit casts, preferred types, unknown literals and domains. Modifiers survive only when the candidates have the same type and modifier: `numeric(5,2) UNION numeric(8,4)` has unconstrained `numeric`, not SQL Server-style decimal widening. |
42
+
| SQLite | Values are dynamically typed; compound-view/subquery affinity can come from any constituent `SELECT`. Declared decimal precision and string length do not impose SQL Server-style limits. |
43
+
| MySQL | Aggregates types and lengths across set-operation branches; alternative expressions also need signed/unsigned, numeric, binary/string, temporal and NULL-literal rules. |
44
+
| DuckDB | Uses combination casting for set operations, including casts not allowed by ordinary implicit casting. Integer widths and nested types need more than a precedence list. |
45
+
| ClickHouse | Computes compatible supertypes, including `Nullable`, signed/unsigned widths and nested types; decimal precision can reach 76. Some combinations have no compatible supertype. |
46
+
| GoogleSQL (Spanner) | Intersects supertype sets, distinguishes exact from inexact numeric inputs, and has separate literal and structured-type rules. Its type inventory is not identical to BigQuery's. |
47
+
48
+
These are reviewed database semantics, not a claim that sqlc has implemented
49
+
or live-tested the missing policies. See the upstream references:
0 commit comments