Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upsql: permit user-defined hidden columns #53428
Comments
|
I'd like to take a stab at implementing this, if that's cool. |
|
You're more than welcome to, Jason! Thanks. |
|
There might be some gotchas that we'll find out along the way. I think there might be some assertions lurking around that |
|
I don't think that's true - didn't you just add the |
|
No, that was only within the optimizer's representation of tables. |
|
Hmm, ok. I think the hash sharded index columns are also marked hidden though, unless I'm missing something there too ( |
|
There was a draft implementation here: #26644 |
|
That PR incidentally makes the case that it's needed to implement certain pg_catalog tables that also have hidden columns. Also the approach at the top of this issue has a flaw. Look at the linked PR:
|


SQL supports hidden columns: columns that are only included in a projection if explicitly requested. An example of this is the
rowidcolumn 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.
pkg/sql/parser/sql.yas an optional modifier to columns for creation and modification. e.g.CREATE TABLE a (a INT HIDDEN),ALTER TABLE a ALTER COLUMN a [SET|DROP] HIDDENColumnTableDefinpkg/sql/sem/tree/create.goMakeColumnDefDescsinpkg/sql/catalog/tabledesc/table.goto setHiddenon the column descriptor if the attribute above is setAlterTableSetHiddenAST nodes topkg/sql/sem/tree/alter_table.gopkg/sql/alter_table.gopkg/sql/logictest/testdata/logic_test/hidden.