I can't understand why SQLFluff shows AM06 error (Inconsistent column references in 'GROUP BY/ORDER BY' clauses) with my code in DBT having only these order bys:
with table2 as (
select
h.id,
h.id2
from table3 as h
order by
h.parentid asc,
h.createddate asc
)
select
s.id,
p.id
from table1 as s
left join table2 as p on p.id = s.parentid
order by
p.shop_id asc,
p.supplier_id asc,
p.supplier_configuration_number asc,
s.createddate asc,
s.id asc
Can anyone tell me what is wrong with them?
Today I found the answer to my problem. It was the .sqlfluff configuration that was causing this.
I had:
[sqlfluff:rules:ambiguous.column_references] # Number in group by
group_by_and_order_by_style = implicit
I changed the value to explicit
and the warning is gone.
Thanks for all the help.