-
Notifications
You must be signed in to change notification settings - Fork 4.1k
sql: permit user-defined hidden columns #53428
Copy link
Copy link
Closed
Labels
C-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)good first issue
Description
SQL supports hidden columns: columns that are only included in a projection if explicitly requested. An example of this is the rowid column that is created on tables without explicitly primary keys.
Currently, there is no way to get a hidden column on a user-defined table: it's only possible if you manually set the hidden boolean in the table descriptor, by editing the CockroachDB source code.
It could conceivably be useful for users to define hidden columns on their own tables. This issue tracks adding that functionality. It should be pretty straightforward, and reasonably suitable for a new contributor.
- Add an NOT VISIBLE keyword to
pkg/sql/parser/sql.yas an optional modifier to columns for creation and modification. e.g.CREATE TABLE a (a INT NOT VISIBLE),ALTER TABLE a ALTER COLUMN a SET [NOT] VISIBLEsql: support NOT VISIBLE in CREATE TABLE for user-defined hidden columns #58923 - Add a NOT VISIBLE attribute to
ColumnTableDefinpkg/sql/sem/tree/create.gosql: support NOT VISIBLE in CREATE TABLE for user-defined hidden columns #58923 - Update
MakeColumnDefDescsinpkg/sql/catalog/tabledesc/table.goto setHiddenon the column descriptor if the attribute above is set sql: support NOT VISIBLE in CREATE TABLE for user-defined hidden columns #58923 - Add
AlterTableSetHiddenAST nodes topkg/sql/sem/tree/alter_table.go - Add cases for those AST nodes in
pkg/sql/alter_table.go - Add logic tests that verify that hidden columns work as expected. A good place for these would be in
pkg/sql/logictest/testdata/logic_test/hidden. sql: support NOT VISIBLE in CREATE TABLE for user-defined hidden columns #58923
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)good first issue