Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

format bigquery sql using dataform format or api call

Hello Team,

I want to format my queries using a bigquery templater (like the format in dataform ui)
I don't found a bigquery templater in the cli of dataform.
How I can use that using dataform cli ?  
Our team don't want to use ui fomatting , just command on vscode ? 
there is a solution for that ? 
Thanks

Solved Solved
0 3 1,724
1 ACCEPTED SOLUTION

Here's how to approach BigQuery SQL formatting in Dataform, given its current limitations:

1. Use General SQL Formatters in VS Code:

  • Install a VS Code extension that formats generic SQL code.
  • Choose one that handles BigQuery SQL syntax well (e.g., SQL Formatter,BigQuery Helper).

2. Integrate External Formatters (if needed):

  • Explore tools specifically for BigQuery SQL formatting (e.g., bqfmt).
  • Integrate them with VS Code using custom scripts or tasks.

3. Request a Feature from Dataform:

  • Contact Dataform support to request a built-in BigQuery templater in the CLI or VS Code extension.

Key Points:

  • Dataform CLI currently lacks a dedicated dataform formatcommand for SQL formatting.
  • Dataform VS Code extension focuses on project management, not direct SQL formatting.
  • General SQL formatters or external tools can bridge the gap.
  • User feedback can influence future Dataform features.

View solution in original post

3 REPLIES 3

I did a Google Search using the phrase "SQL formatter" and seem to have found a bunch of candidates.  Adding in "SQL formatter vscode" produced plugins for vscode.  While the Google Dataform UI pages do appear to have a formatter in their built in editor, I don't think this is exposed in the Dataform CLI.

Thanks for the search you did , it's a good Idea to do some search before asking...
Thanks a lot 🙂 

Here's how to approach BigQuery SQL formatting in Dataform, given its current limitations:

1. Use General SQL Formatters in VS Code:

  • Install a VS Code extension that formats generic SQL code.
  • Choose one that handles BigQuery SQL syntax well (e.g., SQL Formatter,BigQuery Helper).

2. Integrate External Formatters (if needed):

  • Explore tools specifically for BigQuery SQL formatting (e.g., bqfmt).
  • Integrate them with VS Code using custom scripts or tasks.

3. Request a Feature from Dataform:

  • Contact Dataform support to request a built-in BigQuery templater in the CLI or VS Code extension.

Key Points:

  • Dataform CLI currently lacks a dedicated dataform formatcommand for SQL formatting.
  • Dataform VS Code extension focuses on project management, not direct SQL formatting.
  • General SQL formatters or external tools can bridge the gap.
  • User feedback can influence future Dataform features.