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 3 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
17 changes: 17 additions & 0 deletions proto/catalog.proto
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ message Source {

optional uint64 initialized_at_epoch = 15;
optional uint64 created_at_epoch = 16;
optional string description = 17;

// Per-source catalog version, used by schema change.
uint64 version = 100;
Expand Down Expand Up @@ -140,6 +141,7 @@ message Sink {
string sink_from_name = 18;
StreamJobStatus stream_job_status = 19;
SinkFormatDesc format_desc = 20;
optional string description = 21;
}

message Connection {
Expand All @@ -164,6 +166,7 @@ message Connection {
PrivateLinkService private_link_service = 5;
}
uint32 owner = 6;
optional string description = 7;
}

message Index {
Expand All @@ -182,6 +185,7 @@ message Index {
optional uint64 initialized_at_epoch = 10;
optional uint64 created_at_epoch = 11;
StreamJobStatus stream_job_status = 12;
optional string description = 13;
}

message Function {
Expand All @@ -204,6 +208,8 @@ message Function {
message ScalarFunction {}
message TableFunction {}
message AggregateFunction {}

optional string description = 14;
}

// See `TableCatalog` struct in frontend crate for more information.
Expand Down Expand Up @@ -280,6 +286,8 @@ message Table {

CreateType create_type = 32;

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 All @@ -303,17 +311,26 @@ message View {
repeated uint32 dependent_relations = 8;
// User-specified column names.
repeated plan_common.Field columns = 9;
optional string description = 10;
}

message Schema {
uint32 id = 1;
uint32 database_id = 2;
string name = 3;
uint32 owner = 4;
optional string description = 5;
}

message Database {
uint32 id = 1;
string name = 2;
uint32 owner = 3;
optional string description = 4;
}

message Comment {
uint32 table_id = 1;
uint32 column_index = 2;
optional string description = 3;
}
12 changes: 12 additions & 0 deletions proto/ddl_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,17 @@ message GetTablesResponse {
map<uint32, catalog.Table> tables = 1;
}

message CreateCommentRequest {
uint32 table_id = 1;
uint32 column_index = 2;
optional string comment = 3;
}

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

service DdlService {
rpc CreateDatabase(CreateDatabaseRequest) returns (CreateDatabaseResponse);
rpc DropDatabase(DropDatabaseRequest) returns (DropDatabaseResponse);
Expand Down Expand Up @@ -342,5 +353,6 @@ service DdlService {
rpc CreateConnection(CreateConnectionRequest) returns (CreateConnectionResponse);
rpc ListConnections(ListConnectionsRequest) returns (ListConnectionsResponse);
rpc DropConnection(DropConnectionRequest) returns (DropConnectionResponse);
rpc CreateComment(CreateCommentRequest) returns (CreateCommentResponse);
rpc GetTables(GetTablesRequest) returns (GetTablesResponse);
}
2 changes: 2 additions & 0 deletions proto/plan_common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ message ColumnDesc {
GeneratedColumnDesc generated_column = 6;
DefaultColumnDesc default_column = 7;
}

optional string description = 8;
stdrc marked this conversation as resolved.
Show resolved Hide resolved
}

message ColumnCatalog {
Expand Down
2 changes: 2 additions & 0 deletions proto/stream_plan.proto
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ message SinkDesc {
// it is the name of the sink itself.
string sink_from_name = 12;
catalog.SinkFormatDesc format_desc = 13;

optional string description = 14;
}

enum SinkLogStoreType {
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 @@ -128,6 +130,7 @@ impl ColumnDesc {
.map(|f| f.to_protobuf())
.collect_vec(),
type_name: self.type_name.clone(),
description: self.description.clone(),
generated_or_default_column: self.generated_or_default_column.clone(),
jetjinser marked this conversation as resolved.
Show resolved Hide resolved
}
}
Expand Down Expand Up @@ -171,6 +174,7 @@ impl ColumnDesc {
name: name.to_string(),
field_descs: vec![],
type_name: "".to_string(),
description: None,
generated_or_default_column: None,
}
}
Expand All @@ -191,6 +195,7 @@ impl ColumnDesc {
name: name.to_string(),
field_descs: fields,
type_name: type_name.to_string(),
description: None,
generated_or_default_column: 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 @@ -242,6 +248,7 @@ impl From<PbColumnDesc> for ColumnDesc {
name: prost.name,
type_name: prost.type_name,
field_descs,
description: prost.description.clone(),
generated_or_default_column: prost.generated_or_default_column,
}
}
Expand All @@ -261,6 +268,7 @@ impl From<&ColumnDesc> for PbColumnDesc {
name: c.name.clone(),
field_descs: c.field_descs.iter().map(ColumnDesc::to_protobuf).collect(),
type_name: c.type_name.clone(),
description: c.description.clone(),
generated_or_default_column: c.generated_or_default_column.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 @@ -109,6 +109,7 @@ pub fn row_id_column_desc() -> ColumnDesc {
name: row_id_column_name(),
field_descs: vec![],
type_name: "".to_string(),
description: None,
generated_or_default_column: None,
}
}
Expand All @@ -130,6 +131,7 @@ pub fn offset_column_desc() -> ColumnDesc {
name: offset_column_name(),
field_descs: vec![],
type_name: "".to_string(),
description: None,
generated_or_default_column: 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 @@ -56,6 +56,7 @@ impl ColumnDescTestExt for ColumnDesc {
name: name.to_string(),
type_name: type_name.to_string(),
field_descs: fields,
description: None,
generated_or_default_column: None,
}
}
Expand Down
1 change: 1 addition & 0 deletions src/compute/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ async fn test_table_materialize() -> StreamResult<()> {
name: field.name,
field_descs: vec![],
type_name: "".to_string(),
description: None,
generated_or_default_column: None,
})
.collect_vec();
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 @@ -56,6 +56,7 @@ fn avro_field_to_column_desc(
name: name.to_owned(),
field_descs: vec_column,
type_name: schema_name.to_string(),
description: None,
generated_or_default_column: 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 @@ -196,6 +196,7 @@ impl ProtobufParserConfig {
column_type: Some(field_type.to_protobuf()),
field_descs,
type_name: m.full_name().to_string(),
description: None,
generated_or_default_column: None,
})
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/connector/src/sink/catalog/desc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ pub struct SinkDesc {
/// Name of the "table" field for Debezium. If the sink is from table or mv,
/// it is the name of table/mv. Otherwise, it is the name of the sink.
pub sink_from_name: String,

pub description: Option<String>,
}

impl SinkDesc {
Expand Down Expand Up @@ -95,6 +97,7 @@ impl SinkDesc {
initialized_at_epoch: None,
db_name: self.db_name,
sink_from_name: self.sink_from_name,
description: None,
}
}

Expand All @@ -116,6 +119,7 @@ impl SinkDesc {
format_desc: self.format_desc.as_ref().map(|f| f.to_proto()),
db_name: self.db_name.clone(),
sink_from_name: self.sink_from_name.clone(),
description: self.description.clone(),
}
}
}
4 changes: 4 additions & 0 deletions src/connector/src/sink/catalog/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ pub struct SinkCatalog {

/// Name for the table info for Debezium sink
pub sink_from_name: String,

pub description: Option<String>,
}

impl SinkCatalog {
Expand Down Expand Up @@ -330,6 +332,7 @@ impl SinkCatalog {
db_name: self.db_name.clone(),
sink_from_name: self.sink_from_name.clone(),
stream_job_status: PbStreamJobStatus::Creating.into(),
description: self.description.clone(),
}
}

Expand Down Expand Up @@ -418,6 +421,7 @@ impl From<PbSink> for SinkCatalog {
initialized_at_epoch: pb.initialized_at_epoch.map(Epoch::from),
db_name: pb.db_name,
sink_from_name: pb.sink_from_name,
description: pb.description.clone(),
}
}
}
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 @@ -122,6 +122,7 @@ impl From<&SourceColumnDesc> for ColumnDesc {
name: s.name.clone(),
field_descs: s.fields.clone(),
type_name: "".to_string(),
description: None,
generated_or_default_column: 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 @@ -589,6 +589,7 @@ pub fn bind_struct_field(column_def: &StructField) -> Result<ColumnDesc> {
name: f.name.real_value(),
field_descs: vec![],
type_name: "".to_string(),
description: None,
generated_or_default_column: None,
jetjinser marked this conversation as resolved.
Show resolved Hide resolved
})
})
Expand All @@ -602,6 +603,7 @@ pub fn bind_struct_field(column_def: &StructField) -> Result<ColumnDesc> {
name: column_def.name.real_value(),
field_descs,
type_name: "".to_string(),
description: None,
generated_or_default_column: None,
jetjinser marked this conversation as resolved.
Show resolved Hide resolved
})
}
Expand Down
22 changes: 22 additions & 0 deletions src/frontend/src/catalog/catalog_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ pub trait CatalogWriter: Send + Sync {
connection: create_connection_request::Payload,
) -> Result<()>;

async fn create_comment(
&self,
table_id: TableId,
column_index: u32,
comment: Option<String>,
) -> Result<()>;

async fn drop_table(
&self,
source_id: Option<u32>,
Expand Down Expand Up @@ -162,6 +169,7 @@ impl CatalogWriter for CatalogWriterImpl {
name: db_name.to_string(),
id: 0,
owner,
description: None,
})
.await?;
self.wait_version(version).await
Expand All @@ -180,6 +188,7 @@ impl CatalogWriter for CatalogWriterImpl {
name: schema_name.to_string(),
database_id: db_id,
owner,
description: None,
})
.await?;
self.wait_version(version).await
Expand Down Expand Up @@ -282,6 +291,19 @@ impl CatalogWriter for CatalogWriterImpl {
self.wait_version(version).await
}

async fn create_comment(
&self,
TableId { table_id }: TableId,
column_index: u32,
comment: Option<String>,
) -> Result<()> {
let version = self
.meta_client
.create_comment(table_id, column_index, comment)
.await?;
self.wait_version(version).await
}

async fn drop_table(
&self,
source_id: Option<u32>,
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/src/catalog/connection_catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub struct ConnectionCatalog {
pub name: String,
pub info: connection::Info,
pub owner: UserId,
pub description: Option<String>,
}

impl ConnectionCatalog {
Expand All @@ -55,6 +56,7 @@ impl From<&PbConnection> for ConnectionCatalog {
name: prost.name.clone(),
info: prost.info.clone().unwrap(),
owner: prost.owner,
description: prost.description.clone(),
}
}
}
Expand Down
Loading
Loading