-
Notifications
You must be signed in to change notification settings - Fork 591
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(frontend): define generated column on table/source with external schema #14644
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,8 @@ macro_rules! impl_fmt_display { | |
pub struct CreateSourceStatement { | ||
pub if_not_exists: bool, | ||
pub columns: Vec<ColumnDef>, | ||
// The wildchar position in columns defined in sql. Only exist when using external schema. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Schema from external connector |
||
pub wildcard_idx: Option<usize>, | ||
pub constraints: Vec<TableConstraint>, | ||
pub source_name: ObjectName, | ||
pub with_properties: WithProperties, | ||
|
@@ -325,7 +327,8 @@ impl ParseTo for CreateSourceStatement { | |
impl_parse_to!(source_name: ObjectName, p); | ||
|
||
// parse columns | ||
let (columns, constraints, source_watermarks) = p.parse_columns_with_watermark()?; | ||
let (columns, constraints, source_watermarks, wildcard_idx) = | ||
p.parse_columns_with_watermark()?; | ||
let include_options = p.parse_include_options()?; | ||
|
||
let with_options = p.parse_with_properties()?; | ||
|
@@ -343,6 +346,7 @@ impl ParseTo for CreateSourceStatement { | |
Ok(Self { | ||
if_not_exists, | ||
columns, | ||
wildcard_idx, | ||
constraints, | ||
source_name, | ||
with_properties: WithProperties(with_options), | ||
|
@@ -357,11 +361,28 @@ pub(super) fn fmt_create_items( | |
columns: &[ColumnDef], | ||
constraints: &[TableConstraint], | ||
watermarks: &[SourceWatermark], | ||
wildcard_idx: Option<usize>, | ||
) -> std::result::Result<String, fmt::Error> { | ||
let mut items = String::new(); | ||
let has_items = !columns.is_empty() || !constraints.is_empty() || !watermarks.is_empty(); | ||
let has_items = !columns.is_empty() | ||
|| !constraints.is_empty() | ||
|| !watermarks.is_empty() | ||
|| wildcard_idx.is_some(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we store the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will be in the sql string in catalog
|
||
has_items.then(|| write!(&mut items, "(")); | ||
write!(&mut items, "{}", display_comma_separated(columns))?; | ||
if let Some(wildcard_idx) = wildcard_idx { | ||
let (columns_l, columns_r) = columns.split_at(wildcard_idx); | ||
write!(&mut items, "{}", display_comma_separated(columns_l))?; | ||
if !columns_l.is_empty() { | ||
write!(&mut items, ", ")?; | ||
} | ||
write!(&mut items, "{}", Token::Mul)?; | ||
if !columns_r.is_empty() { | ||
write!(&mut items, ", ")?; | ||
} | ||
write!(&mut items, "{}", display_comma_separated(columns_r))?; | ||
} else { | ||
write!(&mut items, "{}", display_comma_separated(columns))?; | ||
} | ||
if !columns.is_empty() && (!constraints.is_empty() || !watermarks.is_empty()) { | ||
write!(&mut items, ", ")?; | ||
} | ||
|
@@ -380,7 +401,12 @@ impl fmt::Display for CreateSourceStatement { | |
impl_fmt_display!(if_not_exists => [Keyword::IF, Keyword::NOT, Keyword::EXISTS], v, self); | ||
impl_fmt_display!(source_name, v, self); | ||
|
||
let items = fmt_create_items(&self.columns, &self.constraints, &self.source_watermarks)?; | ||
let items = fmt_create_items( | ||
&self.columns, | ||
&self.constraints, | ||
&self.source_watermarks, | ||
self.wildcard_idx, | ||
)?; | ||
if !items.is_empty() { | ||
v.push(items); | ||
} | ||
|
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.
nit: This TODO should be removed