@@ -166,4 +166,128 @@ describe('BigQueryFormatter', () => {
166166 Items;
167167 ` ) ;
168168 } ) ;
169+
170+ it ( 'supports create view optional arguments' , ( ) => {
171+ expect (
172+ format ( `
173+ CREATE OR REPLACE VIEW my_dataset.my_view AS (
174+ SELECT t1.col1, t1.col2 FROM my_dataset.my_table)` )
175+ ) . toBe ( dedent `
176+ CREATE OR REPLACE VIEW
177+ my_dataset.my_view AS (
178+ SELECT
179+ t1.col1,
180+ t1.col2
181+ FROM
182+ my_dataset.my_table
183+ )
184+ ` ) ;
185+
186+ expect (
187+ format ( `
188+ CREATE VIEW IF NOT EXISTS my_dataset.my_view AS (
189+ SELECT t1.col1, t1.col2 FROM my_dataset.my_table)` )
190+ ) . toBe ( dedent `
191+ CREATE VIEW IF NOT EXISTS
192+ my_dataset.my_view AS (
193+ SELECT
194+ t1.col1,
195+ t1.col2
196+ FROM
197+ my_dataset.my_table
198+ )
199+ ` ) ;
200+ } ) ;
201+
202+ it ( 'supports create table optional arguments' , ( ) => {
203+ expect (
204+ format ( `
205+ CREATE TABLE mydataset.newtable (
206+ a INT64 NOT NULL
207+ )` )
208+ ) . toBe ( dedent `
209+ CREATE TABLE
210+ mydataset.newtable (a INT64 NOT NULL)
211+ ` ) ;
212+
213+ expect (
214+ format ( `
215+ CREATE TABLE IF NOT EXISTS mydataset.newtable (
216+ a INT64 NOT NULL
217+ )` )
218+ ) . toBe ( dedent `
219+ CREATE TABLE IF NOT EXISTS
220+ mydataset.newtable (a INT64 NOT NULL)
221+ ` ) ;
222+
223+ expect (
224+ format ( `
225+ CREATE TEMP TABLE mydataset.newtable (
226+ a INT64 NOT NULL
227+ )` )
228+ ) . toBe ( dedent `
229+ CREATE TEMP TABLE
230+ mydataset.newtable (a INT64 NOT NULL)
231+ ` ) ;
232+
233+ expect (
234+ format ( `
235+ CREATE TEMP TABLE IF NOT EXISTS mydataset.newtable (
236+ a INT64 NOT NULL
237+ )` )
238+ ) . toBe ( dedent `
239+ CREATE TEMP TABLE IF NOT EXISTS
240+ mydataset.newtable (a INT64 NOT NULL)
241+ ` ) ;
242+
243+ expect (
244+ format ( `
245+ CREATE TEMPORARY TABLE mydataset.newtable (
246+ a INT64 NOT NULL
247+ )` )
248+ ) . toBe ( dedent `
249+ CREATE TEMPORARY TABLE
250+ mydataset.newtable (a INT64 NOT NULL)
251+ ` ) ;
252+
253+ expect (
254+ format ( `
255+ CREATE TEMPORARY TABLE IF NOT EXISTS mydataset.newtable (
256+ a INT64 NOT NULL
257+ )` )
258+ ) . toBe ( dedent `
259+ CREATE TEMPORARY TABLE IF NOT EXISTS
260+ mydataset.newtable (a INT64 NOT NULL)
261+ ` ) ;
262+
263+ expect (
264+ format ( `
265+ CREATE OR REPLACE TABLE mydataset.newtable (
266+ a INT64 NOT NULL
267+ )` )
268+ ) . toBe ( dedent `
269+ CREATE OR REPLACE TABLE
270+ mydataset.newtable (a INT64 NOT NULL)
271+ ` ) ;
272+
273+ expect (
274+ format ( `
275+ CREATE OR REPLACE TEMP TABLE mydataset.newtable (
276+ a INT64 NOT NULL
277+ )` )
278+ ) . toBe ( dedent `
279+ CREATE OR REPLACE TEMP TABLE
280+ mydataset.newtable (a INT64 NOT NULL)
281+ ` ) ;
282+
283+ expect (
284+ format ( `
285+ CREATE OR REPLACE TEMPORARY TABLE mydataset.newtable (
286+ a INT64 NOT NULL
287+ )` )
288+ ) . toBe ( dedent `
289+ CREATE OR REPLACE TEMPORARY TABLE
290+ mydataset.newtable (a INT64 NOT NULL)
291+ ` ) ;
292+ } ) ;
169293} ) ;
0 commit comments