-
-
Notifications
You must be signed in to change notification settings - Fork 24
Closed
Description
Describe the bug
In case expressions, when there are long when statements, sqlfmt put the then statements at the same indentation as the when statements, which makes them harder to read.
If we look at the dbt style guide (e.g. here and here), the then is more indented.
To Reproduce
with
source as (select * from {{ source("my_application", "users") }}),
renamed as (
select
sum(
case when order_status = 'complete' then order_total end
) as monthly_total,
nullif(
trim(
case
when regexp_count(nullif(full_name, ''), ' ') = 0
then nullif(full_name, '')
when regexp_count(nullif(full_name, ''), ' ') = 1
then split_part(nullif(full_name, ''), ' ', 1)
-- this user has more than two names!
else regexp_substr(nullif(full_name, ''), '.* .* ')
end
)
from source
)
select *
from renamedExpected behavior
with
source as (select * from {{ source("my_application", "users") }}),
renamed as (
select
sum(
case when order_status = 'complete' then order_total end
) as monthly_total,
nullif(
trim(
case
when regexp_count(nullif(full_name, ''), ' ') = 0
then nullif(full_name, '')
when regexp_count(nullif(full_name, ''), ' ') = 1
then split_part(nullif(full_name, ''), ' ', 1)
-- this user has more than two names!
else regexp_substr(nullif(full_name, ''), '.* .* ')
end
)
from source
)
select *
from renamedActual behavior
thenare not indented properly (see To Reproduce )
Additional context
What is the output of sqlfmt --version?
sqlfmt, version 0.13.0
Metadata
Metadata
Assignees
Labels
No labels