-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
typing(search): Add parent class for ErrorsQueryBuilder #78213
base: master
Are you sure you want to change the base?
Conversation
@@ -30,7 +31,7 @@ | |||
value_converters = {"status": convert_status_value} | |||
|
|||
|
|||
class ErrorsQueryBuilderMixin: | |||
class ErrorsQueryBuilderMixin(BaseQueryBuilder): |
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.
The missing parameters are set here:
sentry/src/sentry/search/events/builder/base.py
Lines 180 to 289 in b5f1809
def __init__( | |
self, | |
dataset: Dataset, | |
params: ParamsType, | |
config: QueryBuilderConfig | None = None, | |
snuba_params: SnubaParams | None = None, | |
query: str | None = None, | |
selected_columns: list[str] | None = None, | |
groupby_columns: list[str] | None = None, | |
equations: list[str] | None = None, | |
orderby: list[str] | str | None = None, | |
limit: int | None = 50, | |
offset: int | None = 0, | |
limitby: tuple[str, int] | None = None, | |
turbo: bool = False, | |
sample_rate: float | None = None, | |
array_join: str | None = None, | |
entity: Entity | None = None, | |
): | |
if config is None: | |
self.builder_config = QueryBuilderConfig() | |
else: | |
self.builder_config = config | |
if self.builder_config.parser_config_overrides is None: | |
self.builder_config.parser_config_overrides = {} | |
self.dataset = dataset | |
# filter params is the older style params, shouldn't be used anymore | |
self.filter_params = params | |
if snuba_params is not None: | |
self.filter_params = snuba_params.filter_params | |
self.params = self._dataclass_params(snuba_params, params) | |
org_id = self.params.organization_id | |
self.organization_id: int | None = ( | |
org_id if org_id is not None and isinstance(org_id, int) else None | |
) | |
self.raw_equations = equations | |
self.raw_orderby = orderby | |
self.query = query | |
self.selected_columns = selected_columns | |
self.groupby_columns = groupby_columns | |
self.tips: dict[str, set[str]] = { | |
"query": set(), | |
"columns": set(), | |
} | |
# Base Tenant IDs for any Snuba Request built/executed using a QueryBuilder | |
org_id = self.organization_id or ( | |
self.params.organization.id if self.params.organization else None | |
) | |
self.tenant_ids: dict[str, str | None | int] | None = dict() | |
if org_id is not None: | |
self.tenant_ids["organization_id"] = org_id | |
if "use_case_id" in params and params.get("use_case_id") is not None: | |
self.tenant_ids["use_case_id"] = params.get("use_case_id") | |
if not self.tenant_ids: | |
self.tenant_ids = None | |
# Function is a subclass of CurriedFunction | |
self.where: list[WhereType] = [] | |
self.having: list[WhereType] = [] | |
# The list of aggregates to be selected | |
self.aggregates: list[CurriedFunction] = [] | |
self.columns: list[SelectType] = [] | |
self.orderby: list[OrderBy] = [] | |
self.groupby: list[SelectType] = [] | |
self.projects_to_filter: set[int] = set() | |
self.function_alias_map: dict[str, fields.FunctionDetails] = {} | |
self.equation_alias_map: dict[str, SelectType] = {} | |
# field: function map for post-processing values | |
self.value_resolver_map: dict[str, Callable[[Any], Any]] = {} | |
# value_resolver_map may change type | |
self.meta_resolver_map: dict[str, str] = {} | |
# These maps let us convert from prefixed to original tag keys | |
# and vice versa to avoid collisions where tags and functions have | |
# similar aliases | |
self.prefixed_to_tag_map: dict[str, str] = {} | |
self.tag_to_prefixed_map: dict[str, str] = {} | |
# Tags with their type in them can't be passed to clickhouse because of the space | |
# This map is so we can convert those back before the user sees the internal alias | |
self.typed_tag_to_alias_map: dict[str, str] = {} | |
self.alias_to_typed_tag_map: dict[str, str] = {} | |
self.requires_other_aggregates = False | |
self.limit = self.resolve_limit(limit) | |
self.offset = None if offset is None else Offset(offset) | |
self.turbo = turbo | |
self.sample_rate = sample_rate | |
self.config = self.load_config() | |
self.parse_config() | |
self.start: datetime | None = None | |
self.end: datetime | None = None | |
self.resolve_query( | |
query=query, | |
selected_columns=selected_columns, | |
groupby_columns=groupby_columns, | |
equations=equations, | |
orderby=orderby, | |
) | |
self.entity = entity | |
self.limitby = self.resolve_limitby(limitby) | |
self.array_join = None if array_join is None else [self.resolve_column(array_join)] |
mypy src/sentry/search/events/builder/errors.py
src/sentry/search/events/builder/errors.py:40: error: "parse_query" undefined in superclass [misc]
src/sentry/search/events/builder/errors.py:43: error: "ErrorsQueryBuilderMixin" has no attribute "params" [attr-defined]
src/sentry/search/events/builder/errors.py:44: error: "ErrorsQueryBuilderMixin" has no attribute "params" [attr-defined]
src/sentry/search/events/builder/errors.py:45: error: "ErrorsQueryBuilderMixin" has no attribute "params" [attr-defined]
src/sentry/search/events/builder/errors.py:52: error: "ErrorsQueryBuilderMixin" has no attribute "dataset" [attr-defined]
src/sentry/search/events/builder/errors.py:52: error: "ErrorsQueryBuilderMixin" has no attribute "sample_rate" [attr-defined]
src/sentry/search/events/builder/errors.py:62: error: "resolve_params" undefined in superclass [misc]
src/sentry/search/events/builder/errors.py:68: error: "ErrorsQueryBuilderMixin" has no attribute "params" [attr-defined]
src/sentry/search/events/builder/errors.py:81: error: "resolve_query" undefined in superclass [misc]
src/sentry/search/events/builder/errors.py:85: error: "aliased_column" undefined in superclass [misc]
src/sentry/search/events/builder/errors.py:100: error: "ErrorsQueryBuilderMixin" has no attribute "resolve_column_name" [attr-defined]
src/sentry/search/events/builder/errors.py:108: error: "ErrorsQueryBuilderMixin" has no attribute "dataset" [attr-defined]
Found 12 errors in 1 file (checked 1 source file)
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.
mixins in general aren't typesafe -- this should probably be refactored to composition or otherwise
Codecov ReportAll modified and coverable lines are covered by tests ✅ ✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #78213 +/- ##
==========================================
+ Coverage 78.09% 78.10% +0.01%
==========================================
Files 7036 7038 +2
Lines 311491 311519 +28
Branches 50913 50916 +3
==========================================
+ Hits 243264 243322 +58
+ Misses 56468 56447 -21
+ Partials 11759 11750 -9 |
This pull request has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you add the label "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
This pull request has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you add the label "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
This pull request has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you add the label "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
This pull request has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you add the label "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
Fixes these issues: