-
Notifications
You must be signed in to change notification settings - Fork 589
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
feat: introduce generated columns #8700
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
a2712f7
add generated column in proto
yuhao-su a60f9f2
Merge branch 'main' of github.com:singularity-data/risingwave into yu…
yuhao-su f3e387c
refactor
yuhao-su e5710ea
new for stream
yuhao-su d539b1d
conflict
yuhao-su c03eae4
work
yuhao-su 101bbb7
conflict
yuhao-su 78887f6
dashboard
yuhao-su 5911091
conflict
yuhao-su 087caf5
fix
yuhao-su aea9de9
Merge branch 'main' of github.com:singularity-data/risingwave into yu…
yuhao-su 28ff462
add tests; ban detele and create source with generated columns
yuhao-su 8381627
new line
yuhao-su cb843d6
what file
yuhao-su 618c84d
new line
yuhao-su eb2e7e0
fix
yuhao-su 656f4ec
ban alter table with generated column
yuhao-su 8faa387
fix
yuhao-su File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,261 +1 @@ | ||
# Create a table. | ||
statement ok | ||
create table ddl_t (v1 int); | ||
|
||
statement ok | ||
explain select v1 from ddl_t; | ||
|
||
# Create another table with duplicated name. | ||
statement error | ||
create table ddl_t (v2 int); | ||
|
||
# Create a table using a empty string. | ||
statement error | ||
create table ""(v2 int); | ||
|
||
statement ok | ||
create table if not exists ddl_t (v2 int); | ||
|
||
# Drop the table. | ||
statement ok | ||
drop table ddl_t; | ||
|
||
# Drop it again. | ||
statement error | ||
drop table ddl_t; | ||
|
||
# Create another table with the same name. | ||
statement ok | ||
create table ddl_t (v2 int); | ||
|
||
statement ok | ||
explain select v2 from ddl_t; | ||
|
||
# Create a mview on top of it. | ||
statement ok | ||
create materialized view ddl_mv as select v2 from ddl_t; | ||
|
||
statement ok | ||
explain select v2 from ddl_t; | ||
|
||
statement ok | ||
explain create sink sink_t from ddl_t with ( connector = 'kafka', type = 'append-only', force_append_only = 'true' ); | ||
|
||
statement ok | ||
explain create sink sink_as as select sum(v2) as sum from ddl_t with ( connector = 'kafka', type = 'append-only', force_append_only = 'true' ); | ||
|
||
# Create a mview with duplicated name. | ||
statement error | ||
create materialized view ddl_mv as select v2 from ddl_t; | ||
|
||
# Drop the table before dropping the mview. | ||
statement error | ||
drop table ddl_t; | ||
|
||
# We're not allowed to drop the mview using `DROP TABLE`. | ||
statement error | ||
drop table ddl_mv; | ||
|
||
# Drop the mview. | ||
statement ok | ||
drop materialized view ddl_mv; | ||
|
||
# Drop it again. | ||
statement error | ||
drop materialized view ddl_mv; | ||
|
||
# We're not allowed to drop the table using `DROP MATERIALIZED VIEW`. | ||
statement error | ||
drop materialized view ddl_t; | ||
|
||
# Now, we can drop the base table. | ||
statement ok | ||
drop table ddl_t; | ||
|
||
# Create table concludes struct column. | ||
statement ok | ||
create table st (v1 int, v2 struct<v1 int, v2 struct<v1 int, v2 int>>); | ||
|
||
statement ok | ||
drop table st | ||
|
||
# We test the case sensitivity of table name and column name. | ||
statement ok | ||
create table t1 (v1 int); | ||
|
||
statement ok | ||
drop table T1; | ||
|
||
statement ok | ||
create table T1 (v1 int); | ||
|
||
statement ok | ||
drop table t1; | ||
|
||
statement ok | ||
create table "T1" (v1 int); | ||
|
||
# Since we have not really bound the columns in the insert statement | ||
# this test case cannot be enabled. | ||
# statement error | ||
# insert into "T1" ("V1") values (1); | ||
|
||
statement error | ||
drop table t1; | ||
|
||
statement error | ||
drop table T1; | ||
|
||
statement ok | ||
drop table "T1"; | ||
|
||
statement ok | ||
create table "T2" ("V1" int); | ||
|
||
# Since we have not really bound the columns in the insert statement | ||
# this test case cannot be enabled. | ||
# statement error | ||
# insert into "T2" (V1) values (1); | ||
|
||
statement ok | ||
insert into "T2" ("V1") values (1); | ||
|
||
statement ok | ||
drop table "T2" | ||
|
||
statement error | ||
create table C1 (c1 varchar(5)); | ||
|
||
statement error | ||
create table t (v1 int not null); | ||
|
||
statement error | ||
create table t (v1 varchar collate "en_US"); | ||
|
||
# Test create-table-as | ||
statement ok | ||
create table t as select 1; | ||
|
||
statement ok | ||
drop table t; | ||
|
||
statement error | ||
create table t as select 1,2; | ||
|
||
statement ok | ||
create table t as select 1 as a, 2 as b; | ||
|
||
statement ok | ||
drop table t; | ||
|
||
statement ok | ||
create table t(v1) as select 1; | ||
|
||
statement ok | ||
drop table t; | ||
|
||
statement ok | ||
create table t (v1 int,v2 int); | ||
|
||
statement ok | ||
insert into t values (1,1); | ||
|
||
statement ok | ||
insert into t values (1,1); | ||
|
||
statement ok | ||
insert into t values (1,1); | ||
|
||
statement ok | ||
flush | ||
|
||
statement ok | ||
create table t1 as select * from t; | ||
|
||
statement ok | ||
flush; | ||
|
||
query I | ||
select * from t1; | ||
---- | ||
1 1 | ||
1 1 | ||
1 1 | ||
|
||
statement ok | ||
drop table t1; | ||
|
||
statement ok | ||
drop table t; | ||
|
||
statement ok | ||
create table t AS SELECT * FROM generate_series(0, 5,1) tbl(i); | ||
|
||
statement ok | ||
flush; | ||
|
||
query I | ||
select * from t order by i; | ||
---- | ||
0 | ||
1 | ||
2 | ||
3 | ||
4 | ||
5 | ||
|
||
statement ok | ||
drop table t; | ||
|
||
statement ok | ||
create table t (v1 int); | ||
|
||
statement ok | ||
insert into t values (1); | ||
|
||
statement ok | ||
insert into t values (2); | ||
|
||
statement ok | ||
create table n1 as select sum(v1) from t; | ||
|
||
statement ok | ||
flush; | ||
|
||
query I | ||
select * from n1; | ||
---- | ||
3 | ||
|
||
statement error | ||
create table n1 (v2 int); | ||
|
||
statement error | ||
create table n1 as select * from t; | ||
|
||
statement ok | ||
create table if not exists n1 (v2 int); | ||
|
||
statement ok | ||
drop table n1; | ||
|
||
statement ok | ||
drop table t; | ||
|
||
statement ok | ||
create table t (v1 int,v2 int); | ||
|
||
statement ok | ||
create table t1(a,b) as select v1,v2 from t; | ||
|
||
statement ok | ||
create table t2(a) as select v1,v2 from t; | ||
|
||
statement ok | ||
drop table t; | ||
|
||
statement ok | ||
drop table t1; | ||
|
||
statement ok | ||
drop table t2; | ||
include ./table/*.slt.part |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Create a table with generated columns. | ||
statement ok | ||
create table t1 (v1 int as v2-1, v2 int, v3 int as v2+1); | ||
|
||
statement ok | ||
insert into t1 (v2) values (1), (2); | ||
|
||
statement ok | ||
flush; | ||
|
||
query III | ||
select * from t1; | ||
---- | ||
0 1 2 | ||
1 2 3 | ||
|
||
statement ok | ||
drop table t1; | ||
|
||
# Create a table with generated columns. | ||
statement ok | ||
create table t2 (v1 int, v2 int as v1+1); | ||
|
||
statement ok | ||
insert into t2 values (1), (2); | ||
|
||
statement ok | ||
flush; | ||
|
||
query II | ||
select * from t2; | ||
---- | ||
1 2 | ||
2 3 | ||
|
||
statement ok | ||
drop table t2; | ||
|
||
# Generated column reference another generated column | ||
statement error | ||
create table t2 (v1 int as v2+1, v2 int, v3 int as v1-1); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
As a Postgres-compatible database, I think we should also follow its syntax and it's improper to borrow from Flink here. FYI, in Postgres:
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.
AS is a flink syntax. We can use it as a syntax sugar. I will add the
generated always as
in later PRs.