Skip to content
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: add comment on clause support #12849

Merged
merged 41 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
8ba0605
fix(over window): fix error in using aggregate function result as win…
jetjinser Sep 26, 2023
0d7caa6
test: add planner_test agg with window function
jetjinser Sep 29, 2023
fc9f48b
test: add e2e_test agg with window function
jetjinser Sep 29, 2023
593706c
test: add more complex agg with window e2e_test
jetjinser Oct 8, 2023
7cd9457
test: fix the agg planner_test query missed agg
jetjinser Oct 8, 2023
3b0645c
test: more complex agg with window planner_test
jetjinser Oct 8, 2023
5e18a8a
test: add "over_window with agg" streaming e2e_test
jetjinser Oct 8, 2023
4147b8c
test: add `group by` to every agg + window query
jetjinser Oct 9, 2023
a7f3dc2
feat: add `comment on` clause support
jetjinser Oct 15, 2023
1a217e3
fix: add license
jetjinser Oct 15, 2023
1e64388
fix(proto): revert tag order to avoid breaking change
jetjinser Oct 15, 2023
fc7e404
refactor: only support comment on `table` and `col`
jetjinser Oct 18, 2023
3772fe6
feat: new `description` field in `describe` result
jetjinser Oct 18, 2023
d32503c
test: update `describe` test
jetjinser Oct 18, 2023
c350d22
Merge branch 'main' into jinser/support-comment
jetjinser Oct 19, 2023
8b38fed
Merge remote-tracking branch 'upstream/main' into jinser/support-comment
jetjinser Oct 19, 2023
7999c4c
chore: add some comment
jetjinser Oct 19, 2023
d6b316a
refactor: use ok_or_else instead of unwrap
jetjinser Oct 19, 2023
6a0f9dd
feat: leave the `describe` description of pk and dk blank
jetjinser Oct 19, 2023
66c736e
Apply suggestions from code review
jetjinser Oct 19, 2023
a37fbde
Update src/frontend/src/catalog/system_catalog/rw_catalog/rw_descript…
jetjinser Oct 19, 2023
a9b64a9
chore: update comment
jetjinser Oct 19, 2023
effe791
refactor(frontend): remove unnecessary pub methods
jetjinser Oct 19, 2023
223f5fe
refactor(frontend): simplify the code
jetjinser Oct 19, 2023
e72854c
Update src/meta/src/manager/catalog/mod.rs
jetjinser Oct 23, 2023
7e151af
feat: resolve schema when `comment on`
jetjinser Oct 23, 2023
d61a60a
fix: add `PgFieldDescriptor` in `infer`
jetjinser Oct 23, 2023
d980bcd
refactor: better error in catalog comment_on
jetjinser Oct 23, 2023
9f9da21
feat: support `pg_description` upon `rw_description`
jetjinser Oct 23, 2023
3b1aeda
refactor: unify order of order `description`
jetjinser Oct 24, 2023
f4ad632
refactor: more specified function `concat`
jetjinser Oct 24, 2023
53ac310
feat: add table description in `describe`
jetjinser Oct 24, 2023
ccd8a91
feat: more consistent comment behavior with pgsql
jetjinser Oct 24, 2023
90ec94c
test: update `pg_description` e2e_test
jetjinser Oct 24, 2023
05fb23b
test: add more `comment on` & `describe` e2e_test
jetjinser Oct 24, 2023
2bf7dd9
refactor: avoid `type_complexity` clippy warning
jetjinser Oct 24, 2023
fd2fb36
Merge remote-tracking branch 'origin/main' into jinser/support-comment
jetjinser Oct 24, 2023
426bc1a
test: up to date `describe`
jetjinser Oct 25, 2023
7741106
Merge remote-tracking branch 'origin/main' into jinser/support-comment
jetjinser Oct 25, 2023
e2872ba
test: typo fix `NULL`
jetjinser Oct 25, 2023
b41c9c6
Merge remote-tracking branch 'origin/main' into jinser/support-comment
jetjinser Oct 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 64 additions & 17 deletions e2e_test/batch/catalog/pg_description.slt.part
Original file line number Diff line number Diff line change
@@ -1,18 +1,65 @@
query IIITT
SELECT d.*, c.relname FROM pg_catalog.pg_description d join pg_catalog.pg_class c on d.objoid = c.oid ORDER BY d.objoid limit 15;
statement ok
create table t(a int, b text, c date);

statement ok
comment on table t is 'Lorem ipsum';

statement ok
comment on column t.a is 'Praesent elementum';

statement ok
comment on column public.t.c is 'Nullam ultricies';

statement ok
comment on column public.t._row_id is 'facilisis enim';

query TIIIT
SELECT
c.relname,
(
SELECT relname FROM pg_catalog.pg_class WHERE oid = d.classoid
) AS classoid,
d.objsubid,
d.description
FROM
pg_catalog.pg_description d
JOIN pg_catalog.pg_class c
ON d.objoid = c.oid
ORDER BY d.objsubid;
----
1 NULL 0 NULL pg_type
2 NULL 0 NULL pg_namespace
3 NULL 0 NULL pg_cast
4 NULL 0 NULL pg_matviews
5 NULL 0 NULL pg_user
6 NULL 0 NULL pg_class
7 NULL 0 NULL pg_index
8 NULL 0 NULL pg_opclass
9 NULL 0 NULL pg_collation
10 NULL 0 NULL pg_am
11 NULL 0 NULL pg_operator
12 NULL 0 NULL pg_views
13 NULL 0 NULL pg_attribute
14 NULL 0 NULL pg_database
15 NULL 0 NULL pg_description
t rw_tables -1 facilisis enim
t rw_tables 0 Lorem ipsum
t rw_tables 1 Praesent elementum
t rw_tables 3 Nullam ultricies

statement ok
comment on table public.t is NULL;

statement ok
comment on column t._row_id is NULL;

statement ok
comment on column t.c is '';

statement ok
comment on column public.t.b is 'Vivamus fermentum';

query TIIIT
SELECT
c.relname,
(
SELECT relname FROM pg_catalog.pg_class WHERE oid = d.classoid
) AS classoid,
d.objsubid,
d.description
FROM
pg_catalog.pg_description d
JOIN pg_catalog.pg_class c
ON d.objoid = c.oid
ORDER BY d.objsubid;
----
t rw_tables 1 Praesent elementum
t rw_tables 2 Vivamus fermentum

statement ok
drop table t;
56 changes: 41 additions & 15 deletions e2e_test/ddl/show.slt
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,28 @@ create materialized view mv3 as select sum(v1) as sum_v1 from t3;
statement ok
create view v3 as select sum(v2) as sum_v2 from t3;

query TTT
statement ok
comment on table t3 is 'volutpat vitae';

statement ok
comment on column t3.v1 is 'turpis vehicula';

statement ok
comment on column t3.v2 is 'Lorem ipsum dolor sit amet';
yezizp2012 marked this conversation as resolved.
Show resolved Hide resolved

statement ok
comment on column public.t3._row_id is 'consectetur adipiscing elit';

query TTTT
describe t3;
----
v1 integer false
v2 integer false
v3 integer false
_row_id serial true
primary key _row_id NULL
distribution key _row_id NULL
v1 integer false turpis vehicula
v2 integer false Lorem ipsum dolor sit amet
v3 integer false NULL
_row_id serial true consectetur adipiscing elit
primary key _row_id NULL NULL
distribution key _row_id NULL NULL
table description t3 NULL volutpat vitae

query TTT
show columns from t3;
Expand All @@ -33,16 +46,29 @@ show indexes from t3;
----
idx1 t3 v1 ASC, v2 ASC v3 v1

query TTT
statement ok
comment on table public.t3 is 'consectetur turpis';

statement ok
comment on column t3.v1 is 'Nemo enim ipsam';

statement ok
comment on column t3.v2 is '';

statement ok
comment on column t3._row_id is NULL;

query TTTT
describe t3;
----
v1 integer false
v2 integer false
v3 integer false
_row_id serial true
primary key _row_id NULL
distribution key _row_id NULL
idx1 index(v1 ASC, v2 ASC) include(v3) distributed by(v1) NULL
v1 integer false Nemo enim ipsam
v2 integer false NULL
v3 integer false NULL
_row_id serial true NULL
primary key _row_id NULL NULL
distribution key _row_id NULL NULL
idx1 index(v1 ASC, v2 ASC) include(v3) distributed by(v1) NULL NULL
table description t3 NULL consectetur turpis

query TT
show create index idx1;
Expand Down
15 changes: 8 additions & 7 deletions e2e_test/extended_mode/basic.slt
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@ values(round(42.4382));
statement ok
create table t3 (v1 int, v2 int, v3 int);

query TTT
query TTTT
describe t3;
----
v1 integer false
v2 integer false
v3 integer false
_row_id serial true
primary key _row_id NULL
distribution key _row_id NULL
v1 integer false NULL
v2 integer false NULL
v3 integer false NULL
_row_id serial true NULL
primary key _row_id NULL NULL
distribution key _row_id NULL NULL
table description t3 NULL NULL

query TTT
show columns from t3;
Expand Down
11 changes: 11 additions & 0 deletions proto/catalog.proto
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ message Table {

CreateType create_type = 32;

// This field is used to store the description set by the `comment on` clause.
optional string description = 33;
stdrc marked this conversation as resolved.
Show resolved Hide resolved

// Per-table catalog version, used by schema change. `None` for internal tables and tests.
// Not to be confused with the global catalog version for notification service.
TableVersion version = 100;
Expand Down Expand Up @@ -317,3 +320,11 @@ message Database {
string name = 2;
uint32 owner = 3;
}

message Comment {
uint32 table_id = 1;
uint32 schema_id = 2;
uint32 database_id = 3;
optional uint32 column_index = 4;
optional string description = 5;
}
10 changes: 10 additions & 0 deletions proto/ddl_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,15 @@ message WaitRequest {}

message WaitResponse {}

message CommentOnRequest {
catalog.Comment comment = 1;
}

message CommentOnResponse {
common.Status status = 1;
uint64 version = 2;
}

service DdlService {
rpc CreateDatabase(CreateDatabaseRequest) returns (CreateDatabaseResponse);
rpc DropDatabase(DropDatabaseRequest) returns (DropDatabaseResponse);
Expand Down Expand Up @@ -348,4 +357,5 @@ service DdlService {
rpc DropConnection(DropConnectionRequest) returns (DropConnectionResponse);
rpc GetTables(GetTablesRequest) returns (GetTablesResponse);
rpc Wait(WaitRequest) returns (WaitResponse);
rpc CommentOn(CommentOnRequest) returns (CommentOnResponse);
}
3 changes: 3 additions & 0 deletions proto/plan_common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ message ColumnDesc {
GeneratedColumnDesc generated_column = 6;
DefaultColumnDesc default_column = 7;
}

// This field is used to store the description set by the `comment on` clause.
optional string description = 8;
stdrc marked this conversation as resolved.
Show resolved Hide resolved
}

message ColumnCatalog {
Expand Down
8 changes: 8 additions & 0 deletions src/common/src/catalog/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ pub struct ColumnDesc {
pub field_descs: Vec<ColumnDesc>,
pub type_name: String,
pub generated_or_default_column: Option<GeneratedOrDefaultColumn>,
pub description: Option<String>,
}

impl ColumnDesc {
Expand All @@ -112,6 +113,7 @@ impl ColumnDesc {
field_descs: vec![],
type_name: String::new(),
generated_or_default_column: None,
description: None,
}
}

Expand All @@ -129,6 +131,7 @@ impl ColumnDesc {
.collect_vec(),
type_name: self.type_name.clone(),
generated_or_default_column: self.generated_or_default_column.clone(),
description: self.description.clone(),
}
}

Expand Down Expand Up @@ -172,6 +175,7 @@ impl ColumnDesc {
field_descs: vec![],
type_name: "".to_string(),
generated_or_default_column: None,
description: None,
}
}

Expand All @@ -192,6 +196,7 @@ impl ColumnDesc {
field_descs: fields,
type_name: type_name.to_string(),
generated_or_default_column: None,
description: None,
}
}

Expand All @@ -206,6 +211,7 @@ impl ColumnDesc {
.map(Self::from_field_without_column_id)
.collect_vec(),
type_name: field.type_name.clone(),
description: None,
generated_or_default_column: None,
}
}
Expand Down Expand Up @@ -243,6 +249,7 @@ impl From<PbColumnDesc> for ColumnDesc {
type_name: prost.type_name,
field_descs,
generated_or_default_column: prost.generated_or_default_column,
description: prost.description.clone(),
}
}
}
Expand All @@ -262,6 +269,7 @@ impl From<&ColumnDesc> for PbColumnDesc {
field_descs: c.field_descs.iter().map(ColumnDesc::to_protobuf).collect(),
type_name: c.type_name.clone(),
generated_or_default_column: c.generated_or_default_column.clone(),
description: c.description.clone(),
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/common/src/catalog/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ pub fn row_id_column_desc() -> ColumnDesc {
field_descs: vec![],
type_name: "".to_string(),
generated_or_default_column: None,
description: None,
}
}

Expand All @@ -131,6 +132,7 @@ pub fn offset_column_desc() -> ColumnDesc {
field_descs: vec![],
type_name: "".to_string(),
generated_or_default_column: None,
description: None,
}
}

Expand Down
1 change: 1 addition & 0 deletions src/common/src/catalog/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ impl ColumnDescTestExt for ColumnDesc {
type_name: type_name.to_string(),
field_descs: fields,
generated_or_default_column: None,
description: None,
}
}
}
1 change: 1 addition & 0 deletions src/compute/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ async fn test_table_materialize() -> StreamResult<()> {
field_descs: vec![],
type_name: "".to_string(),
generated_or_default_column: None,
description: None,
})
.collect_vec();
let (barrier_tx, barrier_rx) = unbounded_channel();
Expand Down
1 change: 1 addition & 0 deletions src/connector/src/parser/avro/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ fn avro_field_to_column_desc(
field_descs: vec_column,
type_name: schema_name.to_string(),
generated_or_default_column: None,
description: None,
})
}
_ => {
Expand Down
1 change: 1 addition & 0 deletions src/connector/src/parser/protobuf/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ impl ProtobufParserConfig {
field_descs,
type_name: m.full_name().to_string(),
generated_or_default_column: None,
description: None,
})
} else {
*index += 1;
Expand Down
1 change: 1 addition & 0 deletions src/connector/src/source/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ impl From<&SourceColumnDesc> for ColumnDesc {
field_descs: s.fields.clone(),
type_name: "".to_string(),
generated_or_default_column: None,
description: None,
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/src/binder/expr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ pub fn bind_struct_field(column_def: &StructField) -> Result<ColumnDesc> {
field_descs: vec![],
type_name: "".to_string(),
generated_or_default_column: None,
description: None,
})
})
.collect::<Result<Vec<_>>>()?
Expand All @@ -589,6 +590,7 @@ pub fn bind_struct_field(column_def: &StructField) -> Result<ColumnDesc> {
field_descs,
type_name: "".to_string(),
generated_or_default_column: None,
description: None,
})
}

Expand Down
Loading
Loading