Skip to content

Implement Hive QL Parsing #235

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

Merged
merged 101 commits into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
ae3a271
First pass on some create table, and some analyze table parsing
hntd187 Jul 21, 2020
24782fb
First pass on some create table, and some analyze table parsing
hntd187 Jul 21, 2020
aa5fbd0
Speculative WITH (...) INSERT
hntd187 Jul 22, 2020
a2fdaf0
Speculative debugging assistance
hntd187 Jul 23, 2020
388984a
Speculative debugging assistance
hntd187 Jul 23, 2020
368fa95
Remove debugging assistance and speculative double equals fix
hntd187 Jul 23, 2020
0181680
Remove debugging assistance and speculative double equals fix
hntd187 Jul 23, 2020
df21533
Fix partition clauses with values
hntd187 Jul 23, 2020
9733e2e
Add spaceship operator
hntd187 Jul 23, 2020
88d7b69
cargo fmt
hntd187 Jul 23, 2020
64b3953
fix some lints and tests, add purge on tables ad proper formatting fo…
hntd187 Jul 24, 2020
5b79539
Fix a lint, add CREATE TABLE ... LIKE ...
hntd187 Jul 24, 2020
c1d4cbe
cargo fmt
hntd187 Jul 24, 2020
18050aa
Fixed a lint
hntd187 Jul 24, 2020
77092e6
Address some PR changes
hntd187 Jul 25, 2020
f444959
Disabled hive dialect from SQL common for now, added to the dialect t…
hntd187 Jul 27, 2020
b53d78e
Cargo fmt
hntd187 Jul 27, 2020
d076d41
Support for ALTER TABLE with PARTITION
hntd187 Jul 28, 2020
b6c545d
Support for ALTER TABLE DROP IF EXISTS
hntd187 Jul 28, 2020
78b53dc
Support CLUSTER BY and JOIN with no join condition
hntd187 Jul 28, 2020
c56cfcc
Support for columns defined after partition
hntd187 Jul 28, 2020
3db166d
Support ANALYZE FOR COLUMNS
hntd187 Jul 28, 2020
a9e2e30
Support numeric literals ending with 'L'
hntd187 Jul 28, 2020
eccb86d
Support CREATE [TEMP|TEMPORARY] TABLE
hntd187 Jul 28, 2020
d2c9344
Support DIRECTORY INSERTS
hntd187 Jul 29, 2020
946d108
Support LATERAL VIEW and DISTRIBUTE BY
hntd187 Jul 29, 2020
5fa4be0
Add Dan's suggestion to the tokenizer and re-enable tests
hntd187 Jul 29, 2020
4b6653b
Speculative array index for function call
hntd187 Jul 29, 2020
ccfbee3
Make file format optional for directory inserts
hntd187 Jul 29, 2020
307a371
Allow multiple aliases in LATERAL VIEW
hntd187 Jul 29, 2020
5bcd4c3
Allow multiple lateral views and an insanely janky implementation for…
hntd187 Jul 29, 2020
4328a2d
All multiple quote styles for directory paths
hntd187 Jul 29, 2020
c15e958
Speculative test on table properties
hntd187 Jul 29, 2020
6abd52b
Spell keyword tblproperties correctly this time
hntd187 Jul 29, 2020
3c2b0b2
Fix issue with multiple lateral views and no aliases
hntd187 Jul 30, 2020
c26d77f
Rebase, fix lints, removed some janky array element parsing that just…
hntd187 Jul 31, 2020
e23af40
Merge branch 'main' into hive
hntd187 Jul 31, 2020
1515e63
Reenable some identifier parts in dialect, support LATERAL VIEW OUTER
hntd187 Jul 31, 2020
ce0d86f
Cargo fmt
hntd187 Jul 31, 2020
35945e1
Add license to hive.rs
hntd187 Jul 31, 2020
9f981a5
Allow ommitting add/drop/sync partitions in msck
hntd187 Jul 31, 2020
6cbd11c
Fix a bigdecimal compile error
hntd187 Jul 31, 2020
25515d9
Re-add dollar sign for idents
hntd187 Aug 1, 2020
5630f24
Support SORT BY in selects
hntd187 Aug 2, 2020
445860d
Fix ALTER TABLE RENAME TO as taking an ident when should take an Obje…
hntd187 Aug 3, 2020
c5058a9
Merge branch 'main' into hive
hntd187 Aug 11, 2020
c45592f
First pass on some create table, and some analyze table parsing
hntd187 Jul 21, 2020
9bdd021
First pass on some create table, and some analyze table parsing
hntd187 Jul 21, 2020
ff19e20
Speculative WITH (...) INSERT
hntd187 Jul 22, 2020
a290f5f
Speculative debugging assistance
hntd187 Jul 23, 2020
2a567c1
Speculative debugging assistance
hntd187 Jul 23, 2020
39a73d2
Remove debugging assistance and speculative double equals fix
hntd187 Jul 23, 2020
5bb533f
Remove debugging assistance and speculative double equals fix
hntd187 Jul 23, 2020
df7c30a
Fix partition clauses with values
hntd187 Jul 23, 2020
bb6f700
Add spaceship operator
hntd187 Jul 23, 2020
2cf808a
cargo fmt
hntd187 Jul 23, 2020
c671a29
fix some lints and tests, add purge on tables ad proper formatting fo…
hntd187 Jul 24, 2020
00b5d93
Fix a lint, add CREATE TABLE ... LIKE ...
hntd187 Jul 24, 2020
695b1a0
cargo fmt
hntd187 Jul 24, 2020
6cc9056
Fixed a lint
hntd187 Jul 24, 2020
c22e7fb
Address some PR changes
hntd187 Jul 25, 2020
2a53953
Disabled hive dialect from SQL common for now, added to the dialect t…
hntd187 Jul 27, 2020
7eab40a
Cargo fmt
hntd187 Jul 27, 2020
0d6abd4
Support for ALTER TABLE with PARTITION
hntd187 Jul 28, 2020
38b4539
Support for ALTER TABLE DROP IF EXISTS
hntd187 Jul 28, 2020
c3eb4d4
Support CLUSTER BY and JOIN with no join condition
hntd187 Jul 28, 2020
292f00b
Support for columns defined after partition
hntd187 Jul 28, 2020
7a3144f
Support ANALYZE FOR COLUMNS
hntd187 Jul 28, 2020
02a568b
Support numeric literals ending with 'L'
hntd187 Jul 28, 2020
57f111a
Support CREATE [TEMP|TEMPORARY] TABLE
hntd187 Jul 28, 2020
e078f65
Support DIRECTORY INSERTS
hntd187 Jul 29, 2020
6fd9d3f
Support LATERAL VIEW and DISTRIBUTE BY
hntd187 Jul 29, 2020
7983e47
Add Dan's suggestion to the tokenizer and re-enable tests
hntd187 Jul 29, 2020
19e4e97
Speculative array index for function call
hntd187 Jul 29, 2020
5e57789
Make file format optional for directory inserts
hntd187 Jul 29, 2020
6d76abc
Allow multiple aliases in LATERAL VIEW
hntd187 Jul 29, 2020
109363c
Allow multiple lateral views and an insanely janky implementation for…
hntd187 Jul 29, 2020
42fb1b9
All multiple quote styles for directory paths
hntd187 Jul 29, 2020
425cab6
Speculative test on table properties
hntd187 Jul 29, 2020
77fcdb2
Spell keyword tblproperties correctly this time
hntd187 Jul 29, 2020
37d77c4
Fix issue with multiple lateral views and no aliases
hntd187 Jul 30, 2020
5ccc447
Rebase, fix lints, removed some janky array element parsing that just…
hntd187 Jul 31, 2020
f1e04ee
Reenable some identifier parts in dialect, support LATERAL VIEW OUTER
hntd187 Jul 31, 2020
84e96c5
Cargo fmt
hntd187 Jul 31, 2020
0af9e5f
Add license to hive.rs
hntd187 Jul 31, 2020
27a91de
Allow ommitting add/drop/sync partitions in msck
hntd187 Jul 31, 2020
b4ea1ee
Fix a bigdecimal compile error
hntd187 Jul 31, 2020
4161565
Re-add dollar sign for idents
hntd187 Aug 1, 2020
ada1fe6
Support SORT BY in selects
hntd187 Aug 2, 2020
982c073
Fix ALTER TABLE RENAME TO as taking an ident when should take an Obje…
hntd187 Aug 3, 2020
97db91f
Fix WITH AS for Hive
hntd187 Dec 2, 2020
0b7d18f
Fix WITH AS for Hive, merge from upstream
hntd187 Dec 2, 2020
b1a561e
Merge remote-tracking branch 'origin/hive' into hive
hntd187 Dec 2, 2020
5e3c02c
Fix a lint
hntd187 Dec 2, 2020
3f7d421
Cargo fmt
hntd187 Dec 2, 2020
d964dd8
map access on a column
hntd187 Feb 2, 2021
9d9d681
support from style ctes
hntd187 Feb 4, 2021
671fa3c
merge conflicts fix
hntd187 Feb 4, 2021
b885469
Fix some clippy warnings
hntd187 Feb 4, 2021
0f7c976
Merge branch 'main' of https://github.com/ballista-compute/sqlparser-…
hntd187 Feb 4, 2021
349d758
Merge from main
hntd187 Feb 4, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ $ cargo run --feature json_example --example cli FILENAME.sql [--dialectname]
"--postgres" => Box::new(PostgreSqlDialect {}),
"--ms" => Box::new(MsSqlDialect {}),
"--snowflake" => Box::new(SnowflakeDialect {}),
"--hive" => Box::new(HiveDialect {}),
"--generic" | "" => Box::new(GenericDialect {}),
s => panic!("Unexpected parameter: {}", s),
};
Expand Down
3 changes: 3 additions & 0 deletions src/ast/data_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ pub enum DataType {
Regclass,
/// Text
Text,
/// String
String,
/// Bytea
Bytea,
/// Custom type such as enums
Expand Down Expand Up @@ -101,6 +103,7 @@ impl fmt::Display for DataType {
DataType::Interval => write!(f, "INTERVAL"),
DataType::Regclass => write!(f, "REGCLASS"),
DataType::Text => write!(f, "TEXT"),
DataType::String => write!(f, "STRING"),
DataType::Bytea => write!(f, "BYTEA"),
DataType::Array(ty) => write!(f, "{}[]", ty),
DataType::Custom(ty) => write!(f, "{}", ty),
Expand Down
43 changes: 42 additions & 1 deletion src/ast/ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,54 @@ pub enum AlterTableOperation {
if_exists: bool,
cascade: bool,
},
/// `RENAME TO PARTITION (partition=val)`
RenamePartitions {
old_partitions: Vec<Expr>,
new_partitions: Vec<Expr>,
},
/// Add Partitions
AddPartitions {
if_not_exists: bool,
new_partitions: Vec<Expr>,
},
DropPartitions {
partitions: Vec<Expr>,
if_exists: bool,
},
/// `RENAME [ COLUMN ] <old_column_name> TO <new_column_name>`
RenameColumn {
old_column_name: Ident,
new_column_name: Ident,
},
/// `RENAME TO <table_name>`
RenameTable { table_name: Ident },
RenameTable { table_name: ObjectName },
}

impl fmt::Display for AlterTableOperation {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
AlterTableOperation::AddPartitions {
if_not_exists,
new_partitions,
} => write!(
f,
"ADD{ine} PARTITION ({})",
display_comma_separated(new_partitions),
ine = if *if_not_exists { " IF NOT EXISTS" } else { "" }
),
AlterTableOperation::AddConstraint(c) => write!(f, "ADD {}", c),
AlterTableOperation::AddColumn { column_def } => {
write!(f, "ADD COLUMN {}", column_def.to_string())
}
AlterTableOperation::DropPartitions {
partitions,
if_exists,
} => write!(
f,
"DROP{ie} PARTITION ({})",
display_comma_separated(partitions),
ie = if *if_exists { " IF EXISTS" } else { "" }
),
AlterTableOperation::DropConstraint { name } => write!(f, "DROP CONSTRAINT {}", name),
AlterTableOperation::DropColumn {
column_name,
Expand All @@ -63,6 +95,15 @@ impl fmt::Display for AlterTableOperation {
column_name,
if *cascade { " CASCADE" } else { "" }
),
AlterTableOperation::RenamePartitions {
old_partitions,
new_partitions,
} => write!(
f,
"PARTITION ({}) RENAME TO PARTITION ({})",
display_comma_separated(old_partitions),
display_comma_separated(new_partitions)
),
AlterTableOperation::RenameColumn {
old_column_name,
new_column_name,
Expand Down
Loading