-
Notifications
You must be signed in to change notification settings - Fork 465
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
storage/sources: Implement 'CREATE TABLE .. FROM SOURCE' parsing and planning for Kafka sources #29383
storage/sources: Implement 'CREATE TABLE .. FROM SOURCE' parsing and planning for Kafka sources #29383
Changes from all commits
b5fa7f3
aa88dd0
c675218
2f8f23c
f635591
a0ac3b6
56fc57d
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 |
---|---|---|
|
@@ -1010,6 +1010,7 @@ impl<T: AstInfo> AstDisplay for CreateSourceStatement<T> { | |
f.write_str(" FROM "); | ||
f.write_node(&self.connection); | ||
if let Some(format) = &self.format { | ||
f.write_str(" "); | ||
f.write_node(format); | ||
} | ||
if !self.include_metadata.is_empty() { | ||
|
@@ -1263,6 +1264,7 @@ impl<T: AstInfo> AstDisplay for CreateSinkStatement<T> { | |
f.write_str(" INTO "); | ||
f.write_node(&self.connection); | ||
if let Some(format) = &self.format { | ||
f.write_str(" "); | ||
f.write_node(format); | ||
} | ||
if let Some(envelope) = &self.envelope { | ||
|
@@ -1560,8 +1562,11 @@ pub struct CreateTableFromSourceStatement<T: AstInfo> { | |
pub constraints: Vec<TableConstraint<T>>, | ||
pub if_not_exists: bool, | ||
pub source: T::ItemName, | ||
pub external_reference: UnresolvedItemName, | ||
pub external_reference: Option<UnresolvedItemName>, | ||
pub with_options: Vec<TableFromSourceOption<T>>, | ||
pub include_metadata: Vec<SourceIncludeMetadata>, | ||
pub format: Option<FormatSpecifier<T>>, | ||
pub envelope: Option<SourceEnvelope>, | ||
} | ||
|
||
impl<T: AstInfo> AstDisplay for CreateTableFromSourceStatement<T> { | ||
|
@@ -1574,6 +1579,9 @@ impl<T: AstInfo> AstDisplay for CreateTableFromSourceStatement<T> { | |
external_reference, | ||
if_not_exists, | ||
with_options, | ||
include_metadata, | ||
format, | ||
envelope, | ||
} = self; | ||
f.write_str("CREATE TABLE "); | ||
if *if_not_exists { | ||
|
@@ -1592,10 +1600,24 @@ impl<T: AstInfo> AstDisplay for CreateTableFromSourceStatement<T> { | |
} | ||
f.write_str(" FROM SOURCE "); | ||
f.write_node(source); | ||
f.write_str(" (REFERENCE = "); | ||
f.write_node(external_reference); | ||
f.write_str(")"); | ||
if let Some(external_reference) = external_reference { | ||
f.write_str(" (REFERENCE = "); | ||
f.write_node(external_reference); | ||
f.write_str(")"); | ||
} | ||
|
||
if let Some(format) = &format { | ||
f.write_str(" "); | ||
f.write_node(format); | ||
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. I saw that the ast printing of 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. Makes sense - pushed a commit to address this |
||
} | ||
if !include_metadata.is_empty() { | ||
f.write_str(" INCLUDE "); | ||
f.write_node(&display::comma_separated(include_metadata)); | ||
} | ||
if let Some(envelope) = &envelope { | ||
f.write_str(" ENVELOPE "); | ||
f.write_node(envelope); | ||
} | ||
if !with_options.is_empty() { | ||
f.write_str(" WITH ("); | ||
f.write_node(&display::comma_separated(with_options)); | ||
|
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.
Does this PR implement the thing where if no external reference is provided and it's unambiguous it's accepted? I didn't see any test like that added but this change looks like we accept it now?
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.
Discussed offline - it only implements that for Kafka and single-output load generator sources which only ever expose one output to reference. Will submit a future PR to make this uniform across all source types, such that you can omit a reference on a MySQL or Postgres source that only has one upstream table to ingest