Skip to content

COUNT(DISTINCT *) is accepted and returns 1 for any number of rows #2758

Open

Description

@mathiasrw

COUNT(DISTINCT *) is accepted and returns 1. SQLite rejects it as a syntax error. Seen in the sqllogictest run (evidence/slt_lang_aggfunc.test), reproduced on develop (06211a0):

alasql('CREATE TABLE t1 (x INTEGER, y STRING)');
alasql("INSERT INTO t1 VALUES (1, 'true'), (0, 'false'), (NULL, 'NULL')");
alasql('SELECT COUNT(DISTINCT *) AS n FROM t1');   // [{n: 1}] for three different rows

Fix (4.x)

Count the distinct rows: 3 here. The answer is wrong today, so counting distinct rows does not break anyone.

Not changed

COUNT(DISTINCT *) stays accepted. Making it a syntax error, as SQLite does, would break code that runs it today; at most it belongs in the sqlite dialect, and is not tracked separately.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions