Skip to content

[Compatibility]: projected SET values with an empty member cannot be sorted or grouped #28222

Closed

Description

@Ariznawlll

Is there an existing issue for the same bug?

  • I have checked the existing issues.

No issue was found for the explicit projected-SET limitation.

Branch Name

main

Commit ID

e7bb0572235ec4bac81eb098eb0ad8900f0065ab

Other Environment Information

  • Local standalone MatrixOne
  • Reference: MySQL 8.3.0

Actual Behavior

SET permits an empty member. For SET('', 'a'), bitmap 0 and bitmap 1 both render as an empty string. MatrixOne can order the base-table values and can use them in a window order, but rejects equivalent queries after projection or aggregation:

CREATE TABLE amb(id INT PRIMARY KEY, v SET('', 'a'));
INSERT INTO amb VALUES (1,1), (2,0), (3,2);

SELECT id,v FROM (SELECT id,v FROM amb) d ORDER BY v,id;
-- MatrixOne: ERROR 20105: not supported: definition-order sorting of projected
--            ENUM/SET values with non-unique display labels or ambiguous SET display values
-- MySQL: (2,''), (1,''), (3,'a')

WITH c AS (SELECT id,v FROM amb)
SELECT id,v FROM c ORDER BY v,id;
-- MatrixOne: the same ERROR 20105
-- MySQL: (2,''), (1,''), (3,'a')

SELECT v,COUNT(*) FROM amb GROUP BY v ORDER BY v;
-- MatrixOne: the same ERROR 20105
-- MySQL: ('',2), ('a',1)

SELECT DISTINCT v FROM amb ORDER BY v;
-- MatrixOne: the same ERROR 20105
-- MySQL: (''), ('a')

The four rejected paths reproduced identically in three runs. Direct base-table ordering, a persisted view, a window order, and an explicit character cast remain executable, which narrows the gap to preservation of the raw SET ordering/grouping identity through selected query boundaries.

Expected Behavior

Derived tables, CTEs, GROUP BY, and DISTINCT should preserve enough SET storage identity to execute the same valid queries that MySQL accepts. They should not reject a legal SET definition merely because two bitmaps share a display value.

Steps to Reproduce

CREATE DATABASE ambiguous_set_repro;
USE ambiguous_set_repro;
CREATE TABLE amb(id INT PRIMARY KEY, v SET('', 'a'));
INSERT INTO amb VALUES (1,1), (2,0), (3,2);
SELECT id,v FROM (SELECT id,v FROM amb) d ORDER BY v,id;
WITH c AS (SELECT id,v FROM amb) SELECT id,v FROM c ORDER BY v,id;
SELECT v,COUNT(*) FROM amb GROUP BY v ORDER BY v;
SELECT DISTINCT v FROM amb ORDER BY v;

Additional information

mysql_special_types.go intentionally returns this not supported error when projected display values cannot be inverted unambiguously to their raw ordinal/bitmap. This is therefore a defined implementation limitation rather than a transient execution failure.

Activity

  1. added this to the MO-202609 milestone on Sep 5, 2026
  2. added
    kind/bug
    on Sep 5, 2026
  3. added theissue type on Sep 5, 2026
  4. self-assigned this
    on Sep 5, 2026
  5. added a commit that references this issue on Sep 21, 2026
    f9d89ab
  6. Ariznawlll commented on Sep 21, 2026

    @Ariznawlll
    CollaboratorAuthor

    Verified on current main 57c280e.\n\nProjected SET values with empty members now sort and group correctly: two empty SET values form one group and the non-empty value forms the other group. The result was stable across three runs.\n\nMOTR coverage was added in matrixorigin/motr#193:\nsuites/14_issue_regression/t/issue_28765_28694_28692_28222_compatibility.test.\n\nClosing as fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions