Skip to content

Add INVISIBLE column constraint for MySQL.#7510

Merged
VaggelisD merged 2 commits intotobymao:mainfrom
burnison:add_invisible_column_mysql
Apr 17, 2026
Merged

Add INVISIBLE column constraint for MySQL.#7510
VaggelisD merged 2 commits intotobymao:mainfrom
burnison:add_invisible_column_mysql

Conversation

@burnison
Copy link
Copy Markdown
Contributor

MySQL 8.0.23 introduced invisible columns, declared with the INVISIBLE keyword in column definitions. Until now, sqlglot could parse ALTER TABLE ... ALTER COLUMN ... SET INVISIBLE (PR #4809) and ALTER TABLE ... ALTER INDEX ... INVISIBLE (PR #4800), but the keyword was not recognized in column definitions. This meant CREATE TABLE t (c INT INVISIBLE) and ALTER TABLE t ADD COLUMN c INT INVISIBLE both failed to parse.

This commit adds InvisibleColumnConstraint, following the same pattern as AutoIncrementColumnConstraint and ZeroFillColumnConstraint. The constraint is MySQL-specific and is registered in the MySQL dialect's CONSTRAINT_PARSERS. The generator emits the bare INVISIBLE keyword via an inline lambda in TRANSFORMS.

Note that SHOW CREATE TABLE emits invisible columns using MySQL's version-comment syntax (/*!80023 INVISIBLE */), which the tokenizer treats as a comment. This commit does not address that; it only supports the bare keyword in input DDL.

MySQL 8.0.23 introduced invisible columns, declared with the `INVISIBLE`
keyword in column definitions. Until now, sqlglot could parse `ALTER
TABLE ... ALTER COLUMN ... SET INVISIBLE` (PR tobymao#4809) and `ALTER TABLE
... ALTER INDEX ... INVISIBLE` (PR tobymao#4800), but the keyword was not
recognized in column definitions. This meant `CREATE TABLE t (c INT
INVISIBLE)` and `ALTER TABLE t ADD COLUMN c INT INVISIBLE` both failed
to parse.

This commit adds `InvisibleColumnConstraint`, following the same pattern
as `AutoIncrementColumnConstraint` and `ZeroFillColumnConstraint`. The
constraint is MySQL-specific and is registered in the MySQL dialect's
`CONSTRAINT_PARSERS`. The generator emits the bare `INVISIBLE` keyword
via an inline lambda in `TRANSFORMS`.

Note that `SHOW CREATE TABLE` emits invisible columns using MySQL's
version-comment syntax (`/*!80023 INVISIBLE */`), which the tokenizer
treats as a comment. This commit does not address that; it only supports
the bare keyword in input DDL.
Copy link
Copy Markdown
Collaborator

@VaggelisD VaggelisD left a comment

Choose a reason for hiding this comment

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

Thank you for the PR! Had one nit but it's good to go

Comment thread tests/dialects/test_mysql.py
@VaggelisD VaggelisD merged commit 6678ee0 into tobymao:main Apr 17, 2026
2 of 8 checks passed
@VaggelisD VaggelisD mentioned this pull request Apr 17, 2026
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