Skip to main content

Function Argument Formatting

Controls function call formatting including argument newlines.

Modes: ALWAYS breaks all function args onto new lines. NEVER keeps them inline. WIDTH_AWARE preserves original formatting but breaks when maxLineWidth is exceeded.

Applies to: Regular function calls (count(), sum()), special functions (COALESCE, GREATEST, LEAST), and schema-qualified functions.

Nesting: Each function resolves its arg newline mode independently. Outer vertical + inner compact is supported.

Simple function calls

select count(*), sum(a) from t
select count(*), sum(a) from t

Binary expressions

select a + b, c * d from t
select a + b, c * d from t

String literal

select 'hello' from t
select 'hello' from t

Column and table aliases

select a as alias1 from t
select a as alias1 from t

Table alias

select t.a from tbl t
select t.a from tbl t

SELECT star

select * from t
select * from t

COALESCE always vertical

select coalesce(a, b, c) from t
select coalesce(a, b, c) from t

COALESCE never keeps compact

select coalesce(
a,
b,
c
) from t
select coalesce(a, b, c) from t

COALESCE auto compact

User wrote compact input — WIDTH_AWARE keeps it compact.

select coalesce(a, b, c) from t
select coalesce(a, b, c) from t

COALESCE auto vertical via open paren newline

User wrote vertical (newline after open paren) — WIDTH_AWARE expands.

select coalesce(
a, b, c) from t
select coalesce(a, b, c) from t

COALESCE auto vertical via comma newlines

User wrote vertical via comma newlines — WIDTH_AWARE expands.

select coalesce(a,
b,
c) from t
select coalesce(a, b, c) from t

Single arg stays compact in auto

select coalesce(a) from t
select coalesce(a) from t

Nested functions both vertical

select coalesce(
a, coalesce(
b, c)) from t
select coalesce(a, coalesce(b, c)) from t

Nested functions outer vertical inner compact

select coalesce(
a, coalesce(b, c)) from t
select coalesce(a, coalesce(b, c)) from t

Deeply nested special functions with always vertical

With functionArgNewline=always, each nested SpecialFunction (COALESCE, NULLIF, GREATEST, LEAST) should break its own args onto indented lines independently.

select coalesce(nullif(greatest(a, b), 0), least(c, d)) from t
select coalesce(nullif(greatest(a, b), 0), least(c, d)) from t

Function args with leading comma

select coalesce(a, b, c) from t
select coalesce(a, b, c) from t

Width-aware adaptive: preserves 3-per-line grouping in GREATEST

User's original has consistent 3-per-line pattern — WIDTH_AWARE exceeds maxLineWidth and preserves the grouping.

select greatest(alpha, bravo, charlie,
delta, echo, foxtrot,
golf) from t
select
greatest(
alpha, bravo, charlie, delta, echo,
foxtrot, golf
)
from t

Width-aware adaptive: preserves 2-per-line grouping in COALESCE

select coalesce(alpha, bravo,
charlie, delta,
echo) from t
select
coalesce(
alpha, bravo, charlie, delta, echo
)
from t