@@ -255,6 +255,14 @@ def find_entity_property_pairs(data, result=None, keys_path=None):
255255
256256
257257def _get_agg_type_mapping () -> dict :
258+ """
259+ This function extracts a mapping dictionary like this:
260+ {
261+ "0": "Sum",
262+ "1": "Average",
263+ "2": "Distinct count",
264+ }
265+ """
258266
259267 schema_url = "https://developer.microsoft.com/json-schemas/fabric/item/report/definition/semanticQuery/1.2.0/schema.json"
260268 response = requests .get (schema_url )
@@ -284,25 +292,19 @@ def _get_expression(expr_json, agg_type_map):
284292 .get ("Column" , {})
285293 .get ("Expression" , {})
286294 .get ("SourceRef" , {})
287- .get ("Entity" , "Entity not found " )
295+ .get ("Entity" , "Unknown " )
288296 )
289297 column = (
290298 expr_json .get ("Aggregation" , {})
291299 .get ("Expression" , {})
292300 .get ("Column" , {})
293- .get ("Property" , "Column not found " )
301+ .get ("Property" , "Unknown " )
294302 )
295303 function_id = expr_json .get ("Aggregation" , {}).get ("Function" , "-1" )
296304 function = agg_type_map .get (function_id )
297305 expr = f"{ function } ('{ entity } '[{ column } ])"
298306 elif expr_type == "Measure" :
299- entity = (
300- expr_json .get ("Measure" , {})
301- .get ("Expression" , {})
302- .get ("SourceRef" , {})
303- .get ("Entity" , "Entity not found" )
304- )
305- measure = expr_json .get ("Measure" , {}).get ("Property" , "Measure not found" )
307+ measure = expr_json .get ("Measure" , {}).get ("Property" , "Unknown" )
306308 expr = f"[{ measure } ]"
307309 else :
308310 expr = "Unknown"
0 commit comments