Skip to content

dialect(mssqlserver): fixes, tested on SQL Server in Docker - #101

Merged
stbischof merged 2 commits into
eclipse-daanse:mainfrom
dbulahov:main241126_2
Nov 24, 2026
Merged

stbischof merged 2 commits into
eclipse-daanse:mainfrom
dbulahov:main241126_2

Conversation

@dbulahov

Copy link
Copy Markdown
Contributor

What does this PR do?

dialect(mssqlserver): fixes, tested on SQL Server in Docker

Checked on SQL Server 2017, 2019, 2022 and 2025 in Docker, the dialect
built from a live connection.

MicrosoftSqlServerDialect:

  • supportsPercentileDisc/Cont: false, generatePercentileDisc/Cont empty;
    SQL Server has PERCENTILE_DISC/CONT only as window functions, "must
    have an OVER clause" (Msg 10753), so the aggregate always failed
  • generateListAgg: NULLS FIRST/LAST ranked with a CASE, SQL Server has
    no NULLS (syntax error); a quote in the separator doubled, broke the
    statement; the operand as NVARCHAR(MAX) and the separator N'...', the
    list stopped at 8000 bytes (Msg 9829)
  • mergeGenerator: MERGE INTO t WITH (HOLDLOCK); two connections upserting
    the same new key at once both inserted, one failing on the primary key
  • createSequence: with ifNotExists guarded by sys.sequences, SQL Server
    has no CREATE SEQUENCE IF NOT EXISTS (syntax error)
  • dropTable: with ifExists OBJECT_ID(N'"s"."t"', N'U') of the quoted
    name; a name of a quote broke the statement
  • createTrigger: a WHEN condition refused (UnsupportedOperationException);
    SQL Server has no WHEN, and left out the trigger fired for every row

MicrosoftSqlServerGeneratorsTest: MERGE with HOLDLOCK

Container tests:

  • MsSqlPercentileTest: no percentile aggregate, the server refuses one;
    the window form over a partition works
  • MsSqlListAggTest: STRING_AGG ordered, NULLS FIRST/LAST, separators,
    INT and Unicode, longer than 8000 bytes, per group; no DISTINCT
  • MsSqlMergeGeneratorTest: upsert with and without update columns,
    composite key, a quote and Unicode, 8 connections upserting at once
  • MsSqlCreateFunctionTest, MsSqlCreateProcedureTest: created, called,
    OR ALTER replaces the body and keeps the object and its grants; OUT
    and INOUT parameters, no parameters, an inline table function
  • MsSqlDropFunctionIfExistsTest, MsSqlDropProcedureIfExistsTest: IF
    EXISTS, named without types; a schema-bound view and a routine of the
    other kind of the name not passed over
  • MsSqlSequenceTest: options, CYCLE, NO CYCLE, a column default, IF NOT
    EXISTS, rename (refused with a dependent default), drop; no options
    start at the least BIGINT
  • MsSqlDropIfExistsTest: DROP TABLE of names of a quote, a dot, a blank;
    DROP VIEW, INDEX ... ON, SCHEMA IF EXISTS; a schema that holds a table
  • MsSqlTriggerProcedureTest: trigger procedure created and replaced,
    called after insert, update, delete; WHEN refused, written into the
    body instead
  • MsSqlDropTriggerProcedureTest: dropped of a schema, of none, of a
    quote in the name; one a trigger calls dropped, the trigger then fails

DuckDB is embedded and serves no connection: the tests run the CLI of
each version in Docker (duckdb/duckdb 1.0.0 to 2.0.1) on the SQL the
dialect writes, the dialect built for the version the CLI reports.

DuckDbDialect:
- generateListAgg: DISTINCT kept with an order by the value itself, was
  left out with any ORDER BY; a quote in the separator doubled, broke
  the statement; " ORDER BY" spaced, was "nameORDER BY" without one
- generatePercentileDisc/Cont: PERCENTILE_DISC/CONT(p) WITHIN GROUP
  (ORDER BY col [DESC]); quantile_disc/cont(col, p) took no order, so a
  descending percentile came out ascending
- supportsNthValueIgnoreNulls: true, the list is filtered with
  FILTER (WHERE v IS NOT NULL); was false

pom: testcontainers junit-jupiter (test), DOCKER_HOST for surefire

Container tests:
- DuckDbCli: runs the CLI of a tag, files put into the container, the
  version checked against the tag; an error counts by stderr too, the
  CLI of 1.2.0 to 1.2.2 exits with 0 on one
- DuckDbGroupingSetsTest: GROUPING SETS, ROLLUP, CUBE, GROUPING()
- DuckDbListAggTest: STRING_AGG ordered, DISTINCT, separators, NULLS
  FIRST/LAST, per group; DISTINCT by another column refused by DuckDB
- DuckDbPercentileTest: PERCENTILE_DISC/CONT ascending, descending, at
  the ends, per group
- DuckDbNthValueContainerTest: n-th value counting or leaving out
  NULLs, past the end, n below 1, order, per group
- DuckDbBitAggregationTest: AND, OR, XOR, NAND, NOR, NXOR on INTEGER
  and BIGINT past 32 bits, per group, NULLs alone
- DuckDbRenameTest: table and column renamed, refused with an index
  (Dependency Error); no index or constraint rename
- DuckDbAddConstraintTest: unique, check and foreign key in CREATE
  TABLE, enforced; ALTER TABLE ADD refused, ADD UNIQUE from 2.0 only
  while no table refers to it
- DuckDbBulkLoadTest: read_csv of the importer's files, values kept as
  written, delimiters, quotes, NULL literals, skip lines, defaults, a
  large file; a # line left out from 1.1, refused by 1.0

Signed-off-by: <bulahovdenis@gmail.com>
Checked on SQL Server 2017, 2019, 2022 and 2025 in Docker, the dialect
built from a live connection.

MicrosoftSqlServerDialect:
- supportsPercentileDisc/Cont: false, generatePercentileDisc/Cont empty;
  SQL Server has PERCENTILE_DISC/CONT only as window functions, "must
  have an OVER clause" (Msg 10753), so the aggregate always failed
- generateListAgg: NULLS FIRST/LAST ranked with a CASE, SQL Server has
  no NULLS (syntax error); a quote in the separator doubled, broke the
  statement; the operand as NVARCHAR(MAX) and the separator N'...', the
  list stopped at 8000 bytes (Msg 9829)
- mergeGenerator: MERGE INTO t WITH (HOLDLOCK); two connections upserting
  the same new key at once both inserted, one failing on the primary key
- createSequence: with ifNotExists guarded by sys.sequences, SQL Server
  has no CREATE SEQUENCE IF NOT EXISTS (syntax error)
- dropTable: with ifExists OBJECT_ID(N'"s"."t"', N'U') of the quoted
  name; a name of a quote broke the statement
- createTrigger: a WHEN condition refused (UnsupportedOperationException);
  SQL Server has no WHEN, and left out the trigger fired for every row

MicrosoftSqlServerGeneratorsTest: MERGE with HOLDLOCK

Container tests:
- MsSqlPercentileTest: no percentile aggregate, the server refuses one;
  the window form over a partition works
- MsSqlListAggTest: STRING_AGG ordered, NULLS FIRST/LAST, separators,
  INT and Unicode, longer than 8000 bytes, per group; no DISTINCT
- MsSqlMergeGeneratorTest: upsert with and without update columns,
  composite key, a quote and Unicode, 8 connections upserting at once
- MsSqlCreateFunctionTest, MsSqlCreateProcedureTest: created, called,
  OR ALTER replaces the body and keeps the object and its grants; OUT
  and INOUT parameters, no parameters, an inline table function
- MsSqlDropFunctionIfExistsTest, MsSqlDropProcedureIfExistsTest: IF
  EXISTS, named without types; a schema-bound view and a routine of the
  other kind of the name not passed over
- MsSqlSequenceTest: options, CYCLE, NO CYCLE, a column default, IF NOT
  EXISTS, rename (refused with a dependent default), drop; no options
  start at the least BIGINT
- MsSqlDropIfExistsTest: DROP TABLE of names of a quote, a dot, a blank;
  DROP VIEW, INDEX ... ON, SCHEMA IF EXISTS; a schema that holds a table
- MsSqlTriggerProcedureTest: trigger procedure created and replaced,
  called after insert, update, delete; WHEN refused, written into the
  body instead
- MsSqlDropTriggerProcedureTest: dropped of a schema, of none, of a
  quote in the name; one a trigger calls dropped, the trigger then fails
Signed-off-by: <bulahovdenis@gmail.com>
@stbischof
stbischof merged commit 8aa60ee into eclipse-daanse:main Nov 24, 2026
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.

2 participants