@@ -166,4 +166,55 @@ describe('BigQueryFormatter', () => {
166166 Items;
167167 ` ) ;
168168 } ) ;
169+
170+ it ( 'supports create view optional arguments' , ( ) => {
171+ const createViewVariations = [
172+ 'CREATE VIEW' ,
173+ 'CREATE OR REPLACE VIEW' ,
174+ 'CREATE VIEW IF NOT EXISTS' ,
175+ ] ;
176+
177+ createViewVariations . forEach ( ( createViewVariation : string ) => {
178+ expect (
179+ format ( `
180+ ${ createViewVariation } my_dataset.my_view AS (
181+ SELECT t1.col1, t1.col2 FROM my_dataset.my_table)` )
182+ ) . toBe ( dedent `
183+ ${ createViewVariation }
184+ my_dataset.my_view AS (
185+ SELECT
186+ t1.col1,
187+ t1.col2
188+ FROM
189+ my_dataset.my_table
190+ )
191+ ` ) ;
192+ } ) ;
193+ } ) ;
194+
195+ it ( 'supports create table optional arguments' , ( ) => {
196+ const createTableVariations = [
197+ 'CREATE TABLE' ,
198+ 'CREATE TABLE IF NOT EXISTS' ,
199+ 'CREATE TEMP TABLE' ,
200+ 'CREATE TEMP TABLE IF NOT EXISTS' ,
201+ 'CREATE TEMPORARY TABLE' ,
202+ 'CREATE TEMPORARY TABLE IF NOT EXISTS' ,
203+ 'CREATE OR REPLACE TABLE' ,
204+ 'CREATE OR REPLACE TEMP TABLE' ,
205+ 'CREATE OR REPLACE TEMPORARY TABLE' ,
206+ ] ;
207+
208+ createTableVariations . forEach ( ( createTableVariation : string ) => {
209+ expect (
210+ format ( `
211+ ${ createTableVariation } mydataset.newtable (
212+ a INT64 NOT NULL
213+ )` )
214+ ) . toBe ( dedent `
215+ ${ createTableVariation }
216+ mydataset.newtable (a INT64 NOT NULL)
217+ ` ) ;
218+ } ) ;
219+ } ) ;
169220} ) ;
0 commit comments