tb fmt

Formats a .datasource or .pipe file. .connection files are not yet supported.

These are the options available for the fmt command:

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 overwrite the local file.
--yesDon't ask for confirmation to overwrite the local file.
--diffOutputs correctly formatted block (if differs from local file) and prompts to apply correction to local file.
--no-colorDoesn't colorize the diff.

This command applies opinionated formatting rules and may reorder file properties for consistency. For example, these properties:

ENGINE "MergeTree"
ENGINE_SORTING_KEY "name"
ENGINE_PARTITION_KEY "name"

The command formats them as follows:

ENGINE MergeTree
ENGINE_PARTITION_KEY name
ENGINE_SORTING_KEY name

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
Updated