# BigQuery Formatter

Format Google BigQuery Standard SQL with BigQuery rules for backtick project.dataset.table names, triple-quoted and raw strings, # comments and @query parameters. QUALIFY gets its own line, SELECT * EXCEPT and REPLACE stay inline and window clauses are indented. Unclosed strings, comments and parentheses are reported with line and column, which helps analysts and data engineers review queries.

## Frequently asked questions

### Which BigQuery syntax is understood?

Backtick names such as `project.dataset.table`, single and double quoted strings with backslash escapes, triple-quoted strings and raw r'' and bytes b'' prefixes are recognized. @named parameters and @@system variables are kept as written.

### Does the formatter keep hash comments (#)?

Yes. BigQuery accepts # comments as well as -- and /* */ comments, and all three are kept in place.

### How is QUALIFY handled?

QUALIFY starts its own line like WHERE and HAVING. The filter condition is indented beneath it.

### What about SELECT * EXCEPT and REPLACE?

When EXCEPT or REPLACE follows a star, it stays on the same line as the star. That way SELECT * EXCEPT (col) is not mistaken for the EXCEPT set operation.

### Are arrays and structs kept intact?

Yes. Array subscripts such as arr[OFFSET(0)] are kept as written, and STRUCT and ARRAY constructors are formatted like other function calls.

### How are window functions laid out?

Long OVER clauses open an indented block with PARTITION BY and ORDER BY on their own lines. Short ones stay inline.

### Does it change keyword case?

No. Keywords, functions and names keep the case you wrote. Only whitespace and line breaks change.

### Which errors are detected?

Unclosed strings, triple-quoted strings, backtick names and block comments, and unbalanced parentheses, each with line and column. The query is not sent to BigQuery and costs nothing.

### How large can the input be?

Up to 1 MB per request and 128 KB per statement. Scripts with many statements are formatted one statement at a time.

### Can I choose the indentation, and is my query stored?

Use 2 or 4 spaces or tabs. The query is formatted in memory only and never saved.

Your ad here?

[Email us](mailto:hi@dennn.is?subject=Advertising%20on%20OneClick%20Pro)

[Ad The agent-ready plugin suite for WordPress.](https://sleekwp.com/?ref=oneclickpro)
