Skip to content
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(hogql): select statements #14131

Merged
merged 7 commits into from
Feb 13, 2023
Merged

feat(hogql): select statements #14131

merged 7 commits into from
Feb 13, 2023

Conversation

mariusandra
Copy link
Collaborator

@mariusandra mariusandra commented Feb 8, 2023

We are here now

Changes

Basic full SELECT support for HogQL

[x] selectStmt:
[ ]     with=withClause?
[~]     SELECT DISTINCT? topClause?
[x]     columns=columnExprList
[~]     from=fromClause?
[ ]     arrayJoinClause?
[ ]     windowClause?
[x]     prewhereClause?
[x]     where=whereClause?
[x]     groupByClause? (WITH (CUBE | ROLLUP))? (WITH TOTALS)?
[x]     havingClause?
[x]     orderByClause?
[x]     limitClause?
[ ]     settingsClause?
    ;

Support for WITH, ARRAY JOIN and window functions, along with printing support for JOINS (they're being parsed), is outside the scope of this PR.

All of those require "alias resolution" to work well, which is a chunk of work big enough it needs its own PR. I'd like to get just basic SELECT support merged for that.

How did you test this code?

Many new tests here.

@mariusandra mariusandra changed the title Hogql select statements feat(hogql): select statements Feb 8, 2023
@mariusandra mariusandra changed the base branch from master to antlr-placeholders February 8, 2023 10:43
@mariusandra mariusandra marked this pull request as ready for review February 8, 2023 16:15
Copy link
Collaborator Author

@mariusandra mariusandra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also ready for a review now.

Comment on lines -40 to +39
limitByClause: LIMIT limitExpr BY columnExprList;
limitClause: LIMIT limitExpr (WITH TIES)?;
limitClause: LIMIT limitExpr ((WITH TIES) | BY columnExprList)?;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked and CH doesn't support BOTH a "with ties" and a "by x" ending on "limit" at the same time, though the parser seemed to allow it. Fixed.

Base automatically changed from antlr-placeholders to master February 8, 2023 19:00
Copy link
Collaborator

@Twixes Twixes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't find a hole in this. LGTM

@mariusandra mariusandra merged commit 6764620 into master Feb 13, 2023
@mariusandra mariusandra deleted the hogql-select-statements branch February 13, 2023 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants