Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
chore(deps): Unpin sqlparse dependency (apache#21581)
Browse files Browse the repository at this point in the history
Co-authored-by: Erik Cederstrand <erik@adamatics.com>
Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>
(cherry picked from commit 82bd5a3)
  • Loading branch information
ecederstrand authored and john-bodley committed Oct 6, 2022
1 parent 09f3e3a commit 4c182f3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ sqlalchemy-utils==0.37.8
# via
# apache-superset
# flask-appbuilder
sqlparse==0.3.0
sqlparse==0.4.3
# via apache-superset
tabulate==0.8.9
# via apache-superset
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ def get_git_sha() -> str:
"simplejson>=3.15.0",
"slackclient==2.5.0", # PINNED! slack changes file upload api in the future versions
"sqlalchemy>=1.4, <2",
"sqlalchemy-utils>=0.37.8, <0.38",
"sqlparse==0.3.0", # PINNED! see https://github.com/andialbrecht/sqlparse/issues/562
"sqlalchemy-utils>=0.37.8, <0.39",
"sqlparse>=0.4.3, <0.5",
"tabulate==0.8.9",
# needed to support Literal (3.8) and TypeGuard (3.10)
"typing-extensions>=3.10, <4",
Expand Down
19 changes: 3 additions & 16 deletions tests/unit_tests/sql_parse_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,9 @@ def test_extract_tables_illdefined() -> None:
assert extract_tables("SELECT * FROM catalogname..tbname") == set()


@unittest.skip("Requires sqlparse>=3.1")
def test_extract_tables_show_tables_from() -> None:
"""
Test ``SHOW TABLES FROM``.
This is currently broken in the pinned version of sqlparse, and fixed in
``sqlparse>=3.1``. However, ``sqlparse==3.1`` breaks some sql formatting.
"""
assert extract_tables("SHOW TABLES FROM s1 like '%order%'") == set()

Expand Down Expand Up @@ -1017,15 +1013,15 @@ def test_unknown_select() -> None:
Test that `is_select` works when sqlparse fails to identify the type.
"""
sql = "WITH foo AS(SELECT 1) SELECT 1"
assert sqlparse.parse(sql)[0].get_type() == "UNKNOWN"
assert sqlparse.parse(sql)[0].get_type() == "SELECT"
assert ParsedQuery(sql).is_select()

sql = "WITH foo AS(SELECT 1) INSERT INTO my_table (a) VALUES (1)"
assert sqlparse.parse(sql)[0].get_type() == "UNKNOWN"
assert sqlparse.parse(sql)[0].get_type() == "INSERT"
assert not ParsedQuery(sql).is_select()

sql = "WITH foo AS(SELECT 1) DELETE FROM my_table"
assert sqlparse.parse(sql)[0].get_type() == "UNKNOWN"
assert sqlparse.parse(sql)[0].get_type() == "DELETE"
assert not ParsedQuery(sql).is_select()


Expand Down Expand Up @@ -1108,15 +1104,6 @@ def test_messy_breakdown_statements() -> None:
def test_sqlparse_formatting():
"""
Test that ``from_unixtime`` is formatted correctly.
``sqlparse==0.3.1`` has a bug and removes space between ``from`` and
``from_unixtime``, resulting in::
SELECT extract(HOUR
fromfrom_unixtime(hour_ts)
AT TIME ZONE 'America/Los_Angeles')
from table
"""
assert sqlparse.format(
"SELECT extract(HOUR from from_unixtime(hour_ts) "
Expand Down

0 comments on commit 4c182f3

Please sign in to comment.