-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added sqlglot
dependency
#302
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #302 +/- ##
==========================================
- Coverage 84.15% 83.27% -0.89%
==========================================
Files 39 30 -9
Lines 4601 2146 -2455
Branches 859 366 -493
==========================================
- Hits 3872 1787 -2085
+ Misses 528 279 -249
+ Partials 201 80 -121 ☔ View full report in Codecov by Sentry. |
@nfx can you prioritize this one? I need this dependency for my work. |
@zpappa you can send prs that are decoupled from sqlglot |
I tested this off line, just run |
TODO: - [ ] Add it as dashboard query formatter in `make fmt` - [ ] Add it as dashboard query linter in `make lint` - [ ] Fix dashboard framework to understand `/* ... */` comments - [ ] Pick projected columns from SQL AST instead of defining them in magic comments
@nfx , do we still need this? |
Closed in favor of databrickslabs/lsql#66 |
This pull request adds SQLGlot, a SQL parser and reformatter, as a new dependency in the project. It also includes a new test file,
sql_formatter.py
, which contains a test functiontest_sql()
. This function reads SQL files from a specified folder and parses each file using SQLGlot. After parsing, it formats the parsed SQL to a more readable version using thesql()
method from SQLGlot, and then prints out the formatted SQL. The purpose of this test is to ensure that SQL queries can be successfully parsed and formatted by SQLGlot.In terms of the code changes, the main addition is the inclusion of SQLGlot in the
pyproject.toml
file as a new dependency. Additionally, thetests/sql_formatter.py
file has been added, which contains a test function that reads SQL files and parses them using SQLGlot. The test function prints out the formatted SQL for each file, which can be used to verify that the SQL queries are being parsed and formatted correctly.This PR adds
sqlglot
dependency, that would also be required to rewrite views defined in the Hive Metastore to views in UC that follow three-level namespace.TODO:
make fmt
make lint
/* ... */
comments