tb fmt

Formats a datafile. For example: tb fmt my_datasource.datasource.

Options

OptionDescription
--line-length INTEGERA number indicating the maximum characters per line in the node SQL, lines split based on the SQL syntax and the number of characters passed as a parameter.
--dry-runDon't ask to override the local file.
--yesDon't ask for confirmation to overwrite the local file.
--diffFormats local file, prints the diff and exits with 1 if different or 0 if equal.

This command removes comments starting with # from the file, so use DESCRIPTION or a comment block instead:

Example comment block
%
{% comment this is a comment and fmt keeps it %}

SELECT
  {% comment this is another comment and fmt keeps it %}
  count() c
FROM stock_prices_1m

You can add tb fmt to your git precommit hook to have your files properly formatted. If the SQL formatting results aren't the ones expected to you, you can disable it for the blocks needed. Read how to disable fmt.

Updated