Skip to content

Commit

Permalink
fix mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-sentry committed Dec 27, 2024
1 parent 40e74f7 commit 2b2cb21
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions snuba/clickhouse/translators/snuba/mappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
SubscriptableReferenceMapper,
ValidColumnMappings,
)
from snuba.query.dsl import Functions as f
from snuba.query.dsl import arrayElement, column
from snuba.query.dsl import arrayElement, column, literal
from snuba.query.expressions import Column as ColumnExpr
from snuba.query.expressions import CurriedFunctionCall, Expression
from snuba.query.expressions import FunctionCall as FunctionCallExpr
Expand Down Expand Up @@ -268,24 +267,30 @@ def attempt_map(
and key.value in self.normalized_columns
and self.data_type
):
return f.CAST(
column(self.normalized_columns[key.value]),
self.data_type,
alias=expression.alias,
return FunctionCallExpr(
expression.alias,
"CAST",
(
column(self.normalized_columns[key.value]),
literal(self.data_type),
),
)

bucket_idx = fnv_1a(key.value.encode("utf-8")) % ATTRIBUTE_BUCKETS
if self.data_type:
return f.CAST(
arrayElement(
None,
ColumnExpr(
None, self.to_col_table, f"{self.to_col_name}_{bucket_idx}"
return FunctionCallExpr(
expression.alias,
"CAST",
(
arrayElement(
None,
ColumnExpr(
None, self.to_col_table, f"{self.to_col_name}_{bucket_idx}"
),
key,
),
key,
literal(self.data_type),
),
self.data_type,
alias=expression.alias,
)
else:
return arrayElement(
Expand Down

0 comments on commit 2b2cb21

Please sign in to comment.