Skip to content

Commit

Permalink
feat(ux): use sqlglot for pretty printing SQL
Browse files Browse the repository at this point in the history
Swapping in `sqlglot` for `sqlparse` because it is prettier
  • Loading branch information
gforsyth authored and cpcloud committed Aug 9, 2022
1 parent cc5bf76 commit a3c81c5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
8 changes: 4 additions & 4 deletions ibis/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,15 +530,15 @@ def psql(
expr
Expression whose SQL will be printed
reindent
Tell `sqlparse` to reindent the SQL string
Tell `sqlglot` to reindent the SQL string
file
File to write output to
kwargs
`sqlparse.format` options
`sqlglot.transpile` options
"""
import sqlparse as sp
import sqlglot

print(
sp.format(str(expr.compile()), reindent=reindent, **kwargs),
sqlglot.transpile(str(expr.compile()), pretty=reindent, **kwargs)[0],
file=file,
)
20 changes: 10 additions & 10 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pyspark = { version = ">=3,<4", optional = true }
requests = { version = ">=2,<3", optional = true }
Shapely = { version = ">=1.6,<1.8.3", optional = true }
sqlalchemy = { version = ">=1.4,<2.0", optional = true }
sqlglot = { version = "^4.3.0", optional = true }

[tool.poetry.dev-dependencies]
absolufy-imports = ">=0.3.1,<1"
Expand Down Expand Up @@ -103,7 +104,6 @@ pyupgrade = ">=2.26.0,<3"
requests = ">=2,<3"
setuptools = ">=57,<64"
sqlalchemy = ">=1.4,<2.0"
sqlparse = ">=0.4.2,<0.5.0"
tomli = ">=2.0.1,<3"

[tool.poetry.extras]
Expand Down
1 change: 0 additions & 1 deletion requirements.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a3c81c5

Please sign in to comment.