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(ourlogs): Add item type check to resolver #6914

Merged
merged 1 commit into from
Feb 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from snuba.datasets.pluggable_dataset import PluggableDataset
from snuba.query import OrderBy, OrderByDirection, SelectedExpression
from snuba.query.data_source.simple import Entity
from snuba.query.dsl import Functions as f
from snuba.query.dsl import column
from snuba.query.logical import Query
from snuba.query.query_settings import HTTPQuerySettings
from snuba.request import Request as SnubaRequest
Expand Down Expand Up @@ -68,14 +70,14 @@ def _build_query(request: TraceItemTableRequest) -> Query:
)

selected_columns = []
for column in request.columns:
if column.HasField("key"):
key_col = attribute_key_to_expression(column.key)
for col in request.columns:
if col.HasField("key"):
key_col = attribute_key_to_expression(col.key)
Comment on lines -71 to +75
Copy link
Member

Choose a reason for hiding this comment

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

why the rename?

Copy link
Member Author

Choose a reason for hiding this comment

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

python hoists the column out of the loop scope to shadow the import, makes pypy mad

# The key_col expression alias may differ from the column label. That is okay
# the attribute key name is used in the groupby, the column label is just the name of
# the returned attribute value
selected_columns.append(
SelectedExpression(name=column.label, expression=key_col)
SelectedExpression(name=col.label, expression=key_col)
)
else:
raise BadSnubaRPCRequestException(
Expand All @@ -87,6 +89,7 @@ def _build_query(request: TraceItemTableRequest) -> Query:
selected_columns=selected_columns,
condition=base_conditions_and(
request.meta,
f.equals(column("item_type"), TraceItemType.TRACE_ITEM_TYPE_LOG),
trace_item_filters_to_expression(
request.filter, attribute_key_to_expression
),
Expand Down
Loading