clickhouse-format

    Keys:

    • or-h — Produce help message.
    • --hilite — Add syntax highlight with ANSI terminal escape sequences.
    • --oneline — Format in single line.
    • --quiet or — Just check syntax, no output on success.
    • --obfuscate — Obfuscate instead of formatting.
    • --seed <string> — Seed arbitrary string that determines the result of obfuscation.
    • — Add a backslash at the end of each line of the formatted query. Can be useful when you copy a query from web or somewhere else with multiple lines, and want to execute it in command line.
    1. Highlighting and single line:
    1. SELECT sum(number) FROM numbers(5)
    1. $ clickhouse-format -n <<< "SELECT * FROM (SELECT 1 AS x UNION ALL SELECT 1 UNION DISTINCT SELECT 3);"

    Result:

    1. Obfuscating:
    1. $ clickhouse-format --seed Hello --obfuscate <<< "SELECT cost_first_screen BETWEEN a AND b, CASE WHEN x >= 123 THEN y ELSE NULL END;"
    1. SELECT treasury_mammoth_hazelnut BETWEEN nutmeg AND span, CASE WHEN chive >= 116 THEN switching ELSE ANYTHING END;

    Same query and another seed string:

    1. $ clickhouse-format --backslash <<< "SELECT * FROM (SELECT 1 AS x UNION ALL SELECT 1 UNION DISTINCT SELECT 3);"

    Result: