Skip to content

Commit 039b202

Browse files
authored
Support BigQuery system variables (#568)
2 parents a1aa667 + 6c118d1 commit 039b202

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/languages/bigquery/bigquery.formatter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ export const bigquery: DialectOptions = {
178178
identTypes: ['``'],
179179
identChars: { dashes: true },
180180
paramTypes: { positional: true, named: ['@'], quoted: ['@'] },
181+
variableTypes: [{ regex: String.raw`@@\w+` }],
181182
lineCommentTypes: ['--', '#'],
182183
operators: ['&', '|', '^', '~', '>>', '<<', '||'],
183184
postProcess,

test/bigquery.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ describe('BigQueryFormatter', () => {
7676
`);
7777
});
7878

79+
it('supports @@variables', () => {
80+
expect(format('SELECT @@error.message, @@time_zone')).toBe(dedent`
81+
SELECT
82+
@@error.message,
83+
@@time_zone
84+
`);
85+
});
86+
7987
// BigQuery-specific string types
8088
it('supports strings with rb prefixes', () => {
8189
expect(format(`SELECT rb"huh", br'bulu bulu', BR'la la' FROM foo`)).toBe(dedent`

0 commit comments

Comments
 (0)