Skip to content

dialect: known functions, portable expressions, native types, and fixes from a database run - #72

Merged
stbischof merged 1 commit into
mainfrom
pr/dialect-fixes-2026-10-31
Oct 31, 2026
Merged

stbischof merged 1 commit into
mainfrom
pr/dialect-fixes-2026-10-31

Conversation

@stbischof

Copy link
Copy Markdown
Contributor
  • Known functions: MONTH_NAME, TO_TEXT, PAD_RIGHT, DATE_FROM_PARTS and TO_WIDE_INTEGER, each spelled by the dialect.
  • Portable expressions: an expression (SqlExpression.Portable) and a derived table (FromClause.FromPortable) are written once as a tree for every database, beside the texts some dialects give. The renderer takes the live dialect's own text where there is one, else renders the tree in that dialect, else takes the generic text.
  • Native types:
    • SQL Server keeps national text national; long text and binary are MAX.
    • DuckDB writes long text as VARCHAR and binary as BLOB.
    • PostgreSQL and MySQL name their large objects: a BLOB is an OID as pgjdbc binds it, other binary is BYTEA, and a VARBINARY without a length is a LONGBLOB.
  • Per database:
    • MySQL reads AVG as a double.
    • SQL Server declines a distinct text list.
    • Derby spells a typed null, keeps a text null untyped, and reads a part of a date with its own YEAR, MONTH and DAY.
  • Sum over an integer column: a capability, sumKeepsTheTypeOfItsOperand, says whether SUM keeps its operand's type. It is true for SQL Server and Derby, where a sum over an INTEGER column overflows past 2 147 483 647; TO_WIDE_INTEGER widens the operand.

…es from a database run

- known functions MONTH_NAME, TO_TEXT, PAD_RIGHT, DATE_FROM_PARTS and
  TO_WIDE_INTEGER; an expression and a derived table written once for
  every database beside the texts of some dialects
  (SqlExpression.Portable, FromClause.FromPortable)
- native types: SQL Server keeps national text national, long text and
  binary are MAX; DuckDB long text is VARCHAR, binary BLOB; PostgreSQL
  and MySQL name their large objects (a BLOB is an OID as pgjdbc binds
  it, other binary BYTEA; a VARBINARY without a length is a LONGBLOB)
- MySQL reads AVG as a double; SQL Server declines a distinct text list;
  Derby spells a typed null, keeps a text null untyped and reads a part
  of a date by its own YEAR, MONTH and DAY
- a capability says whether SUM keeps its operand's type (SQL Server,
  Derby: an INTEGER column overflows past 2 147 483 647), and
  TO_WIDE_INTEGER widens the operand

Co-authored-by: dbulahov <bulahovdenis@gmail.com>
Signed-off-by: dbulahov <bulahovdenis@gmail.com>
Signed-off-by: Stefan Bischof <stbischof@bipolis.org>
@stbischof
stbischof force-pushed the pr/dialect-fixes-2026-10-31 branch from 056d860 to 91eb3d5 Compare October 31, 2026 09:26
@stbischof
stbischof merged commit 18091e3 into main Oct 31, 2026
5 of 6 checks passed
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.

1 participant