-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
feat: Add support for Azure Data Explorer (Kusto) db engine spec #17898
Conversation
…ode to support Kusto engine specs.
Codecov Report
@@ Coverage Diff @@
## master #17898 +/- ##
=======================================
Coverage 67.10% 67.10%
=======================================
Files 1609 1610 +1
Lines 64897 64970 +73
Branches 6866 6866
=======================================
+ Hits 43547 43600 +53
- Misses 19484 19504 +20
Partials 1866 1866
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! One nit + one question. Also, wondering if you would be open to adding some unit tests for typical cases, especially for the overridden class methods, like is_select_query
and parse_sql
.
Thank you for the review and suggestion on how to improve this code! We will add unit tests and merge two dialects in a single file, and I will back to you. |
Add tests for Kusto db spec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great - a few last comments, but I think this is really close to being mergeable.
setup.py
Outdated
@@ -140,6 +140,7 @@ def get_git_sha() -> str: | |||
"hana": ["hdbcli==2.4.162", "sqlalchemy_hana==0.4.0"], | |||
"hive": ["pyhive[hive]>=0.6.1", "tableschema", "thrift>=0.11.0, <1.0.0"], | |||
"impala": ["impyla>0.16.2, <0.17"], | |||
"kusto": ["sqlalchemy-kusto>=1.0.1"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just in case, could we restrict to the current major version?
"kusto": ["sqlalchemy-kusto>=1.0.1"], | |
"kusto": ["sqlalchemy-kusto>=1.0.1, <2"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sounds good to me. We will add this restriction.
[ | ||
("tbl | limit 100", True), | ||
("let foo = 1; tbl | where bar == foo", True), | ||
(".show tables", False), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, out of curiosity, is this actually a read-only query? I know that SHOW TABLES
, EXPLAIN
etc appears to currently be flagged as DML by parse_sql
, but as this logic will now be contained in the db engine spec, this can now be easily altered. So maybe we'd like to change this to be flagged as read-only in the KQL spec? Also, could we add a more typical DML case here, like .set
, .append
or .drop
? I assume they're the cases we want to make sure we're catching.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your remark is valuable. Thank you. We will add more specific code.
("INSERT INTO tbl (foo) VALUES (1)", False), | ||
], | ||
) | ||
def test_sql_is_readonly_query( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add a few more tests for the SQL spec, like a few timegrains, convert_dttm
etc, just to get coverage up? You can probably copy some template tests from the pre-existing unit tests.
@villebro Thank you for the review! We fixed your comments. |
@xneg awesome 👍 I started CI and this definitely LGTM if it passes CI. Again, to further protect this connector from the unlikely risk of regressions I'd suggest adding unit tests for all overridden methods (e.g. convert_dttm etc), but I'm fine merging as-is. |
@villebro Thank you! We already added unit tests for all overridden methods except |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@xneg right you are - my apologies, I see that now! ✅ |
…che#17898) * Add two Kusto engine specs: KQL and SQL. Some minor changes in core code to support Kusto engine specs. * Remove redundant imports and logging. * docs: Kusto sqlalchemy docs * fix: Fix mypy and linting errors * fix: Handle Black vs Pylint checks * fix: isort problem * refactor: Merge kustosql and kustokql in the single kusto module * test: Add tests for Kusto db spec * feat: Schema override does not require in KQL anymore * Removed redundant imports. * Added ".show" queries to readonly query determination. * Fixed some bugs. Added tests for convert_dttm. * Fixed major sqlalchemy-kusto version. * Fixed by isort. Co-authored-by: Eugene Bikkinin <xnegxneg@gmail.com> Co-authored-by: k.tomak <k.tomak@dodopizza.com> Co-authored-by: Eugene Bikkinin <e.bikkinin@dodopizza.com>
…che#17898) * Add two Kusto engine specs: KQL and SQL. Some minor changes in core code to support Kusto engine specs. * Remove redundant imports and logging. * docs: Kusto sqlalchemy docs * fix: Fix mypy and linting errors * fix: Handle Black vs Pylint checks * fix: isort problem * refactor: Merge kustosql and kustokql in the single kusto module * test: Add tests for Kusto db spec * feat: Schema override does not require in KQL anymore * Removed redundant imports. * Added ".show" queries to readonly query determination. * Fixed some bugs. Added tests for convert_dttm. * Fixed major sqlalchemy-kusto version. * Fixed by isort. Co-authored-by: Eugene Bikkinin <xnegxneg@gmail.com> Co-authored-by: k.tomak <k.tomak@dodopizza.com> Co-authored-by: Eugene Bikkinin <e.bikkinin@dodopizza.com>
Hi @xneg.. thanks for creating this amazing Kusto plugin.. I couldn't find the documentation for the connector though, I can see you had made commits but not sure why Kusto isn't listed here ? https://superset.apache.org/docs/intro |
Hi @anshulsharmas, thank you. |
SUMMARY
Add support for Azure Data Explorer (Kusto). My team at @dodopizza has built and maintained the Kusto dialect for SQLAlchemy. It allows us to add a new Kusto engine spec.
Kusto can handle two dialects: SQL and KQL. Currently, we provide full support for the SQL dialect (SELECT queries, no DML) and experimental support for the KQL (work in progress). For more details, you may check sqlalchemy-kusto repo.
We are using SQL dialect in production at our company and working on full support for KQL dialect.
TESTING INSTRUCTIONS
To test manually you may connect to the Kusto database and run some queries in the SQL Lab against it.
Additionally,
sqlalchemy-kusto
includes dialect tests.ADDITIONAL INFORMATION