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

Support cache/uncache table syntax #670

Merged
merged 2 commits into from Oct 15, 2022
Merged

Conversation

francis-du
Copy link
Contributor

Close #669

@coveralls
Copy link

coveralls commented Oct 13, 2022

Pull Request Test Coverage Report for Build 3249154694

  • 299 of 331 (90.33%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.01%) to 85.833%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/ast/mod.rs 23 33 69.7%
tests/sqlparser_common.rs 217 227 95.59%
src/parser.rs 59 71 83.1%
Totals Coverage Status
Change from base Build 3227007003: 0.01%
Covered Lines: 10724
Relevant Lines: 12494

💛 - Coveralls

src/ast/mod.rs Outdated
@@ -1430,6 +1430,19 @@ pub enum Statement {
// Specifies the actions to perform when values match or do not match.
clauses: Vec<MergeClause>,
},
/// CACHE TABLE <table_name> [[AS] [QUERY]]
Copy link
Collaborator

Choose a reason for hiding this comment

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

What database is this meant to follow? It doesn't seem to follow Spark's syntax

https://docs.databricks.com/spark/latest/spark-sql/language-manual/sql-ref-syntax-aux-cache-cache-table.html

How is it different than a CREATE VIEW statement?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the doc, I will support the full Cache table syntax.

The difference between CACHE TABLE and CREATE VIEW is that users can cache small tables in memory before Join to speed up queries, such as dimension tables in data warehouse.The View should not be able to do this if it is not in memory.

}]),
args: vec![FunctionArg::Unnamed(FunctionArgExpr::Expr(zero.clone()))],
over: None,
distinct: false,
special: false,
})),
time_zone: "UTC-06:00".to_string()
time_zone: "UTC-06:00".to_string(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't mind the , everywhere but it sure makes the diff a lot bigger ;)

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 think this one is from the latest cargo fmt

@francis-du
Copy link
Contributor Author

@alamb Hi Andrew, could you review this PR again, if you have time. I have supported the full syntax.

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.

Looks good to me -- thanks @francis-du !

},
SqlOption {
name: Ident::with_quote('\'', "K2"),
value: number("0.88"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@@ -5810,3 +5813,249 @@ fn parse_show_functions() {
}
);
}

#[test]
fn parse_cache_table() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

giphy
👍

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.

Support cache/uncache table syntax
3 participants