Formatter changes `null end` to `nullend` in case statement
Closed this issue · 2 comments
tiffany-upside commented
The formatter can introduce an error when formatting the end of a case statement:
Before formatting:
when GTTV_28 between 2500 and 4000 then 'Trending'
when GTTV_28 < 2500 then 'Low'
else null end csm_status
After formatting:
WHEN GTTV_28 BETWEEN 2500
AND 4000 THEN 'Trending'
WHEN GTTV_28 < 2500 THEN 'Low'
ELSE NULLEND csm_status
NULL END
should remain as separate words.
This does not happen on all case statements; in this case it may have been related to use of between X and Y
in one of the WHEN
clauses
henriblancke commented
@tiffany-upside trying to reproduce this one but can't get the same behavior you had. I tried different variations of (adding and removing more columns):
select
stuff,
{{ some_var }} as stuff_var,
case
when GTTV_28 between 2500 and 4000 then 'Trending'
when GTTV_28 < 2500 then 'Low'
else null end csm_status,
stuff_after,
more_stuff_after
from tester
---
with cte as (
select
stuff,
{{ some_var }} as stuff_var,
case
when GTTV_28 between 2500 and 4000 then 'Trending'
when GTTV_28 < 2500 then 'Low'
else null end csm_status,
stuff_after,
more_stuff_after
from tester
)
select * from cte;
---
{% macro star(from, relation_alias=False, except=[]) -%}
select
stuff,
{{ some_var }} as stuff_var,
case
when GTTV_28 between 2500 and 4000 then 'Trending'
when GTTV_28 < 2500 then 'Low'
else null end csm_status,
stuff_after,
more_stuff_after
from tester
{% endmacro %}
but it always comes back with END
on a new line:
SELECT
stuff,
{{ some_var }} AS stuff_var,
CASE
WHEN GTTV_28 BETWEEN 2500
AND 4000 THEN 'Trending'
WHEN GTTV_28 < 2500 THEN 'Low'
ELSE NULL
END AS csm_status,
stuff_after,
more_stuff_after
FROM
tester
Do you remember the specific query? I'm sure there is some edge case I'm overlooking.
henriblancke commented
Closing because I'm unable to reproduce this issue. @tiffany-upside feel free to re-open the ticket if you encounter this issue again!