Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
macbre committed Sep 23, 2023
2 parents 65d09bc + c76aacb commit 76c3ec3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sql_metadata/keywords_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
KEYWORDS_BEFORE_COLUMNS = {
"SELECT",
"WHERE",
"HAVING",
"ORDERBY",
"GROUPBY",
"ON",
Expand Down Expand Up @@ -57,6 +58,7 @@
COLUMNS_SECTIONS = {
"SELECT": "select",
"WHERE": "where",
"HAVING": "having",
"ORDERBY": "order_by",
"ON": "join",
"USING": "join",
Expand Down
16 changes: 16 additions & 0 deletions test/test_getting_columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,3 +461,19 @@ def test_aliases_switching_column_names():
parsed = Parser(query)
assert parsed.columns == ["a", "b"]
assert parsed.columns_dict == {"select": ["a", "b"]}


def test_having_columns():
query = """
SELECT Country
FROM Customers
GROUP BY Country
HAVING COUNT(CustomerID) > 5;
"""
parsed = Parser(query)
assert parsed.columns == ["Country", "CustomerID"]
assert parsed.columns_dict == {
"select": ["Country"],
"group_by": ["Country"],
"having": ["CustomerID"],
}

0 comments on commit 76c3ec3

Please sign in to comment.