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): use readonly user for hogql queries if available #15889

Merged
merged 3 commits into from
Jun 5, 2023

Conversation

yakkomajuri
Copy link
Contributor

@yakkomajuri yakkomajuri commented Jun 5, 2023

safety and all.

tested locally and it works

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.

If these are the right vars and a connection can be made from production EU and US with them... then LGTM! Thanks! 👍

Comment on lines +85 to +86
has_joins="JOIN" in clickhouse_sql,
has_json_operations="JSONExtract" in clickhouse_sql or "JSONHas" in clickhouse_sql,
Copy link
Collaborator

Choose a reason for hiding this comment

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

How accurate do we want to be with these two tags? Since we have the full modified pre-printer AST available to us (lazy tables expanded, etc), we can just use a quick visitor that checks if there's a select query with any joins for a 100% accurate answer. See e.g. AggregationFinder in property.py. The current simple check will also catch ARRAY JOIN-s, which I'm not sure if it's the intention or not.

As for JSONExtract, that's trickier to autodetect based on HogQL, as property access is expanded in the printer. So yeah, this here is the safest way though there might be some extremely rare duplicates.

All in all, do with the context above what you think is best :).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As of right now I just moved this since the default for all queries is to do lookups like this.

It was happening inside insight_sync_execute.

Will just keep as is for now

@yakkomajuri yakkomajuri merged commit 3fcc984 into master Jun 5, 2023
@yakkomajuri yakkomajuri deleted the hogql-readonly branch June 5, 2023 14:57
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