-
Notifications
You must be signed in to change notification settings - Fork 609
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
refactor(types): remove type_name
and field_descs
from ColumnDesc
#20497
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
18b4236
to
27c218b
Compare
0f64462
to
feb234b
Compare
27c218b
to
0165303
Compare
a2384d4
to
71e92b9
Compare
0165303
to
6d40b4b
Compare
71e92b9
to
a95541c
Compare
6d40b4b
to
81b85ca
Compare
961e7ed
to
10e177a
Compare
// TODO(struct): since we deprecated `field_descs` in `ColumnDesc`, there's no need to | ||
// traverse the fields here except for maintaining the same column id (index) as the | ||
// original implementation. | ||
let _field_descs = if let DataType::List { .. } = field_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.
As a result, there's no information for the "column" id of the nested fields, which seems to make resolving #19755 even more challenging. I may reintroduce it in future PRs, but in a clearer manner.
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.
Just to confirm, does it mean that we will only be able to alter subfields for newly created structs? 🤔
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.
Not that true as if we really want this to be available on existing tables, we can introduce a "mini" multi-versioned schema for the STRUCT
type when we are going to upgrade its storage representation for compatibility purposes.
@@ -128,27 +126,14 @@ pub struct ColumnDesc { | |||
|
|||
impl ColumnDesc { | |||
pub fn unnamed(column_id: ColumnId, data_type: DataType) -> ColumnDesc { |
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.
Maybe we could rename it to unnamed_for_test
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.
Or just for_test
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 was confused when we have unnamed
column, and found it's just in tests.
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.
Counting on @xiangjinwu! 😁
src/common/src/catalog/column.rs
Outdated
/// Should only be used for observability/debugging purposes. | ||
pub fn flatten(&self) -> Vec<ColumnDesc> { |
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.
Should only be used for observability/debugging purposes.
I think for these we should always name it like xxx_for_debug
to avoid misuse. Because developers don't always read docs. 🤣
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.
Currently, there is only one caller in the handler for DESCRIBE table
. I might update it in the future to stop returning ColumnDesc
, which would prevent potential misuse.
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.
update it in the future to stop returning
ColumnDesc
, which would prevent potential misuse.
Agree. Or it can be moved as part of describe
's implementation, rather than a reusable method on common::catalog::column::ColumnDesc
.
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.
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.
Generally LGTM
145a308
to
144ede2
Compare
10e177a
to
9fabe05
Compare
src/common/src/catalog/column.rs
Outdated
/// Should only be used for observability/debugging purposes. | ||
pub fn flatten(&self) -> Vec<ColumnDesc> { |
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.
update it in the future to stop returning
ColumnDesc
, which would prevent potential misuse.
Agree. Or it can be moved as part of describe
's implementation, rather than a reusable method on common::catalog::column::ColumnDesc
.
pub fn new_struct( | ||
name: &str, | ||
column_id: i32, | ||
type_name: &str, | ||
_type_name: &str, | ||
fields: Vec<ColumnDesc>, | ||
) -> Self { | ||
// TODO(struct): assign type name to the struct once supported | ||
let data_type = | ||
StructType::new(fields.iter().map(|f| (&f.name, f.data_type.clone()))).into(); | ||
Self { | ||
data_type, | ||
column_id: ColumnId::new(column_id), | ||
name: name.to_owned(), | ||
field_descs: fields, | ||
type_name: type_name.to_owned(), | ||
generated_or_default_column: None, | ||
description: None, | ||
additional_column: AdditionalColumn { column_type: None }, | ||
version: ColumnDescVersion::LATEST, | ||
system_column: None, | ||
} | ||
|
||
Self::named(name, ColumnId::new(column_id), data_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.
I will deprecate this in favor of named
as well.
additional_column: c.additional_column.clone().into(), | ||
version: c.version as i32, | ||
} | ||
c.to_protobuf() |
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.
Did not notice such duplication 🤯
// TODO(struct): since we deprecated `field_descs` in `ColumnDesc`, there's no need to | ||
// traverse the fields here except for maintaining the same column id (index) as the | ||
// original implementation. |
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.
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.
Actually, because we always reassign the ColumnId
in the final step of creating a source or table, there's no need to allocate a column ID here (but simply specifying ColumnId::placeholder()
), unless we need the uniqueness property of ColumnId
before that step.
144ede2
to
46a2007
Compare
9fabe05
to
a8a61d6
Compare
285bc59
to
08fa368
Compare
Merge activity
|
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
08fa368
to
d2bddd4
Compare
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
The follow-up to #20496.
ColumnDesc
is simplyField
with some extra information.field_descs
will be generated on the fly based on theStructType
when it's used inDESCRIBE
. Resolve #17128.Checklist
Documentation
Release note