-
Notifications
You must be signed in to change notification settings - Fork 7.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
Kusto phase1 #37961
Kusto phase1 #37961
Conversation
This is the initial implement of Kusto Query Language. in this commit, we support the following features as MVP : Tabular expression statements Limit returned results Select Column (basic project) sort, order Perform string equality operations Filter using a list of elements Filter using common string operations Some string operators Aggregate by columns Base aggregate functions only support avg, count ,min, max, sum Aggregate by time intervals
Add new test cases
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.
Overall approach with translation into SQL seems fine, though maybe not very efficient in the future for some KQL specific features.
Also I see some issues with expressions sequencing - for example expression t1 | take 3 | order by id
will be evaluated to the same SQL as t1 | order by id | take 3
- apparently you are trying to combine everything into one SELECT which is not always correct...
src/Core/Settings.h
Outdated
@@ -38,6 +38,7 @@ static constexpr UInt64 operator""_GiB(unsigned long long value) | |||
*/ | |||
|
|||
#define COMMON_SETTINGS(M) \ | |||
M(String, sql_dialect, "clickhouse", "Which SQL dialect will be used to parse query", 0)\ |
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.
let's make it just "dialect"
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 feature looks quite marginal, so I would prefer to use longer setting name. We could use just dialect
setting of type Enum
(not String
), but we don't have other dialects for now (and I'm not sure we will have more dialects in the near future). What do you think about something like use_kusto_query_language_dialect
of type Bool
?
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.
@tavplubix Bool
will exclude any other dialects in the future if we decide to add any - it should be mutually exclusive...
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.
there is another PR use the dialect.:
https://github.com/ClickHouse/ClickHouse/pull/36308/files
so there will be more dialects
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.
Ok, so it makes sense to name it just dialect
, but it must be Enum
, not String
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.
Ok, so it makes sense to name it just
dialect
, but it must beEnum
, notString
sure
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.
we changed the dialect to Enum.
yes it's not efficient for some KQL specific features, according the concept of KQL, output of a pipeline is the input of next pipeline, so each pipeline will generate a query, I am not sure if this is efficient in ClickHouse when KQL has a lot of pipe |
ClickHouse will try to optimize of course, but it's not always possible I guess. But for simple cases like this it can be done in KQL parser, so |
yes, we can do for this case |
This is the initial implement of Kusto Query Language. in this commit, we support the following features as MVP : Tabular expression statements Limit returned results Select Column (basic project) sort, order Perform string equality operations Filter using a list of elements Filter using common string operations Some string operators Aggregate by columns Base aggregate functions only support avg, count ,min, max, sum Aggregate by time intervals
Add new test cases
thanks |
I don't think it's correct:
I see at least two discrepancies here - default order should be ASC I think, and both KQL expressions are evaluated to the same SQL, which is not correct - the first one should be |
@yakov-olkhovskiy thanks for the test, default for order in KQL is desc. I will fix the subquery for the limit. |
Hi, @yakov-olkhovskiy I have updated the PR, can you do a test and review again ? Thanks |
Hi @yakov-olkhovskiy , did you get chance to test and review ? Thanks. |
I will check it soon |
@yakov-olkhovskiy I updated the PR according to your suggestions. Thanks |
@kashwy will review it soon |
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.
looks good to me
@yakov-olkhovskiy thank you very much. is it able to merge ? |
@kashwy merged |
thanks, we have added functional test in our phase2 |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
This is the initial implement of Kusto Query Language. (MVP)
Add Support to Kusto Query Language (KQL) as mentioned in this issue:
#36806
In this PR, we support the following features .
We parse KQL queries to ClickHouse ASTs, use a setting called sql_dialect to switch between ClickHouse and KQL:
By default
sql_dialect = 'clickhouse'
set sql_dialect = 'kusto'
Switch to parse KQL
set sql_dialect = 'clickhouse'
switch back to parse ClickHouse SQL.