-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tables: basic support for hidden column #13908
Conversation
/run-all-tests |
Codecov Report
@@ Coverage Diff @@
## master #13908 +/- ##
===========================================
Coverage 80.3975% 80.3975%
===========================================
Files 483 483
Lines 122449 122449
===========================================
Hits 98446 98446
Misses 16244 16244
Partials 7759 7759 |
0f2c2d5
to
5e7217a
Compare
/run-all-tests |
1 similar comment
/run-all-tests |
a347827
to
76b13f5
Compare
/run-all-tests |
table/tables/tables.go
Outdated
) | ||
|
||
func (t *TableCommon) getCols(mode getColsMode) []*table.Column { | ||
Columns := make([]*table.Column, 0, len(t.Columns)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Columns := make([]*table.Column, 0, len(t.Columns)) | |
columns := make([]*table.Column, 0, len(t.Columns)) |
expression/column.go
Outdated
@@ -201,6 +201,7 @@ type Column struct { | |||
VirtualExpr Expression | |||
|
|||
OrigName string | |||
Hidden bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Hidden/IsHidden/
4d57885
to
77beff5
Compare
LGTM |
for _, col := range t.Columns { | ||
if col.State != model.StatePublic { | ||
continue | ||
} | ||
publicColumns[col.Offset] = col | ||
if maxOffset < col.Offset { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove these codes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous code imply that public column always before non-public column, and set the maxOffset to the last public column. When we intro hidden column, we can't guarantee the visible columns are continuous.
@@ -2373,7 +2373,7 @@ func (d *ddl) DropColumn(ctx sessionctx.Context, ti ast.Ident, spec *ast.AlterTa | |||
|
|||
// Check whether dropped column has existed. | |||
colName := spec.OldColumnName.Name | |||
col := table.FindCol(t.Cols(), colName.L) | |||
col := table.FindCol(t.VisibleCols(), colName.L) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't drop hide columns. Could we do modify column
operation to hide columns?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't modify the hidden column in theory, I will disable this operation in next PR
@Deardrops, @djshow832, @zz-jason, @zimulala, @eurekaka, @XuHuaiyu, @wshwsh12, @lzmhhh123, PTAL. |
b2493b1
to
bd411a0
Compare
@Deardrops, @djshow832, @zz-jason, @zimulala, @eurekaka, @XuHuaiyu, @wshwsh12, @lzmhhh123, PTAL. |
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-all-tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice done.
What problem does this PR solve?
Expression index is based on hidden column.
This PR will basicly support hidden column(insert and other functions will be supported in next few PRs):
ALTER TABLE DROP COLUMN
statement.SHOW CREATE TABLE
statement wouldn't display hidden columns.What is changed and how it works?
VisibleCols
for interfacetable
which will ignore hidden column and replace it withCols
inbuildDatasourece
. Then the hidden columns will not display in plan.schema, and can not be selected, even in order by, group by statement.(2) For
where
andorder by
clause in update statement, we can't skip hidden column inwritableCols
, because we need to fill the assignment and do the update, which need the column infomation of the hidden column. So we skip the hidden column intoColumn
ofexpression_rewriter
.1
is done, hidden column can't be used as delete condition.Cols
withVisibleCols
inDropColumn
, then we can't drop the hidden column.tableInfo.Cols
(Not theCols
mention before) , skip it if it is a hidden column.Check List
Tests
Code changes
Side effects
Related changes
Release note