-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
executor: support "show columns from" for view #8863
Conversation
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.
Any test for this?
@XuHuaiyu |
We'd better add some test cases for it. |
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 |
@XuHuaiyu PTAL |
Codecov Report
@@ Coverage Diff @@
## master #8863 +/- ##
=========================================
Coverage ? 67.54%
=========================================
Files ? 363
Lines ? 75111
Branches ? 0
=========================================
Hits ? 50731
Misses ? 19907
Partials ? 4473
Continue to review full report at Codecov.
|
for _, col := range cols { | ||
viewColumn := viewSchema.FindColumnByName(col.Name.L) | ||
if viewColumn != nil { | ||
col.FieldType = *viewColumn.GetType() |
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 get the column type from the columns returned by tb.Cols()
?
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.
Yes, view's column tableinfo only store column name, so we need to extract sql's schema.column to get column type.
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.
Can we fill the column type info when this table info is generated?
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.
I don't think so, because undertable's column type and column length can be change.
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.
MySQL(root@localhost:test) > create table t(a bigint, b bigint);
Query OK, 0 rows affected (0.04 sec)
MySQL(root@localhost:test) > create view v as select * from t;
Query OK, 0 rows affected (0.07 sec)
MySQL(root@localhost:test) > show columns from v;
+-------+------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------+------+-----+---------+-------+
| a | bigint(20) | YES | | NULL | |
| b | bigint(20) | YES | | NULL | |
+-------+------------+------+-----+---------+-------+
2 rows in set (0.01 sec)
MySQL(root@localhost:test) > drop table t;
Query OK, 0 rows affected (0.03 sec)
MySQL(root@localhost:test) > create table t(a double, b double, c double);
Query OK, 0 rows affected (0.07 sec)
MySQL(root@localhost:test) > show columns from v;
+-------+--------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------+------+-----+---------+-------+
| a | double | YES | | NULL | |
| b | double | YES | | NULL | |
+-------+--------+------+-----+---------+-------+
2 rows in set (0.01 sec)
Got it. Confirmed in MySQL.
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.
@AndrewDi Could you add a comment to specify why we need to build logical plan on the view to get the column types?
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.
Done
2e8077a
to
7abbb96
Compare
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 |
What problem does this PR solve?
Modify
DESCRIBE TABLE
to describe view columnsWhat is changed and how it works?
ref proposal Proposal: Implement View
Check List
Tests
Code changes
Export function
func (b *PlanBuilder) BuildDataSourceFromView(dbName model.CIStr, tableInfo *model.TableInfo)
Side effects
none
This change is