From a677676dcb5195f720d042f2b6382d67b5ca641f Mon Sep 17 00:00:00 2001 From: Matthew Peveler Date: Wed, 10 Aug 2022 13:55:28 -0400 Subject: [PATCH] Fix identifying DECLARE statements for bigquery Signed-off-by: Matthew Peveler --- src/parser.ts | 2 +- test/identifier/single-statement.spec.ts | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/parser.ts b/src/parser.ts index cb158ed..1b42f93 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -65,7 +65,7 @@ const blockOpeners: Record = { mssql: ['BEGIN', 'CASE'], sqlite: ['BEGIN', 'CASE'], oracle: ['DECLARE', 'BEGIN', 'CASE'], - bigquery: ['DECLARE', 'BEGIN', 'CASE'], + bigquery: ['BEGIN', 'CASE'], }; interface ParseOptions { diff --git a/test/identifier/single-statement.spec.ts b/test/identifier/single-statement.spec.ts index c5c84f5..65b28fa 100644 --- a/test/identifier/single-statement.spec.ts +++ b/test/identifier/single-statement.spec.ts @@ -1361,5 +1361,24 @@ describe('identifier', () => { expect(actual).to.eql(expected); }); + + it('Should identify declare statement as unknown for bigquery', () => { + const actual = identify("DECLARE start_time TIMESTAMP DEFAULT '2022-08-08 13:05:00';", { + dialect: 'bigquery', + strict: false, + }); + const expected = [ + { + start: 0, + end: 58, + text: "DECLARE start_time TIMESTAMP DEFAULT '2022-08-08 13:05:00';", + type: 'UNKNOWN', + executionType: 'UNKNOWN', + parameters: [], + }, + ]; + + expect(actual).to.eql(expected); + }); }); });