-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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): add readonly=1 and max_execution_time=60 on every query #14870
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,8 @@ | |
WHERE and(equals(events.team_id, 66), less(events.timestamp, '2020-01-10 12:14:05.000000'), greater(events.timestamp, '2020-01-09 12:00:00.000000')) | ||
ORDER BY events.event ASC | ||
LIMIT 101 | ||
OFFSET 0 | ||
OFFSET 0 SETTINGS readonly=1, | ||
max_execution_time=60 | ||
' | ||
--- | ||
# name: TestQuery.test_event_property_filter.1 | ||
|
@@ -25,7 +26,8 @@ | |
WHERE and(equals(events.team_id, 66), equals(replaceRegexpAll(JSONExtractRaw(events.properties, 'key'), '^"|"$', ''), 'test_val3'), less(events.timestamp, '2020-01-10 12:14:05.000000'), greater(events.timestamp, '2020-01-09 12:00:00.000000')) | ||
ORDER BY events.event ASC | ||
LIMIT 101 | ||
OFFSET 0 | ||
OFFSET 0 SETTINGS readonly=1, | ||
max_execution_time=60 | ||
' | ||
--- | ||
# name: TestQuery.test_event_property_filter.2 | ||
|
@@ -40,7 +42,8 @@ | |
WHERE and(equals(events.team_id, 66), ilike(replaceRegexpAll(JSONExtractRaw(events.properties, 'path'), '^"|"$', ''), '%/%'), less(events.timestamp, '2020-01-10 12:14:05.000000'), greater(events.timestamp, '2020-01-09 12:00:00.000000')) | ||
ORDER BY events.event ASC | ||
LIMIT 101 | ||
OFFSET 0 | ||
OFFSET 0 SETTINGS readonly=1, | ||
max_execution_time=60 | ||
' | ||
--- | ||
# name: TestQuery.test_event_property_filter_materialized | ||
|
@@ -55,7 +58,8 @@ | |
WHERE and(equals(events.team_id, 67), less(events.timestamp, '2020-01-10 12:14:05.000000'), greater(events.timestamp, '2020-01-09 12:00:00.000000')) | ||
ORDER BY events.event ASC | ||
LIMIT 101 | ||
OFFSET 0 | ||
OFFSET 0 SETTINGS readonly=1, | ||
max_execution_time=60 | ||
' | ||
--- | ||
# name: TestQuery.test_event_property_filter_materialized.1 | ||
|
@@ -70,7 +74,8 @@ | |
WHERE and(equals(events.team_id, 67), equals(events.mat_key, 'test_val3'), less(events.timestamp, '2020-01-10 12:14:05.000000'), greater(events.timestamp, '2020-01-09 12:00:00.000000')) | ||
ORDER BY events.event ASC | ||
LIMIT 101 | ||
OFFSET 0 | ||
OFFSET 0 SETTINGS readonly=1, | ||
max_execution_time=60 | ||
' | ||
--- | ||
# name: TestQuery.test_event_property_filter_materialized.2 | ||
|
@@ -85,7 +90,8 @@ | |
WHERE and(equals(events.team_id, 67), ilike(events.mat_path, '%/%'), less(events.timestamp, '2020-01-10 12:14:05.000000'), greater(events.timestamp, '2020-01-09 12:00:00.000000')) | ||
ORDER BY events.event ASC | ||
LIMIT 101 | ||
OFFSET 0 | ||
OFFSET 0 SETTINGS readonly=1, | ||
max_execution_time=60 | ||
' | ||
--- | ||
# name: TestQuery.test_full_hogql_query | ||
|
@@ -97,7 +103,8 @@ | |
FROM events | ||
WHERE equals(events.team_id, 68) | ||
ORDER BY events.timestamp ASC | ||
LIMIT 100 | ||
LIMIT 100 SETTINGS readonly=1, | ||
max_execution_time=60 | ||
' | ||
--- | ||
# name: TestQuery.test_full_hogql_query_materialized | ||
|
@@ -109,7 +116,8 @@ | |
FROM events | ||
WHERE equals(events.team_id, 69) | ||
ORDER BY events.timestamp ASC | ||
LIMIT 100 | ||
LIMIT 100 SETTINGS readonly=1, | ||
max_execution_time=60 | ||
' | ||
--- | ||
# name: TestQuery.test_hogql_property_filter | ||
|
@@ -124,7 +132,8 @@ | |
WHERE and(equals(events.team_id, 70), less(events.timestamp, '2020-01-10 12:14:05.000000'), greater(events.timestamp, '2020-01-09 12:00:00.000000')) | ||
ORDER BY events.event ASC | ||
LIMIT 101 | ||
OFFSET 0 | ||
OFFSET 0 SETTINGS readonly=1, | ||
max_execution_time=60 | ||
' | ||
--- | ||
# name: TestQuery.test_hogql_property_filter.1 | ||
|
@@ -139,7 +148,8 @@ | |
WHERE and(equals(events.team_id, 70), equals('a%sd', 'foo'), less(events.timestamp, '2020-01-10 12:14:05.000000'), greater(events.timestamp, '2020-01-09 12:00:00.000000')) | ||
ORDER BY events.event ASC | ||
LIMIT 101 | ||
OFFSET 0 | ||
OFFSET 0 SETTINGS readonly=1, | ||
max_execution_time=60 | ||
' | ||
--- | ||
# name: TestQuery.test_hogql_property_filter.2 | ||
|
@@ -154,7 +164,8 @@ | |
WHERE and(equals(events.team_id, 70), equals('a%sd', 'a%sd'), less(events.timestamp, '2020-01-10 12:14:05.000000'), greater(events.timestamp, '2020-01-09 12:00:00.000000')) | ||
ORDER BY events.event ASC | ||
LIMIT 101 | ||
OFFSET 0 | ||
OFFSET 0 SETTINGS readonly=1, | ||
max_execution_time=60 | ||
' | ||
--- | ||
# name: TestQuery.test_hogql_property_filter.3 | ||
|
@@ -169,7 +180,8 @@ | |
WHERE and(equals(events.team_id, 70), equals(replaceRegexpAll(JSONExtractRaw(events.properties, 'key'), '^"|"$', ''), 'test_val2'), less(events.timestamp, '2020-01-10 12:14:05.000000'), greater(events.timestamp, '2020-01-09 12:00:00.000000')) | ||
ORDER BY events.event ASC | ||
LIMIT 101 | ||
OFFSET 0 | ||
OFFSET 0 SETTINGS readonly=1, | ||
max_execution_time=60 | ||
' | ||
--- | ||
# name: TestQuery.test_hogql_property_filter_materialized | ||
|
@@ -184,7 +196,8 @@ | |
WHERE and(equals(events.team_id, 71), less(events.timestamp, '2020-01-10 12:14:05.000000'), greater(events.timestamp, '2020-01-09 12:00:00.000000')) | ||
ORDER BY events.event ASC | ||
LIMIT 101 | ||
OFFSET 0 | ||
OFFSET 0 SETTINGS readonly=1, | ||
max_execution_time=60 | ||
' | ||
--- | ||
# name: TestQuery.test_hogql_property_filter_materialized.1 | ||
|
@@ -199,7 +212,8 @@ | |
WHERE and(equals(events.team_id, 71), equals('a%sd', 'foo'), less(events.timestamp, '2020-01-10 12:14:05.000000'), greater(events.timestamp, '2020-01-09 12:00:00.000000')) | ||
ORDER BY events.event ASC | ||
LIMIT 101 | ||
OFFSET 0 | ||
OFFSET 0 SETTINGS readonly=1, | ||
max_execution_time=60 | ||
' | ||
--- | ||
# name: TestQuery.test_hogql_property_filter_materialized.2 | ||
|
@@ -214,7 +228,8 @@ | |
WHERE and(equals(events.team_id, 71), equals('a%sd', 'a%sd'), less(events.timestamp, '2020-01-10 12:14:05.000000'), greater(events.timestamp, '2020-01-09 12:00:00.000000')) | ||
ORDER BY events.event ASC | ||
LIMIT 101 | ||
OFFSET 0 | ||
OFFSET 0 SETTINGS readonly=1, | ||
max_execution_time=60 | ||
' | ||
--- | ||
# name: TestQuery.test_hogql_property_filter_materialized.3 | ||
|
@@ -229,7 +244,8 @@ | |
WHERE and(equals(events.team_id, 71), equals(events.mat_key, 'test_val2'), less(events.timestamp, '2020-01-10 12:14:05.000000'), greater(events.timestamp, '2020-01-09 12:00:00.000000')) | ||
ORDER BY events.event ASC | ||
LIMIT 101 | ||
OFFSET 0 | ||
OFFSET 0 SETTINGS readonly=1, | ||
max_execution_time=60 | ||
' | ||
--- | ||
# name: TestQuery.test_person_property_filter | ||
|
@@ -258,7 +274,8 @@ | |
WHERE and(equals(events.team_id, 75), equals(events__pdi__person.properties___email, '[email protected]'), less(events.timestamp, '2020-01-10 12:14:05.000000'), greater(events.timestamp, '2020-01-09 12:00:00.000000')) | ||
ORDER BY events.event ASC | ||
LIMIT 101 | ||
OFFSET 0 | ||
OFFSET 0 SETTINGS readonly=1, | ||
max_execution_time=60 | ||
' | ||
--- | ||
# name: TestQuery.test_person_property_filter_materialized | ||
|
@@ -287,7 +304,8 @@ | |
WHERE and(equals(events.team_id, 76), equals(events__pdi__person.properties___email, '[email protected]'), less(events.timestamp, '2020-01-10 12:14:05.000000'), greater(events.timestamp, '2020-01-09 12:00:00.000000')) | ||
ORDER BY events.event ASC | ||
LIMIT 101 | ||
OFFSET 0 | ||
OFFSET 0 SETTINGS readonly=1, | ||
max_execution_time=60 | ||
' | ||
--- | ||
# name: TestQuery.test_property_filter_aggregations | ||
|
@@ -300,7 +318,8 @@ | |
GROUP BY replaceRegexpAll(JSONExtractRaw(events.properties, 'key'), '^"|"$', '') | ||
ORDER BY count() DESC | ||
LIMIT 101 | ||
OFFSET 0 | ||
OFFSET 0 SETTINGS readonly=1, | ||
max_execution_time=60 | ||
' | ||
--- | ||
# name: TestQuery.test_property_filter_aggregations.1 | ||
|
@@ -314,7 +333,8 @@ | |
HAVING and(greater(count(), 1)) | ||
ORDER BY count() DESC | ||
LIMIT 101 | ||
OFFSET 0 | ||
OFFSET 0 SETTINGS readonly=1, | ||
max_execution_time=60 | ||
' | ||
--- | ||
# name: TestQuery.test_property_filter_aggregations_materialized | ||
|
@@ -327,7 +347,8 @@ | |
GROUP BY events.mat_key | ||
ORDER BY count() DESC | ||
LIMIT 101 | ||
OFFSET 0 | ||
OFFSET 0 SETTINGS readonly=1, | ||
max_execution_time=60 | ||
' | ||
--- | ||
# name: TestQuery.test_property_filter_aggregations_materialized.1 | ||
|
@@ -341,7 +362,8 @@ | |
HAVING and(greater(count(), 1)) | ||
ORDER BY count() DESC | ||
LIMIT 101 | ||
OFFSET 0 | ||
OFFSET 0 SETTINGS readonly=1, | ||
max_execution_time=60 | ||
' | ||
--- | ||
# name: TestQuery.test_select_event_person | ||
|
@@ -354,7 +376,8 @@ | |
WHERE and(equals(events.team_id, 79), less(events.timestamp, '2020-01-10 12:14:05.000000'), greater(events.timestamp, '2020-01-09 12:00:00.000000')) | ||
ORDER BY events.event ASC | ||
LIMIT 101 | ||
OFFSET 0 | ||
OFFSET 0 SETTINGS readonly=1, | ||
max_execution_time=60 | ||
' | ||
--- | ||
# name: TestQuery.test_select_hogql_expressions | ||
|
@@ -368,7 +391,8 @@ | |
WHERE and(equals(events.team_id, 80), less(events.timestamp, '2020-01-10 12:14:05.000000'), greater(events.timestamp, '2020-01-09 12:00:00.000000')) | ||
ORDER BY replaceRegexpAll(JSONExtractRaw(events.properties, 'key'), '^"|"$', '') ASC | ||
LIMIT 101 | ||
OFFSET 0 | ||
OFFSET 0 SETTINGS readonly=1, | ||
max_execution_time=60 | ||
' | ||
--- | ||
# name: TestQuery.test_select_hogql_expressions.1 | ||
|
@@ -380,7 +404,8 @@ | |
WHERE and(equals(events.team_id, 80), less(events.timestamp, '2020-01-10 12:14:05.000000'), greater(events.timestamp, '2020-01-09 12:00:00.000000')) | ||
ORDER BY tuple(events.uuid, events.event, events.properties, events.timestamp, events.team_id, events.distinct_id, events.elements_chain, events.created_at) ASC | ||
LIMIT 101 | ||
OFFSET 0 | ||
OFFSET 0 SETTINGS readonly=1, | ||
max_execution_time=60 | ||
' | ||
--- | ||
# name: TestQuery.test_select_hogql_expressions.2 | ||
|
@@ -393,7 +418,8 @@ | |
GROUP BY events.event | ||
ORDER BY count() DESC | ||
LIMIT 101 | ||
OFFSET 0 | ||
OFFSET 0 SETTINGS readonly=1, | ||
max_execution_time=60 | ||
' | ||
--- | ||
# name: TestQuery.test_select_hogql_expressions.3 | ||
|
@@ -406,6 +432,7 @@ | |
GROUP BY events.event | ||
ORDER BY count() DESC, events.event ASC | ||
LIMIT 101 | ||
OFFSET 0 | ||
OFFSET 0 SETTINGS readonly=1, | ||
max_execution_time=60 | ||
' | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we want to be able to remove
readonly
? Should this be constant 1 forcing us to change code if we wanted to let HogQL do non-selects?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.
I guess we can change it then :)
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.
So this is allowed
this prints
So, if we can accidentally or someone can maliciously get us to create settings with
HogQLSettings(readonly=None)
then we don't have readonly set on the query.If we're saying that HogQL is readonly a constant here feels safer
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.
Yeah, but none of the settings come from users --> we set them ourselves, and it's hardcoded in. I opted out of using feature flags to set these settings just for this reason. Now, if we want, we could, e.g. override some of them for some longer queries, e.g. setting max execution time to 5min for exports.
Theoretically we can also override
readonly
, but 1) nothing does that now, 2) users will not be able to set these settings... at least not directly, 3) it's still a select query so it's anyway an extra safety measure.