Skip to content

Q447 a Q449 do not work well with group by and having #18

@pavelsaman

Description

@pavelsaman

This piece of code:

SELECT acfc.adcategoryid, acfc.targetmetadatadefinitionid
  FROM [adcategoryfiltercondition] acfc
 GROUP BY acfc.adcategoryid, acfc.targetmetadatadefinitionid
HAVING acfc.targetmetadatadefinitionid IS NOT NULL

should be fine according to the style guide that is linked in the docs: https://www.sqlstyle.guide/

But running flake8-sql gives two errors: Q447 and Q449:

Q447 root_keywords SELECT and GROUP BY are not right aligned
Q449 token HAVING should be aligned to the right of the river

Speaking of GROUP BY, an example in the style guide is here: https://www.sqlstyle.guide/#spaces, i.e. only GROUP is aligned to the right of the river, but flake8-sql requires the whole GROUP BY to be aligned to the right of the river, i.e. this doesn't give an error:

  SELECT acfc.adcategoryid, acfc.targetmetadatadefinitionid
    FROM [adcategoryfiltercondition] acfc
GROUP BY acfc.adcategoryid, acfc.targetmetadatadefinitionid

In terms of HAVING, there's no example in the style guide, but I believe it should be just like WHERE, that is it should be a root_keyword and required to be aligned to the right of the river. Such an approach is mentioned for example in here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions