@@ -437,11 +437,13 @@ class DataFrameMetadata:
437437 | AVG | 150
438438 SUM | | 450
439439
440+ column_totals_indexes: Similar to row_totals_indexes but for column headers.
440441 execution_response: An instance of BareExecutionResponse representing the
441442 execution response.
442443 """
443444
444445 row_totals_indexes : list [list [int ]]
446+ column_totals_indexes : list [list [int ]]
445447 execution_response : BareExecutionResponse
446448 primary_labels_from_index : dict [int , dict [str , str ]]
447449 primary_labels_from_columns : dict [int , dict [str , str ]]
@@ -460,17 +462,25 @@ def from_data(
460462 A tuple containing data headers. execution_response (BareExecutionResponse): An ExecutionResponse object.
461463
462464 Returns: DataFrameMetadata: An initialized DataFrameMetadata object."""
463- row_totals_indexes = [
464- [idx for idx , hdr in enumerate (dim ) if hdr is not None and hdr .get ("totalHeader" ) is not None ]
465- for dim in headers [0 ]
466- ]
465+ row_totals_indexes = cls ._get_totals_indexes (headers [0 ])
466+ column_totals_indexes = cls ._get_totals_indexes (headers [1 ])
467467 return cls (
468468 row_totals_indexes = row_totals_indexes ,
469+ column_totals_indexes = column_totals_indexes ,
469470 execution_response = execution_response ,
470471 primary_labels_from_index = primary_labels_from_index ,
471472 primary_labels_from_columns = primary_labels_from_columns ,
472473 )
473474
475+ @staticmethod
476+ def _get_totals_indexes (headers : Optional [Any ]) -> list [list [int ]]:
477+ if headers is None :
478+ return []
479+ return [
480+ [idx for idx , hdr in enumerate (dim ) if hdr is not None and hdr .get ("totalHeader" ) is not None ]
481+ for dim in headers
482+ ]
483+
474484
475485def _read_complete_execution_result (
476486 execution_response : BareExecutionResponse ,
0 commit comments