Skip to content
Draft
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
22 changes: 11 additions & 11 deletions snuba/web/rpc/v1/visitors/trace_item_table_request_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ def visit_TraceItemTableRequest(self, node: TraceItemTableRequest) -> None:
if column.label == "":
continue
if column.label in self.column_labels:
raise BadSnubaRPCRequestException(
f"Duplicate column label: {column.label}"
)
raise BadSnubaRPCRequestException(f"Duplicate column label: {column.label}")
self.column_labels.add(column.label)

for column in node.columns:
Expand Down Expand Up @@ -113,7 +111,13 @@ def visit_TraceItemTableRequest(self, node: TraceItemTableRequest) -> None:
def visit_Column(self, node: Column, new_label: str) -> None:
node.label = new_label

match node.WhichOneof("column"):
column_type = node.WhichOneof("column")
# Handle columns that only have a label but no column type
# (e.g., order_by columns that reference existing columns by label)
if column_type is None:
return

match column_type:
case "key":
self.visit(node.key, new_label)
case "aggregation":
Expand All @@ -125,14 +129,12 @@ def visit_Column(self, node: Column, new_label: str) -> None:
case "literal":
self.visit(node.literal, new_label)
case _:
raise ValueError(f"Unknown column type: {node.WhichOneof('column')}")
raise ValueError(f"Unknown column type: {column_type}")

def visit_AttributeKey(self, node: AttributeKey, new_label: str) -> None:
return

def visit_AttributeAggregation(
self, node: AttributeAggregation, new_label: str
) -> None:
def visit_AttributeAggregation(self, node: AttributeAggregation, new_label: str) -> None:
node.label = new_label

def visit_AttributeConditionalAggregation(
Expand Down Expand Up @@ -188,7 +190,5 @@ def visit_Column(self, node: Column) -> None:
def visit_AttributeAggregation(self, node: AttributeAggregation) -> None:
node.label = self.current_label

def visit_AttributeConditionalAggregation(
self, node: AttributeConditionalAggregation
) -> None:
def visit_AttributeConditionalAggregation(self, node: AttributeConditionalAggregation) -> None:
node.label = self.current_label
Loading