Skip to content

Commit 5ba5c00

Browse files
author
Roman Hartig
committed
XSH-733: Explain ExecutionResponse parsing TODOs
* row totals have some limitations for now
1 parent 20e8895 commit 5ba5c00

2 files changed

Lines changed: 37 additions & 2 deletions

File tree

gooddata-pandas/gooddata_pandas/result_convertor.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def accumulate_grand_totals(
8484
dim_idx_dict = {dim["localIdentifier"]: idx for idx, dim in enumerate(response.dimensions)}
8585

8686
for grand_total in grand_totals:
87-
# TODO not sure why totalDimensions is an array
87+
# 2-dim results have always 1-dim grand totals (3-dim results have 2-dim gt but DataFrame stores 2D only)
8888
dims = grand_total["totalDimensions"]
8989
assert len(dims) == 1
9090
dim_idx = dim_idx_dict[dims[0]]
@@ -101,7 +101,8 @@ def accumulate_grand_totals(
101101
# grand totals not initialized yet; initialize both data and headers by making
102102
# a shallow copy from the results
103103
self.grand_totals[opposite_dim] = grand_total["data"][:]
104-
# TODO: wtf is the deal with this? why can there be multiple elements in the headerGroups list?
104+
# TODO: row total measure headers are currently not supported (only aggregation info w/o measure label)
105+
# measure header defs are under ["headerGroups"][>0]
105106
self.grand_totals_headers[opposite_dim] = grand_total["dimensionHeaders"][0]["headerGroups"][0][
106107
"headers"
107108
][:]

gooddata-pandas/tests/dataframe/test_dataframe_for_exec_def.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,40 @@ def test_dataframe_for_exec_def_totals4(gdf: DataFrameFactory):
222222
_run_and_validate_results(gdf=gdf, exec_def=exec_def, expected=(96, 19))
223223

224224

225+
# TODO - not implemented yet
226+
# def test_dataframe_for_exec_def_totals5(gdf: DataFrameFactory):
227+
# """
228+
# Execution with multiple measures row totals; the columns have labels of each measure.
229+
# """
230+
# exec_def = ExecutionDefinition(
231+
# attributes=[
232+
# Attribute(local_id="a_region", label="region"),
233+
# Attribute(local_id="a_cat", label="products.category"),
234+
# ],
235+
# metrics=[
236+
# SimpleMetric(local_id="m_price", item=ObjId(id="price", type="fact")),
237+
# SimpleMetric(local_id="m_quantity", item=ObjId(id="quantity", type="fact")),
238+
# ],
239+
# filters=[],
240+
# dimensions=[["a_region"], ["a_cat", "measureGroup"]],
241+
# totals=[
242+
# TotalDefinition(
243+
# local_id="grand_total1",
244+
# aggregation="sum",
245+
# total_dims=[TotalDimension(idx=1, items=["measureGroup"]), TotalDimension(idx=0, items=["a_region"])],
246+
# metric_local_id="m_price",
247+
# ),
248+
# TotalDefinition(
249+
# local_id="grand_total2",
250+
# aggregation="sum",
251+
# total_dims=[TotalDimension(idx=1, items=["measureGroup"]), TotalDimension(idx=0, items=["a_region"])],
252+
# metric_local_id="m_quantity",
253+
# ),
254+
# ],
255+
# )
256+
# _run_and_validate_results(gdf=gdf, exec_def=exec_def, expected=(?, ?))
257+
258+
225259
@gd_vcr.use_cassette(str(_fixtures_dir / "dataframe_for_exec_def_one_dim1.json"))
226260
def test_dataframe_for_exec_def_one_dim1(gdf: DataFrameFactory):
227261
exec_def = ExecutionDefinition(

0 commit comments

Comments
 (0)