Align AS
When alignAs is enabled, AS keywords are vertically aligned across SELECT items with explicit aliases by padding the expression to align the AS keyword.
Basic alignment with varying expression widths
select customer_id, count(order_id) as order_count, sum(total) as total_spent, avg(total) as avg_order from orders
select
customer_id,
count(order_id) as order_count,
sum(total) as total_spent,
avg(total) as avg_order
from orders
Mixed: some items aliased, some not
Only items with explicit AS aliases participate. Items without aliases render normally.
select a, count(b) as cnt, c, sum(d) as total from t
select a, count(b) as cnt, c, sum(d) as total from t
Single aliased item — no alignment needed
select count(*) as cnt from t
select count(*) as cnt from t
Only applies to multi-line styles (not INLINE)
select a as x, bb as y from t
select a as x, bb as y from t
Works with leading commas
select a as x, bbb as y, cc as z from t
select a as x, bbb as y, cc as z from t
Disabled by default
select a as x, bbb as y from t
select a as x, bbb as y from t
Idempotency
SELECT CUSTOMER_ID,
COUNT(ORDER_ID) AS ORDER_COUNT,
SUM(TOTAL) AS TOTAL_SPENT,
AVG(TOTAL) AS AVG_ORDER
FROM ORDERS
select
customer_id,
count(order_id) as order_count,
sum(total) as total_spent,
avg(total) as avg_order
from orders
With STACKED style
select a as x, bbb as y, cc as z from t
select a as x, bbb as y, cc as z from t
Skipped when width difference too large
When all expressions differ by more than 20 chars, no alignment group can be formed.
select count(*) as cnt, row_number() over (partition by a order by b desc) as rn from t
select count(*) as cnt, row_number() over (partition by a order by b desc) as rn
from t
With FIRST_ON_KEYWORD style
select a as x, bbb as y, cc as z from t
select a as x, bbb as y, cc as z from t