Skip to content

Conversation

yakkomajuri
Copy link
Contributor

Adds support for a SAMPLE clause to HogQL, with OFFSET support as well.

https://clickhouse.com/docs/en/sql-reference/statements/select/sample/

@yakkomajuri yakkomajuri requested a review from mariusandra March 14, 2023 11:09
yakkomajuri and others added 4 commits March 14, 2023 08:32
Co-authored-by: Marius Andra <marius.andra@gmail.com>
Copy link
Collaborator

@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.

Found one thing that should be changed, the rest looks really good!

I'd also add a test where we have a join with multiple sampled tables in the query.

@yakkomajuri
Copy link
Contributor Author

@mariusandra all addressed!

Copy link
Collaborator

@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.

Great work!

However I remembered now that I forgot one more thing 😅. To own my mistake of not thinking of it earlier, I made a quick commit instead of asking you to fix it again (though I know you would have happily done it).

Anyway, we have two visitor classes in hogql/visitor.py that a lot of other visitors inherit from. These used when you want to write a quick visitor and just fill in one or two functions, such as the "field and property collector" I moved in this PR. These also need to know about the sampling clause.

It's a bit unfortunate we don't have anything automatic to catch that we didn't add these functions to the visitors, but I'm not sure what's a good way to check that. This might come back to bite us slightly one day 🤔

@mariusandra mariusandra merged commit c8a367f into master Mar 15, 2023
@mariusandra mariusandra deleted the sample-hogql branch March 15, 2023 21:21
fuziontech added a commit that referenced this pull request Mar 16, 2023
* master: (101 commits)
  feat: feedback tab - improve the UI and switch to HogQL (#14777)
  feat(experiments): cache experiment results (#14742)
  fix(empty-state): properly fix query timeout state (#14793)
  chore(feature-flag): release json payload flag (#14775)
  feat(hogql): make sure joins work with properties (#14790)
  test(frontend): Tune visual regression test failure threshold (#14766)
  feat(hogql): count distinct and count star (#14786)
  feat(perf): only load experiment results once (#14772)
  feat: allow new insight type choice from sidebar (#14759)
  fix(persons): hide persons in the future (#14308)
  feat: allow query cards in saved insights grid (#14784)
  fix(lemon-ui): Align padding for small/large buttons with icons (#14750)
  chore(deps): Upgrade TypeScript from 4.8 to 4.9 in the frontend (#14609)
  feat: rename insight query tab to json tab (#14781)
  feat: use same top heading for insight card and exported insight (#14780)
  feat: define new insight urls in one place (#14778)
  fix(hogql): person properties in a funnel breakdown (#14765)
  fix: hide query based insights in recently viewed list (#14774)
  feat: improve query summaries (#14768)
  feat(hogql): add sampling support (#14733)
  ...
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