-
Notifications
You must be signed in to change notification settings - Fork 221
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
Support TableFactor::{Derived, Dictionary, Series}
in AstBuilder
#1007
Conversation
Pull Request Test Coverage Report for Build 3592779396
💛 - Coveralls |
6cdc2db
to
b9c370f
Compare
TableFactor
in AstBuilderTableFactor:{Derived, Dictionary, Series}
in AstBuilder
TableFactor:{Derived, Dictionary, Series}
in AstBuilderTableFactor::{Derived, Dictionary, Series}
in AstBuilder
core/src/ast_builder/table.rs
Outdated
impl TableNode { | ||
pub fn alias_as(self, table_alias: &str) -> TableAliasNode { | ||
impl<'a> TableNode<'a> { | ||
pub fn alias_as(self, table_alias: &'a str) -> TableAliasNode { |
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.
pub fn alias_as(self, table_alias: &'a str) -> TableAliasNode { | |
pub fn alias_as(self, table_alias: &str) -> TableAliasNode<'a> { |
I think it is correct to declare this lifetime in TableAliasNode, not in str.
|
||
match object_name.as_str() { | ||
"SERIES" if args.is_some() => Ok(TableFactor::Series { | ||
alias: alias_or_name, | ||
alias: alias_or_name(alias, object_name), | ||
size: translate_table_args(args)?, |
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.
It seems that there is unreachable code inside the translate_table_args
closure, because the value of None
for args will never go into translate_table_args
.
core/src/ast_builder/mod.rs
Outdated
pub fn glue_objects<'a>() -> TableNode<'a> { | ||
TableNode { | ||
table_name: "GLUE_OBJECTS".to_owned(), | ||
table_type: TableType::Dictionary(Dictionary::GlueObjects), | ||
} | ||
} | ||
|
||
pub fn glue_tables<'a>() -> TableNode<'a> { | ||
TableNode { | ||
table_name: "GLUE_TABLES".to_owned(), | ||
table_type: TableType::Dictionary(Dictionary::GlueTables), | ||
} | ||
} | ||
|
||
pub fn glue_indexes<'a>() -> TableNode<'a> { | ||
TableNode { | ||
table_name: "GLUE_INDEXES".to_owned(), | ||
table_type: TableType::Dictionary(Dictionary::GlueIndexes), | ||
} | ||
} | ||
|
||
pub fn glue_table_columns<'a>() -> TableNode<'a> { | ||
TableNode { | ||
table_name: "GLUE_TABLE_COLUMNS".to_owned(), | ||
table_type: TableType::Dictionary(Dictionary::GlueTableColumns), | ||
} | ||
} |
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. except for
series
which takesInto<ExprNode<'a>>
, all has static lifetimes.
e.g.
pub fn glue_table_columns() -> TableNode<'static> { .. }
this would be enough.
- Now table sugar functions are more than a single one, then how about moving these including
series
intotable.rs
module?
core/src/ast_builder/select/root.rs
Outdated
JoinNode::new( | ||
self, | ||
table_name.to_owned(), | ||
Some(alias.to_owned()), | ||
JoinOperatorType::Left, | ||
) | ||
} | ||
|
||
pub fn alias_as(self, table_alias: &'a str) -> TableAliasNode { |
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.
This is too cool feature! Could we have an usage example in test-suite/ ast_builder/select.rs?
c3efb49
to
d881363
Compare
SelectNode to QueryNode
1cdb4bb
to
28d3049
Compare
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.
Awesome 👍 👍 👍
Now we can chain select queries as many as we want.
All looks great! Thanks a lot 👍
Goal
From now, we can use
Dictionary
,SERIES(N)
andDerived subquery
even in AstBuilder!Todo
Box<SelectNode>
Next