@@ -82,12 +82,12 @@ def transform(exp: Expression) -> Expression:
82
82
"sentry.segment_id" : AttributeKey .Type .TYPE_STRING , # this is converted by a processor on the storage
83
83
"sentry.segment_name" : AttributeKey .Type .TYPE_STRING ,
84
84
"sentry.is_segment" : AttributeKey .Type .TYPE_BOOLEAN ,
85
- "sentry.duration_ms" : AttributeKey .Type .TYPE_DOUBLE ,
86
- "sentry.exclusive_time_ms" : AttributeKey .Type .TYPE_DOUBLE ,
85
+ "sentry.duration_ms" : AttributeKey .Type .TYPE_FLOAT ,
86
+ "sentry.exclusive_time_ms" : AttributeKey .Type .TYPE_FLOAT ,
87
87
"sentry.retention_days" : AttributeKey .Type .TYPE_INT ,
88
88
"sentry.name" : AttributeKey .Type .TYPE_STRING ,
89
- "sentry.sampling_weight" : AttributeKey .Type .TYPE_DOUBLE ,
90
- "sentry.sampling_factor" : AttributeKey .Type .TYPE_DOUBLE ,
89
+ "sentry.sampling_weight" : AttributeKey .Type .TYPE_FLOAT ,
90
+ "sentry.sampling_factor" : AttributeKey .Type .TYPE_FLOAT ,
91
91
"sentry.timestamp" : AttributeKey .Type .TYPE_UNSPECIFIED ,
92
92
"sentry.start_timestamp" : AttributeKey .Type .TYPE_UNSPECIFIED ,
93
93
"sentry.end_timestamp" : AttributeKey .Type .TYPE_UNSPECIFIED ,
@@ -102,6 +102,7 @@ def transform(exp: Expression) -> Expression:
102
102
103
103
def attribute_key_to_expression (attr_key : AttributeKey ) -> Expression :
104
104
print ("typeeeeee" , attr_key )
105
+
105
106
def _build_label_mapping_key (attr_key : AttributeKey ) -> str :
106
107
return attr_key .name + "_" + AttributeKey .Type .Name (attr_key .type )
107
108
@@ -125,10 +126,14 @@ def _build_label_mapping_key(attr_key: AttributeKey) -> str:
125
126
)
126
127
if attr_key .type == AttributeKey .Type .TYPE_INT :
127
128
return f .CAST (column (attr_key .name [len ("sentry." ) :]), "Int64" , alias = alias )
128
- if attr_key .type == AttributeKey .Type .TYPE_DOUBLE :
129
- print ("timestamp_columnsssss" , f .CAST (
130
- column (attr_key .name [len ("sentry." ) :]), "Float64" , alias = alias
131
- ))
129
+ if (
130
+ attr_key .type == AttributeKey .Type .TYPE_FLOAT
131
+ or attr_key .type == AttributeKey .Type .TYPE_DOUBLE
132
+ ):
133
+ print (
134
+ "timestamp_columnsssss" ,
135
+ f .CAST (column (attr_key .name [len ("sentry." ) :]), "Float64" , alias = alias ),
136
+ )
132
137
return f .CAST (
133
138
column (attr_key .name [len ("sentry." ) :]), "Float64" , alias = alias
134
139
)
@@ -137,7 +142,11 @@ def _build_label_mapping_key(attr_key: AttributeKey) -> str:
137
142
)
138
143
139
144
if attr_key .name in NORMALIZED_COLUMNS :
140
- if NORMALIZED_COLUMNS [attr_key .name ] == attr_key .type :
145
+ # the second if statement is saying if Sentry sends Snuba TYPE_FLOATS when Snuba already supports TYPE_DOUBLE. This is needed for backward compatibility
146
+ if NORMALIZED_COLUMNS [attr_key .name ] == attr_key .type or (
147
+ attr_key .type == AttributeKey .Type .TYPE_DOUBLE
148
+ and NORMALIZED_COLUMNS [attr_key .name ] == AttributeKey .Type .TYPE_FLOAT
149
+ ):
141
150
return column (attr_key .name [len ("sentry." ) :], alias = attr_key .name )
142
151
raise BadSnubaRPCRequestException (
143
152
f"Attribute { attr_key .name } must be requested as { NORMALIZED_COLUMNS [attr_key .name ]} , got { attr_key .type } "
@@ -148,10 +157,16 @@ def _build_label_mapping_key(attr_key: AttributeKey) -> str:
148
157
return SubscriptableReference (
149
158
alias = alias , column = column ("attr_str" ), key = literal (attr_key .name )
150
159
)
151
- if attr_key .type == AttributeKey .Type .TYPE_DOUBLE :
152
- print ("subscriptableeeee" , SubscriptableReference (
153
- alias = alias , column = column ("attr_num" ), key = literal (attr_key .name )
154
- ))
160
+ if (
161
+ attr_key .type == AttributeKey .Type .TYPE_FLOAT
162
+ or attr_key .type == AttributeKey .Type .TYPE_DOUBLE
163
+ ):
164
+ print (
165
+ "subscriptableeeee" ,
166
+ SubscriptableReference (
167
+ alias = alias , column = column ("attr_num" ), key = literal (attr_key .name )
168
+ ),
169
+ )
155
170
return SubscriptableReference (
156
171
alias = alias , column = column ("attr_num" ), key = literal (attr_key .name )
157
172
)
0 commit comments