@@ -186,29 +186,16 @@ def generate_prefix(self, log_source_signature: CortexXQLLogSourceSignature, fun
186186 return f"{ functions_prefix } { log_source_signature } "
187187
188188 def apply_token (self , token : Union [FieldValue , Keyword , Identifier ], source_mapping : SourceMapping ) -> str :
189- if (
190- isinstance (token , FieldValue )
191- and source_mapping .source_id in SOURCE_MAPPING_TO_FIELD_VALUE_MAP
192- and token .field .source_name in SOURCE_MAPPING_TO_FIELD_VALUE_MAP [source_mapping .source_id ]
193- ):
194- values_to_update = []
195- token_values = token .values
196- for token_value in token_values :
197- if (
198- isinstance (token_value , str )
199- and token_value
200- in SOURCE_MAPPING_TO_FIELD_VALUE_MAP [source_mapping .source_id ][token .field .source_name ]
201- ):
189+ if isinstance (token , FieldValue ):
190+ field_name = token .field .source_name
191+ if values_map := SOURCE_MAPPING_TO_FIELD_VALUE_MAP .get (source_mapping .source_id , {}).get (field_name ):
192+ values_to_update = []
193+ for token_value in token .values :
194+ mapped_value : str = values_map .get (token_value , token_value )
202195 values_to_update .append (
203- SOURCE_MAPPING_TO_FIELD_VALUE_MAP [source_mapping .source_id ][token .field .source_name ][
204- token_value
205- ]
196+ StrValue (value = mapped_value , split_value = mapped_value .split ()) if mapped_value else token_value
206197 )
207- else :
208- values_to_update .append (token_value )
209- if values_to_update != token_values :
210198 token .value = values_to_update
211-
212199 return super ().apply_token (token = token , source_mapping = source_mapping )
213200
214201 @staticmethod
0 commit comments