Skip to content

feat: support MySQL SET columns - #23936

Merged
mergify[bot] merged 15 commits into
matrixorigin:mainfrom
robll-v1:issue/23912
Mar 25, 2026
Merged

mergify[bot] merged 15 commits into
matrixorigin:mainfrom
robll-v1:issue/23912

Conversation

@robll-v1

@robll-v1 robll-v1 commented Mar 23, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • BUG
  • API-change
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #23912

Closes #23912

What this PR does / why we need it:

  • add MySQL SET value parsing and normalization on top of uint64 bitmaps
  • preserve SET metadata across planner casts, DDL/DML, SHOW CREATE TABLE, DESC, information_schema, CTAS, and LOAD DATA
  • validate ALTER TABLE ... MODIFY COLUMN when the SET member list changes
  • allow table-defined secondary indexes on SET columns
  • preserve enum/set definition-order sorting for SELECT DISTINCT ... ORDER BY ...
  • add planner regression coverage and SET BVT coverage for secondary-index and DISTINCT ordering cases

Validation:

  • go test ./pkg/container/types -run 'Test(NormalizeSetValues|ParseSet|ParseSetIndex|NormalizeSetValuesMaxMembers)'
  • env GOCACHE=/tmp/matrixone-go-cache go test ./pkg/sql/plan -run 'Test_isSameColumnType|TestQueryBuilder_bindOrderByEnum|TestQueryBuilder_bindOrderByEnumDistinct'
  • env GOCACHE=/tmp/matrixone-go-cache go test ./pkg/sql/colexec/external -run TestDummyDoesNotExist
  • SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk CPLUS_INCLUDE_PATH=/usr/local/var/homebrew/tmp/.cellar/llvm@21/21.1.8/include/c++/v1 env GOCACHE=/tmp/matrixone-go-cache make build
  • cd /Users/moukeyu/mo-tester && ./run.sh -m genrs -p /Users/moukeyu/matrixone-23912/test/distributed/cases/dtype/set.sql
  • cd /Users/moukeyu/mo-tester && ./run.sh -p /Users/moukeyu/matrixone-23912/test/distributed/cases/dtype/set.sql -g
  • [SUMMARY] COST : 0s, TOTAL :56, SUCCESS : 56, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@matrix-meow matrix-meow added the size/XL Denotes a PR that changes [1000, 1999] lines label Mar 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds end-to-end support for the MySQL SET column type by representing SET as a uint64 bitmap plus persisted member metadata, and threading that metadata through planning/binding, DDL/DML, SHOW/INFORMATION_SCHEMA, and LOAD DATA.

Changes:

  • Add SET parsing/normalization in pkg/container/types and expose planner/runtime cast functions for value↔bitmap conversions.
  • Preserve SET metadata across casts and planner operations (ORDER BY, DISTINCT/window ORDER BY handling, CTAS, ALTER/MODIFY, UPDATE/INSERT paths).
  • Extend sysviews and distributed tests/resources to validate SET behavior (including charset and LOAD DATA coverage).

Reviewed changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/distributed/resources/load_data/set_bad.csv Adds invalid SET CSV row used for LOAD DATA error-path coverage.
test/distributed/resources/load_data/set.csv Adds valid SET CSV rows for LOAD DATA coverage.
test/distributed/cases/zz_accesscontrol/account_restricted.result Updates expected INFORMATION_SCHEMA.COLUMNS view definition output for enum/set-aware display.
test/distributed/cases/dtype/set.sql New distributed SQL suite covering SET DDL/DML, ORDER BY/DISTINCT/GROUP BY, ALTER MODIFY, CTAS, and LOAD DATA.
test/distributed/cases/dtype/set.result Expected results for the new SET distributed suite.
test/distributed/cases/dml/show/show.result Updates expected INFORMATION_SCHEMA.COLUMNS view definition output for enum/set-aware display.
test/distributed/cases/charset_collation/charset_collation_advanced.result Updates charset advanced expected output and adds coverage where SET with utf8mb4 is now supported.
pkg/util/sysview/predefined.go Updates INFORMATION_SCHEMA.COLUMNS view SQL to show ENUM/SET types via attr_enum + mo_show_visible_bin_enum.
pkg/sql/plan/tools.go Adds internal function-name constants for SET cast helpers.
pkg/sql/plan/query_builder.go Extends ORDER BY “unwrap” logic to also cover SET (and avoids project-append when DISTINCT is active).
pkg/sql/plan/projection_binder.go Unwraps enum/set cast_index_to_* for window ORDER BY to sort by underlying stored value.
pkg/sql/plan/mysql_special_types.go New helper module to identify ENUM/SET plan types and centralize wrapping/cast function selection.
pkg/sql/plan/make.go Adds SET cast support; tightens isSameColumnType to include Enumvalues for accurate type equality.
pkg/sql/plan/function/list_builtIn.go Registers new builtins: cast_index_to_set_value, cast_set_value_to_index, cast_set_index_value_to_index.
pkg/sql/plan/function/function_id_test.go Updates expected function-id map to include new SET cast function IDs.
pkg/sql/plan/function/function_id.go Adds new function IDs and registers SET cast function names.
pkg/sql/plan/function/func_mo.go Implements runtime execution logic for SET cast functions using types.ParseSet*.
pkg/sql/plan/function/func_builtin.go Extends mo_show_visible_bin_enum to support SET display formatting.
pkg/sql/plan/build_util.go Adds AST type resolution for MYSQL_TYPE_SET, storing member list in Type.Enumvalues on T_uint64.
pkg/sql/plan/build_update.go Extends UPDATE rewrite/cast logic to include SET and refactors enum/set wrapping via shared helpers.
pkg/sql/plan/build_show_util.go Formats SET column types for SHOW/DDL output using Enumvalues metadata.
pkg/sql/plan/build_ddl.go Preserves SET metadata for CTAS/select-derived columns by recognizing SET cast wrapper functions.
pkg/sql/plan/build_constraint_util.go Extends INSERT/value-scan casting paths to handle SET (and avoids premature numeric const handling for enum/set).
pkg/sql/plan/build_alter_table.go Ensures NOT NULL default generation treats SET (stored as uint64) correctly.
pkg/sql/plan/build_alter_modify_column.go Treats SET similarly to ENUM for compatibility checks during ALTER/MODIFY.
pkg/sql/plan/build_alter_add_column.go Blocks SET columns from primary/unique keys (consistent with existing enum restrictions).
pkg/sql/plan/bind_update.go Extends UPDATE binding logic to wrap/cast SET values and reuse shared enum/set wrapping helper.
pkg/sql/plan/bind_insert.go Extends INSERT/REPLACE value casting paths to handle SET.
pkg/sql/plan/base_binder.go Wraps SET column references similarly to ENUM so projection shows the MySQL-visible string form.
pkg/sql/colexec/external/external.go Adds LOAD DATA validation/parsing for SET columns stored as uint64 + member metadata.
pkg/container/types/set_test.go Adds unit tests for set normalization, parsing, bitmap-to-string conversion, and max member limits.
pkg/container/types/set.go Implements SET normalization and parsing/formatting based on uint64 bitmaps.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/distributed/cases/dtype/set.sql Resolved
@robll-v1

Copy link
Copy Markdown
Contributor Author
  • isSameColumnType

    Fixed in 572c8c8. The final fallback now returns false when width/scale differ, and I added targeted tests to
    cover width, scale, and Enumvalues mismatches.

    I am not changing this one. The enum-path change is intentional: after tightening same-type checks to consider
    Enumvalues, the enum-specific cast must stamp expr.Typ back to the target enum type, otherwise it can fall through
    into the generic cast path.

    • SET secondary index

    I am leaving this as-is for this PR. This is a broader product/compatibility gap rather than a regression
    introduced by [Feature Request]: Support MySQL SET data type #23912, and MatrixOne already applies similar restrictions to ENUM index paths. Enabling secondary
    indexes for SET needs a separate design pass.

    • DISTINCT + ORDER BY

    Agreed that this is a compatibility tradeoff rather than a correctness bug. I kept the current guard to avoid the
    DISTINCT->AGG binding failure, and added a TODO in query_builder to preserve enum/set index ordering in a follow-up
    change.

@mergify

mergify Bot commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-03-25 08:41 UTC · Rule: main
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged — 2026-03-25 08:41 UTC · at d051d7faacabb9de37dc8c7702401e733d293bd5

This pull request spent 7 seconds in the queue, with no time running CI.

Required conditions to merge
  • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
  • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • branch-protection-review-decision = APPROVED [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-neutral = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-skipped = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Ubuntu/x86
    • check-neutral = Matrixone CI / SCA Test on Ubuntu/x86
    • check-skipped = Matrixone CI / SCA Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-neutral = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-skipped = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
  • any of [🛡 GitHub branch protection]:
    • check-skipped = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage

This branch was previously deployed

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

Labels

kind/bug Something isn't working kind/feature size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Support MySQL SET data type

8 participants