Skip to content
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: add support for duckdb style "FROM <tbl>" statements #1144

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

universalmind303
Copy link
Contributor

allows for parsing of duckdb's from queries

closes #1143

@@ -6722,6 +6726,8 @@ impl<'a> Parser<'a> {
SetExpr::Values(self.parse_values(is_mysql)?)
} else if self.parse_keyword(Keyword::TABLE) {
SetExpr::Table(Box::new(self.parse_as_table()?))
} else if self.parse_keyword(Keyword::FROM) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea why, but adding this branch causes SO in the recursion tests such as parse_deeply_nested_parens_hits_recursion_limits

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even if the branch is never met, the presence of it is causing SO.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe @alamb, @andygrove @nickolay knows why adding this condition causes a SO.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This branch probably makes the stack frame size increase in debug builds as it adds some new local variables. I think we could fix the test by decreasing the recursion limit

Copy link
Collaborator

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this contribution @universalmind303 -- I left some comments that hopefully will help us get this PR good to go

@@ -6722,6 +6726,8 @@ impl<'a> Parser<'a> {
SetExpr::Values(self.parse_values(is_mysql)?)
} else if self.parse_keyword(Keyword::TABLE) {
SetExpr::Table(Box::new(self.parse_as_table()?))
} else if self.parse_keyword(Keyword::FROM) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This branch probably makes the stack frame size increase in debug builds as it adds some new local variables. I think we could fix the test by decreasing the recursion limit

#[test]
fn test_duckdb_from_statement_with_filter_and_select() {
let stmt = duckdb().verified_only_select("FROM t1 SELECT b WHERE a = 1");
println!("{:?}", stmt);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left over?

#[test]
fn test_duckdb_from_statement_with_filter() {
let stmt = duckdb().verified_only_select("FROM t1 WHERE a = 1");
println!("{:?}", stmt);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left over?


/// Parse a duckdb style `FROM` statement without a select.
/// assuming the initial `FROM` was already consumed
pub fn parse_from_select(&mut self) -> Result<Select, ParserError> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems largely copied from the normal select parsing -- is there any way to refactor the code to reduce the duplication

@alamb
Copy link
Collaborator

alamb commented Feb 29, 2024

Marking as Draft to signify this PR is no longer waiting on review. Please mark it as ready for review when it is ready for another look.

@alamb
Copy link
Collaborator

alamb commented Apr 7, 2024

FWIW @Nikita-str has solved the stack overflow issues in #1171 if you wanted to revive this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

duckdb style FROM <tbl> [SELECT] ... syntax
2 participants