Repository: sql-formatter-org/sql-formatter (ts)

Issue:
[FORMATTING] GBQ @@error.message not supported
```
BEGIN
select 1/0;
EXCEPTION WHEN ERROR THEN
SELECT @@error.message;
END;
```
Unable to format SQL: Error: Parse error: Unexpected "@@error.me" at line 4 column 8

This code is for BigQuery.

Pull request description:
Support BigQuery system variables
Fixes #567

Patch:
diff --git a/src/languages/bigquery/bigquery.formatter.ts b/src/languages/bigquery/bigquery.formatter.ts
index bd69ae7f..aef53d84 100644
--- a/src/languages/bigquery/bigquery.formatter.ts
+++ b/src/languages/bigquery/bigquery.formatter.ts
@@ -178,6 +178,7 @@ export const bigquery: DialectOptions = {
     identTypes: ['``'],
     identChars: { dashes: true },
     paramTypes: { positional: true, named: ['@'], quoted: ['@'] },
+    variableTypes: [{ regex: String.raw`@@\w+` }],
     lineCommentTypes: ['--', '#'],
     operators: ['&', '|', '^', '~', '>>', '<<', '||'],
     postProcess,


Test patch:
diff --git a/test/bigquery.test.ts b/test/bigquery.test.ts
index 857181df..461a69b7 100644
--- a/test/bigquery.test.ts
+++ b/test/bigquery.test.ts
@@ -76,6 +76,14 @@ describe('BigQueryFormatter', () => {
     `);
   });
 
+  it('supports @@variables', () => {
+    expect(format('SELECT @@error.message, @@time_zone')).toBe(dedent`
+      SELECT
+        @@error.message,
+        @@time_zone
+    `);
+  });
+
   // BigQuery-specific string types
   it('supports strings with rb prefixes', () => {
     expect(format(`SELECT rb"huh", br'bulu bulu', BR'la la' FROM foo`)).toBe(dedent`