-
Notifications
You must be signed in to change notification settings - Fork 334
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: Modify Column Type #3701
feat: Modify Column Type #3701
Conversation
…ER COLUMN b TYPE varchar(80)`
Nice job🚀
BTW, Should we support both dialects(i.e., |
#3517 mentioned that it supports MySQL dialects as much as possible. I think it is good to only support MySQL. The current PostgreSQL syntax is only for testing |
Run |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3701 +/- ##
==========================================
- Coverage 85.57% 85.25% -0.33%
==========================================
Files 957 962 +5
Lines 159226 160907 +1681
==========================================
+ Hits 136258 137181 +923
- Misses 22968 23726 +758 |
@@ -458,6 +459,118 @@ impl TableMeta { | |||
Ok(meta_builder) | |||
} | |||
|
|||
fn modify_columns( |
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.
non-blocking: Add more tests to cover branches of the modify_columns
(Maybe in another PR)
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.
non-blocking: Let's add the fuzz tests for column type modification(Maybe in another PR).
Since altering column types is a big feature, we might need further discussions and implement it carefully. Could you please describe how you implemented this feature in the issue? We also need to consider the following things:
What's more, I'd suggest implementing this step by step as it also depends on other crates. For example:
|
/// Index in source batch or a default value to fill a column.
#[derive(Debug)]
enum IndexOrDefault {
/// Index of the column in source batch.
Index {
pos: usize,
cast_type: Option<ConcreteDataType>,
},
/// Default value for the column.
DefaultValue {
/// Id of the column.
column_id: ColumnId,
/// Default value. The vector has only 1 element.
default_vector: VectorRef,
},
}
|
What about error handling?
Maybe we can only support a subset of conversion rules that arrow implements.
Modifying the data type of the time index might be helpful. e.g. Alter a timestamp(second) to timestamp(millisecond). But we can support it later. For other engines (file, metric), you could refer to their implementation of the I'm not going to implement It'd be better if we only modify a single crate in each step. e.g.
|
I hereby agree to the terms of the GreptimeDB CLA.
Refer to a related PR or issue link (optional)
#3517
GreptimeTeam/greptime-proto#146
What's changed and what's your intention?
Support:
ALTER TABLE <table_name> ALTER COLUMN <column_name> TYPE <data_type>;
ref: https://www.postgresql.org/docs/current/sql-altertable.html
Tips 1: sql parser does not support
Modify Column
temporarily, I have created a PR: apache/datafusion-sqlparser-rs#1216Tips 2: I temporarily use my own fork of
greptime-proto
, and then replace it after merging it at GreptimeTeam/greptime-proto#146Checklist