-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
fix(materialization): dont always run get column on update if no query is there #29271
base: master
Are you sure you want to change the base?
Conversation
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.
PR Summary
This PR optimizes the update process for saved queries in the data warehouse by avoiding unnecessary column recalculation when the query itself hasn't changed.
- Modified
DataWarehouseSavedQuerySerializer.update()
inposthog/warehouse/api/saved_query.py
to only callget_columns()
and update status when the query field is present in validated data - Added test
test_update_without_query_change_doesnt_call_get_columns
inposthog/warehouse/api/test/test_saved_query.py
to verify optimization when only updating the name - Added test
test_update_with_query_change_calls_get_columns
to ensure column recalculation still happens when the query changes - This optimization improves performance for view updates by eliminating redundant processing
2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile
except RecursionError: | ||
raise serializers.ValidationError("Model contains a cycle") | ||
except Exception as err: | ||
raise serializers.ValidationError(str(err)) |
Check warning
Code scanning / CodeQL
Information exposure through an exception Medium
Stack trace information
Stack trace information
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 1 day ago
To fix the problem, we should avoid exposing the detailed error message to the end user. Instead, we can log the detailed error message on the server and return a generic error message to the user. This approach ensures that developers can still access the detailed error information for debugging purposes, while the end user only sees a generic message.
- Modify the code on line 154 to log the detailed error message using the
logger
and raise aserializers.ValidationError
with a generic error message. - Ensure that the
logger
is used to capture the detailed error information.
-
Copy modified lines R154-R155
@@ -153,3 +153,4 @@ | ||
except Exception as err: | ||
raise serializers.ValidationError(str(err)) | ||
logger.exception("An error occurred while updating the view: %s", err) | ||
raise serializers.ValidationError("An internal error has occurred.") | ||
|
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.
Best to avoid doing this when we can.
Problem
Changes
👉 Stay up-to-date with PostHog coding conventions for a smoother review.
Does this work well for both Cloud and self-hosted?
How did you test this code?