File tree 2 files changed +31
-1
lines changed
2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -3482,7 +3482,7 @@ impl<'a> Parser<'a> {
3482
3482
) -> Result < Statement , ParserError > {
3483
3483
let materialized = self . parse_keyword ( Keyword :: MATERIALIZED ) ;
3484
3484
self . expect_keyword ( Keyword :: VIEW ) ?;
3485
- let if_not_exists = dialect_of ! ( self is SQLiteDialect |GenericDialect )
3485
+ let if_not_exists = dialect_of ! ( self is BigQueryDialect | SQLiteDialect |GenericDialect )
3486
3486
&& self . parse_keywords ( & [ Keyword :: IF , Keyword :: NOT , Keyword :: EXISTS ] ) ;
3487
3487
// Many dialects support `OR ALTER` right after `CREATE`, but we don't (yet).
3488
3488
// ANSI SQL and Postgres support RECURSIVE here, but we don't support it either.
Original file line number Diff line number Diff line change @@ -175,6 +175,36 @@ fn parse_create_view_with_options() {
175
175
_ => unreachable ! ( ) ,
176
176
}
177
177
}
178
+ #[ test]
179
+ fn parse_create_view_if_not_exists ( ) {
180
+ let sql = "CREATE VIEW IF NOT EXISTS mydataset.newview AS SELECT foo FROM bar" ;
181
+ match bigquery ( ) . verified_stmt ( sql) {
182
+ Statement :: CreateView {
183
+ name,
184
+ columns,
185
+ query,
186
+ or_replace,
187
+ materialized,
188
+ options,
189
+ cluster_by,
190
+ with_no_schema_binding : late_binding,
191
+ if_not_exists,
192
+ temporary,
193
+ } => {
194
+ assert_eq ! ( "mydataset.newview" , name. to_string( ) ) ;
195
+ assert_eq ! ( Vec :: <ViewColumnDef >:: new( ) , columns) ;
196
+ assert_eq ! ( "SELECT foo FROM bar" , query. to_string( ) ) ;
197
+ assert ! ( !materialized) ;
198
+ assert ! ( !or_replace) ;
199
+ assert_eq ! ( options, CreateTableOptions :: None ) ;
200
+ assert_eq ! ( cluster_by, vec![ ] ) ;
201
+ assert ! ( !late_binding) ;
202
+ assert ! ( if_not_exists) ;
203
+ assert ! ( !temporary) ;
204
+ }
205
+ _ => unreachable ! ( ) ,
206
+ }
207
+ }
178
208
179
209
#[ test]
180
210
fn parse_create_table_with_options ( ) {
You can’t perform that action at this time.
0 commit comments