feat: support for KQL in SQLScript#27522
Conversation
02e0c52 to
dbe087f
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #27522 +/- ##
==========================================
+ Coverage 69.83% 69.85% +0.01%
==========================================
Files 1910 1910
Lines 74839 74924 +85
Branches 8351 8351
==========================================
+ Hits 52263 52337 +74
- Misses 20524 20535 +11
Partials 2052 2052
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
| return {} | ||
|
|
||
|
|
||
| class SQLScript: |
There was a problem hiding this comment.
I'm guessing this already has tests?
There was a problem hiding this comment.
Right, this is an existing class that already has tests, it looks like new because the file changed too much.
| INSIDE_MULTILINE_STRING = enum.auto() | ||
|
|
||
|
|
||
| def split_kql(kql: str) -> list[str]: |
There was a problem hiding this comment.
I don't see a test for this
There was a problem hiding this comment.
It's tested indirectly here:
But I'll add some explicit tests.
bc7a159 to
43034d6
Compare
43034d6 to
f22648e
Compare
SUMMARY
This PR is part of SIP-117:
SQLScriptandSQLStatement, and replace any simple calls tosqlparsewith calls to the new classes (chore: improve SQL parsing #26767).SQLStatementclass forKusto, since it doesn't use conventional SQL (this PR).insert_rls_in_predicateandinsert_rls_as_subqueryinsideSQLStatement.get_cte_queryinsideSQLStatement.apply_top_to_sqlinSQLStatement.ParsedQuerywithSQLScriptandSQLStatement.sqlparsefrom Superset.One of the goals of SIP-117 is to encapsulate all SQL parsing and manipulation logic inside two classes:
SQLScriptandSQLStatement(mostly the latter;SQLScriptis just a lightweight collection ofSQLStatementobjects). This includes logic that currently lives inside the DB engine specs (eg,parse_sql,apply_top_to_sql,get_cte_query, etc.).Unfortunately, one of the DB engine specs currently supported by Superset is very unusual. The
KustoKqlEngineSpecengine spec uses a language called KQL that is very different from SQL. In order to move theparse_sqlmethod out of the DB engine spec this PR refactors theSQLStatementclass, introducing aBaseSQLStatementbase class that is used bySQLStatement(for dialects supported bysqlglot) andKustoKQLStatement(for KQL).Note that this is not a path forward for supporting non-SQL databases! I only added support for
KustoKqlEngineSpecbecause it's already there, but IMHO we should deprecate it in the future. Supporting non-SQL databases adds a lot of complexity to Superset, and is a problem that is better solved orthogonally by writing a SQL adapter.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION