Skip to content

Commit 628c371

Browse files
Rachel ChenRachel Chen
authored andcommitted
round
1 parent 298b46c commit 628c371

File tree

8 files changed

+44
-62
lines changed

8 files changed

+44
-62
lines changed

snuba/query/processors/logical/calculated_average_processor.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class CalculatedAverageProcessor(LogicalQueryProcessor):
1616
"""
1717

1818
def process_query(self, query: Query, query_settings: QuerySettings) -> None:
19-
print("huh_process_query")
2019
# use a matcher to find something like avg(value)
2120
matcher = FunctionCallMatch(
2221
Or([String("avg"), String("avgIf")]),
@@ -25,7 +24,6 @@ def process_query(self, query: Query, query_settings: QuerySettings) -> None:
2524
)
2625

2726
def transform_expression(exp: Expression) -> Expression:
28-
print("huh_transform_expression")
2927
match = matcher.match(exp)
3028
if isinstance(exp, FunctionCall) and match is not None:
3129
suffix = "If" if exp.function_name == "avgIf" else ""

snuba/query/processors/logical/filter_in_select_optimizer.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ class FindConditionalAggregateFunctionsVisitor(
4545
"""
4646

4747
def __init__(self) -> None:
48-
print("huh_FindConditionalAggregateFunctionsVisitor")
4948
self._matches: list[FunctionCall | CurriedFunctionCall] = []
5049

5150
def visit_literal(self, exp: Literal) -> list[FunctionCall | CurriedFunctionCall]:
@@ -101,7 +100,6 @@ class FilterInSelectOptimizer(LogicalQueryProcessor):
101100
"""
102101

103102
def process_query(self, query: LogicalQuery, query_settings: QuerySettings) -> None:
104-
print("huh_FilterInSelectOptimizer")
105103
try:
106104
new_condition = self.get_select_filter(query)
107105
except Exception:
@@ -117,7 +115,6 @@ def get_select_filter(
117115
self,
118116
query: LogicalQuery | CompositeQuery[QueryEntity],
119117
) -> FunctionCall | None:
120-
print("huh_get_select_filter")
121118
"""
122119
Given a query, grabs all the conditions from conditional aggregates and lifts into
123120
one condition.

snuba/query/processors/logical/optional_attribute_aggregation.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def __init__(
3232
aggregation_names: list[str],
3333
curried_aggregation_names: list[str],
3434
):
35-
print("huh_OptionalAttributeAggregationTransformer")
3635
self._attribute_column_names = attribute_column_names
3736
self._aggregation_names = aggregation_names
3837
self._curried_aggregation_names = curried_aggregation_names

snuba/web/db_query.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,13 @@ def execute_query(
176176
# Apply clickhouse query setting overrides
177177
clickhouse_query_settings.update(query_settings.get_clickhouse_settings())
178178

179-
print("formatted_queryyyy", formatted_query)
180-
181179
result = reader.execute(
182180
formatted_query,
183181
clickhouse_query_settings,
184182
with_totals=clickhouse_query.has_totals(),
185183
robust=robust,
186184
)
187185

188-
print("resulttttttt", result)
189-
190186
timer.mark("execute")
191187
stats.update(
192188
{

snuba/web/rpc/common/common.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ def _build_label_mapping_key(attr_key: AttributeKey) -> str:
137137

138138
if attr_key.name in NORMALIZED_COLUMNS:
139139
# the second if statement allows Sentry to send TYPE_FLOAT to Snuba when Snuba still has to be backward compatible with TYPE_FLOATS
140-
print("attr_keyyy", attr_key.name, attr_key.type)
141140
if NORMALIZED_COLUMNS[attr_key.name] == attr_key.type or (
142141
attr_key.type == AttributeKey.Type.TYPE_FLOAT
143142
and NORMALIZED_COLUMNS[attr_key.name] == AttributeKey.Type.TYPE_DOUBLE

snuba/web/rpc/v1/resolvers/R_eap_spans/common/aggregation.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,9 @@ def aggregation_to_expression(aggregation: AttributeAggregation) -> Expression:
612612
alias = aggregation.label if aggregation.label else None
613613
alias_dict = {"alias": alias} if alias else {}
614614
function_map: dict[Function.ValueType, CurriedFunctionCall | FunctionCall] = {
615-
Function.FUNCTION_SUM: f.sum(f.multiply(field, sign_column), **alias_dict),
615+
Function.FUNCTION_SUM: f.round(
616+
f.sum(f.multiply(field, sign_column)), 8, **alias_dict
617+
),
616618
Function.FUNCTION_AVERAGE: f.divide(
617619
f.sum(f.multiply(field, sign_column)),
618620
f.sumIf(sign_column, get_field_existence_expression(aggregation)),
@@ -628,7 +630,7 @@ def aggregation_to_expression(aggregation: AttributeAggregation) -> Expression:
628630
Function.FUNCTION_P90: cf.quantile(0.9)(field, **alias_dict),
629631
Function.FUNCTION_P95: cf.quantile(0.95)(field, **alias_dict),
630632
Function.FUNCTION_P99: cf.quantile(0.99)(field, **alias_dict),
631-
Function.FUNCTION_AVG: f.round(f.avg(field), 9, **alias_dict),
633+
Function.FUNCTION_AVG: f.round(f.avg(field), 8, **alias_dict),
632634
Function.FUNCTION_MAX: f.max(field, **alias_dict),
633635
Function.FUNCTION_MIN: f.min(field, **alias_dict),
634636
Function.FUNCTION_UNIQ: f.uniq(field, **alias_dict),

snuba/web/rpc/v1/resolvers/R_eap_spans/resolver_trace_item_table.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,8 @@ def _build_query(request: TraceItemTableRequest) -> Query:
148148
)
149149
elif column.HasField("aggregation"):
150150
function_expr = aggregation_to_expression(column.aggregation)
151-
print("function_expr_1", function_expr)
152151
# aggregation label may not be set and the column label takes priority anyways.
153152
function_expr = replace(function_expr, alias=column.label)
154-
print("function_expr_2", function_expr)
155153
selected_columns.append(
156154
SelectedExpression(name=column.label, expression=function_expr)
157155
)
@@ -188,7 +186,6 @@ def _build_query(request: TraceItemTableRequest) -> Query:
188186
raise BadSnubaRPCRequestException(
189187
"Column is neither an aggregate or an attribute"
190188
)
191-
print("selected_columnsss", selected_columns)
192189
res = Query(
193190
from_clause=entity,
194191
selected_columns=selected_columns,
@@ -244,7 +241,6 @@ def _convert_results(
244241

245242
for column in request.columns:
246243
if column.HasField("key"):
247-
print("columnnnnkey", column, column.key, column.key.type)
248244
if column.key.type == AttributeKey.TYPE_BOOLEAN:
249245
converters[column.label] = lambda x: AttributeValue(val_bool=bool(x))
250246
elif column.key.type == AttributeKey.TYPE_STRING:
@@ -262,8 +258,6 @@ def _convert_results(
262258
"column is neither an attribute or aggregation"
263259
)
264260

265-
print("covertersss", converters)
266-
267261
res: defaultdict[str, TraceItemColumnValues] = defaultdict(TraceItemColumnValues)
268262
for row in data:
269263
for column_name, value in row.items():
@@ -301,16 +295,13 @@ def trace_item_type(cls) -> TraceItemType.ValueType:
301295
return TraceItemType.TRACE_ITEM_TYPE_SPAN
302296

303297
def resolve(self, in_msg: TraceItemTableRequest) -> TraceItemTableResponse:
304-
print("in_msgggg", in_msg)
305298
snuba_request = _build_snuba_request(in_msg)
306299
res = run_query(
307300
dataset=PluggableDataset(name="eap", all_entities=[]),
308301
request=snuba_request,
309302
timer=self._timer,
310303
)
311-
print("ressss", res)
312304
column_values = _convert_results(in_msg, res.result.get("data", []))
313-
print("column_valuesss", column_values)
314305
response_meta = extract_response_meta(
315306
in_msg.meta.request_id,
316307
in_msg.meta.debug,

tests/web/rpc/v1/test_endpoint_trace_item_table/test_endpoint_trace_item_table.py

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -557,37 +557,37 @@ def test_table_with_aggregates(self, setup_teardown: Any) -> None:
557557
)
558558
response = EndpointTraceItemTable().execute(message)
559559

560-
print("responseee", response.column_values)
561-
562-
print(
563-
"RESULTSSS",
564-
[
565-
TraceItemColumnValues(
566-
attribute_name="location",
567-
results=[
568-
AttributeValue(val_str="backend"),
569-
AttributeValue(val_str="frontend"),
570-
AttributeValue(val_str="mobile"),
571-
],
572-
),
573-
TraceItemColumnValues(
574-
attribute_name="max(my.float.field)",
575-
results=[
576-
AttributeValue(val_double=101.2),
577-
AttributeValue(val_double=101.2),
578-
AttributeValue(val_double=101.2),
579-
],
580-
),
581-
TraceItemColumnValues(
582-
attribute_name="avg(my.float.field)",
583-
results=[
584-
AttributeValue(val_double=101.2),
585-
AttributeValue(val_double=101.2),
586-
AttributeValue(val_double=101.2),
587-
],
588-
),
589-
],
590-
)
560+
# print("responseee", response.column_values)
561+
#
562+
# print(
563+
# "RESULTSSS",
564+
# [
565+
# TraceItemColumnValues(
566+
# attribute_name="location",
567+
# results=[
568+
# AttributeValue(val_str="backend"),
569+
# AttributeValue(val_str="frontend"),
570+
# AttributeValue(val_str="mobile"),
571+
# ],
572+
# ),
573+
# TraceItemColumnValues(
574+
# attribute_name="max(my.float.field)",
575+
# results=[
576+
# AttributeValue(val_double=101.2),
577+
# AttributeValue(val_double=101.2),
578+
# AttributeValue(val_double=101.2),
579+
# ],
580+
# ),
581+
# TraceItemColumnValues(
582+
# attribute_name="avg(my.float.field)",
583+
# results=[
584+
# AttributeValue(val_double=101.2),
585+
# AttributeValue(val_double=101.2),
586+
# AttributeValue(val_double=101.2),
587+
# ],
588+
# ),
589+
# ],
590+
# )
591591

592592
assert response.column_values == [
593593
TraceItemColumnValues(
@@ -1159,7 +1159,7 @@ def test_aggregation_filter_basic(self, setup_teardown: Any) -> None:
11591159
aggregation=AttributeAggregation(
11601160
aggregate=Function.FUNCTION_SUM,
11611161
key=AttributeKey(
1162-
type=AttributeKey.TYPE_FLOAT, name="my.float.field"
1162+
type=AttributeKey.TYPE_DOUBLE, name="my.float.field"
11631163
),
11641164
label="sum(my.float.field)",
11651165
extrapolation_mode=ExtrapolationMode.EXTRAPOLATION_MODE_NONE,
@@ -1179,7 +1179,7 @@ def test_aggregation_filter_basic(self, setup_teardown: Any) -> None:
11791179
aggregation=AttributeAggregation(
11801180
aggregate=Function.FUNCTION_SUM,
11811181
key=AttributeKey(
1182-
type=AttributeKey.TYPE_FLOAT, name="my.float.field"
1182+
type=AttributeKey.TYPE_DOUBLE, name="my.float.field"
11831183
),
11841184
label="this-doesnt-matter-and-can-be-left-out",
11851185
),
@@ -1200,8 +1200,8 @@ def test_aggregation_filter_basic(self, setup_teardown: Any) -> None:
12001200
TraceItemColumnValues(
12011201
attribute_name="sum(my.float.field)",
12021202
results=[
1203-
AttributeValue(val_float=1214.4),
1204-
AttributeValue(val_float=3036),
1203+
AttributeValue(val_double=1214.4),
1204+
AttributeValue(val_double=3036),
12051205
],
12061206
),
12071207
]
@@ -1311,8 +1311,8 @@ def test_aggregation_filter_and_or(self, setup_teardown: Any) -> None:
13111311
TraceItemColumnValues(
13121312
attribute_name="sum(my.float.field)",
13131313
results=[
1314-
AttributeValue(val_float=1214.4),
1315-
AttributeValue(val_float=3036),
1314+
AttributeValue(val_double=1214.4),
1315+
AttributeValue(val_double=3036),
13161316
],
13171317
),
13181318
]
@@ -1365,9 +1365,9 @@ def test_aggregation_filter_and_or(self, setup_teardown: Any) -> None:
13651365
TraceItemColumnValues(
13661366
attribute_name="sum(my.float.field)",
13671367
results=[
1368-
AttributeValue(val_float=303.6),
1369-
AttributeValue(val_float=1214.4),
1370-
AttributeValue(val_float=3036),
1368+
AttributeValue(val_double=303.6),
1369+
AttributeValue(val_double=1214.4),
1370+
AttributeValue(val_double=3036),
13711371
],
13721372
),
13731373
]

0 commit comments

Comments
 (0)