mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-30 18:57:21 +00:00
inital commit (#736)
This commit is contained in:
parent
77eddfcc8d
commit
a422116b89
3 changed files with 52 additions and 3 deletions
|
@ -4496,6 +4496,7 @@ fn parse_create_view() {
|
|||
or_replace,
|
||||
materialized,
|
||||
with_options,
|
||||
cluster_by,
|
||||
} => {
|
||||
assert_eq!("myschema.myview", name.to_string());
|
||||
assert_eq!(Vec::<Ident>::new(), columns);
|
||||
|
@ -4503,6 +4504,7 @@ fn parse_create_view() {
|
|||
assert!(!materialized);
|
||||
assert!(!or_replace);
|
||||
assert_eq!(with_options, vec![]);
|
||||
assert_eq!(cluster_by, vec![]);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
@ -4542,13 +4544,15 @@ fn parse_create_view_with_columns() {
|
|||
with_options,
|
||||
query,
|
||||
materialized,
|
||||
cluster_by,
|
||||
} => {
|
||||
assert_eq!("v", name.to_string());
|
||||
assert_eq!(columns, vec![Ident::new("has"), Ident::new("cols")]);
|
||||
assert_eq!(with_options, vec![]);
|
||||
assert_eq!("SELECT 1, 2", query.to_string());
|
||||
assert!(!materialized);
|
||||
assert!(!or_replace)
|
||||
assert!(!or_replace);
|
||||
assert_eq!(cluster_by, vec![]);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
@ -4565,13 +4569,15 @@ fn parse_create_or_replace_view() {
|
|||
with_options,
|
||||
query,
|
||||
materialized,
|
||||
cluster_by,
|
||||
} => {
|
||||
assert_eq!("v", name.to_string());
|
||||
assert_eq!(columns, vec![]);
|
||||
assert_eq!(with_options, vec![]);
|
||||
assert_eq!("SELECT 1", query.to_string());
|
||||
assert!(!materialized);
|
||||
assert!(or_replace)
|
||||
assert!(or_replace);
|
||||
assert_eq!(cluster_by, vec![]);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
@ -4592,13 +4598,15 @@ fn parse_create_or_replace_materialized_view() {
|
|||
with_options,
|
||||
query,
|
||||
materialized,
|
||||
cluster_by,
|
||||
} => {
|
||||
assert_eq!("v", name.to_string());
|
||||
assert_eq!(columns, vec![]);
|
||||
assert_eq!(with_options, vec![]);
|
||||
assert_eq!("SELECT 1", query.to_string());
|
||||
assert!(materialized);
|
||||
assert!(or_replace)
|
||||
assert!(or_replace);
|
||||
assert_eq!(cluster_by, vec![]);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
@ -4615,6 +4623,7 @@ fn parse_create_materialized_view() {
|
|||
query,
|
||||
materialized,
|
||||
with_options,
|
||||
cluster_by,
|
||||
} => {
|
||||
assert_eq!("myschema.myview", name.to_string());
|
||||
assert_eq!(Vec::<Ident>::new(), columns);
|
||||
|
@ -4622,6 +4631,32 @@ fn parse_create_materialized_view() {
|
|||
assert!(materialized);
|
||||
assert_eq!(with_options, vec![]);
|
||||
assert!(!or_replace);
|
||||
assert_eq!(cluster_by, vec![]);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_create_materialized_view_with_cluster_by() {
|
||||
let sql = "CREATE MATERIALIZED VIEW myschema.myview CLUSTER BY (foo) AS SELECT foo FROM bar";
|
||||
match verified_stmt(sql) {
|
||||
Statement::CreateView {
|
||||
name,
|
||||
or_replace,
|
||||
columns,
|
||||
query,
|
||||
materialized,
|
||||
with_options,
|
||||
cluster_by,
|
||||
} => {
|
||||
assert_eq!("myschema.myview", name.to_string());
|
||||
assert_eq!(Vec::<Ident>::new(), columns);
|
||||
assert_eq!("SELECT foo FROM bar", query.to_string());
|
||||
assert!(materialized);
|
||||
assert_eq!(with_options, vec![]);
|
||||
assert!(!or_replace);
|
||||
assert_eq!(cluster_by, vec![Ident::new("foo")]);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue