Skip to main content

Comma Style

Controls whether commas appear at the end of the line (trailing) or the beginning of the next line (leading).

Trailing (default): a,\n b — comma at end of line, next item on new line at indent. Leading: a\n , b — newline first, comma at start of next line, then item.

Applies to: SELECT items, GROUP BY items, ORDER BY items, SET columns, VALUES rows, CREATE TABLE columns, function args.

Interaction with FIRST_ON_KEYWORD: Leading comma aligns at alignColumn - 2 so items still line up under the first item.

GROUP BY item newline trailing

select a, b, count(*) from t group by a, b
select a, b, count(*) from t group by a, b

ORDER BY item newline trailing

select a, b from t order by a, b desc
select a, b from t order by a, b desc

GROUP BY items stay compact by default

Default: GROUP BY items stay on one line (ADAPTIVE, no newlines in input).

select a, b, count(*) from t group by a, b
select a, b, count(*) from t group by a, b

SELECT items leading comma with newlines

select a, b, c from t
select a, b, c from t

GROUP BY leading comma

select a, b, count(*) from t group by a, b
select a, b, count(*) from t group by a, b

Trailing comma in SELECT preserved (BigQuery style)

Trailing commas are preserved through the SeparatedList structure (inline style avoids the phantom-line issue).

select a, b, from t
select a, b, from t

Trailing comma in GROUP BY preserved

select a, count(*) from t group by a,
select a, count(*) from t group by a,

ORDER BY leading comma

select a, b from t order by a, b desc
select a, b from t order by a, b desc