andialbrecht / sqlparse

A non-validating SQL parser module for Python
BSD 3-Clause "New" or "Revised" License
3.76k stars 700 forks source link

adding Spark keywords #690

Closed mrmasterplan closed 1 year ago

mrmasterplan commented 1 year ago

I would like to use this library to parse Spark SQL. Especially I am trying to parse databricks CREATE TABLE and CREATE DATABASE statements. https://spark.apache.org/docs/latest/sql-ref-syntax-ddl-create-table-datasource.html https://spark.apache.org/docs/3.0.0-preview/sql-ref-syntax-ddl-create-database.html These statements contain some further keywords than the ones already in the library. I created a new section of SPARK_KEYWORDS in the keywords.py file.

Maybe it would also be nice to have an extension mechanism in the library where a user can quickly extend the keyword range without a PR like this. If you like this idea, I will make another PR for it.

mrmasterplan commented 1 year ago

~I forgot that I meant to add a test. Please consider this PR as a draft and don't review, yet.~ Unit tests have been added.

codecov[bot] commented 1 year ago

Codecov Report

Base: 96.90% // Head: 96.90% // Increases project coverage by +0.00% :tada:

Coverage data is based on head (f55dd54) compared to base (9f44d54). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #690 +/- ## ======================================= Coverage 96.90% 96.90% ======================================= Files 20 20 Lines 1520 1521 +1 ======================================= + Hits 1473 1474 +1 Misses 47 47 ``` | [Impacted Files](https://codecov.io/gh/andialbrecht/sqlparse/pull/690?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andi+Albrecht) | Coverage Δ | | |---|---|---| | [sqlparse/keywords.py](https://codecov.io/gh/andialbrecht/sqlparse/pull/690/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andi+Albrecht#diff-c3FscGFyc2Uva2V5d29yZHMucHk=) | `100.00% <100.00%> (ø)` | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andi+Albrecht). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andi+Albrecht)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

mrmasterplan commented 1 year ago

already covered in #687