Skip to content
Snippets Groups Projects
Unverified Commit 710530f9 authored by ou yuanning's avatar ou yuanning Committed by GitHub
Browse files

Add view support (#4459)

add view support in MO

Approved by: @fengttt, @iamlinjunhong, @aunjgr, @daviszhen, @nnsgmsone, @XuPeng-SH, @reusee, @aressu1985
parent 450470f7
No related branches found
No related tags found
No related merge requests found
......@@ -109,11 +109,16 @@ type CommentDef struct {
Comment string
}
type ViewDef struct {
View string
}
type TableDef interface {
tableDef()
}
func (*CommentDef) tableDef() {}
func (*ViewDef) tableDef() {}
func (*AttributeDef) tableDef() {}
func (*IndexTableDef) tableDef() {}
func (*PropertiesDef) tableDef() {}
......
......@@ -218,12 +218,17 @@ message PropertiesDef {
repeated Property properties = 1;
}
message ViewDef {
string view = 1;
}
message TableDef {
message DefType {
oneof def {
PrimaryKeyDef pk = 1;
IndexDef idx = 2;
PropertiesDef properties = 3;
ViewDef view = 4;
}
}
string name = 1;
......
-- @label:bvt
drop table if exists t1;
create table t1 (a int, b int);
create view v1 as select * from t1;
select * from v1;
insert into t1 values (1, 11), (2, 22), (3, 33);
show columns from v1;
select * from v1 where a > 1;
create database db2;
use db2;
select * from view.v1 where a > 1;
use view;
drop database db2;
drop table t1;
select * from v1;
drop table v1;
drop view v1;
\ No newline at end of file
drop table if exists t1;
create table t1 (a int, b int);
create view v1 as select * from t1;
select * from v1;
a b
insert into t1 values (1, 11), (2, 22), (3, 33);
show columns from v1;
Field Type Null Key Default Comment
a INT YES NULL
b INT YES NULL
select * from v1 where a > 1;
a b
2 22
3 33
create database db2;
use db2;
select * from view.v1 where a > 1;
a b
2 22
3 33
use view;
drop database db2;
drop table t1;
select * from v1;
table "t1" does not exist
drop table v1;
table v1 is not exists
drop view v1;
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment