Skip to content

Commit 4cce0c4

Browse files
committed
fix(gooddata-sdk): add additional vis table type detection condition
In case a table with no row attributes is received, it is incorrectly assumed to be a non-table ("non-pivot") visualization. There doesn't seem to be a nice way to figure out whether a viz is table or not. So for now we can try to parse it out from the visualizationUrl field if present. JIRA: CQ-440
1 parent 269289d commit 4cce0c4

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

gooddata-sdk/gooddata_sdk/table.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,19 @@ def get_exec_for_non_pivot(visualization: Visualization) -> ExecutionDefinition:
746746
)
747747

748748

749+
def _vis_is_table(visualization: Visualization) -> bool:
750+
attributes = visualization._vo.get("attributes")
751+
if not attributes:
752+
return False
753+
content = attributes.get("content")
754+
if not content:
755+
return False
756+
vis_url = content.get("visualizationUrl")
757+
if not vis_url:
758+
return False
759+
return vis_url.split(":")[-1] == "table"
760+
761+
749762
class TableService:
750763
"""
751764
The TableService provides a convenient way to drive computations and access the results in a tabular fashion.
@@ -760,10 +773,13 @@ def __init__(self, api_client: GoodDataApiClient) -> None:
760773
self._compute = ComputeService(api_client)
761774

762775
def for_visualization(self, workspace_id: str, visualization: Visualization) -> ExecutionTable:
763-
# Assume the received visualization is a pivot table if it contains row ("attribute") bucket
776+
# Assume the received visualization is a pivot table if:
777+
# - we can parse out "table" suffix from the attributes.contents.visualizationUrl
778+
# or
779+
# - it contains row ("attribute") bucket
764780
exec_def = (
765781
_get_exec_for_pivot(visualization)
766-
if visualization.has_bucket_of_type(BucketType.ROWS)
782+
if _vis_is_table(visualization) or visualization.has_bucket_of_type(BucketType.ROWS)
767783
else get_exec_for_non_pivot(visualization)
768784
)
769785
response = self._compute.for_exec_def(workspace_id=workspace_id, exec_def=exec_def)

0 commit comments

Comments
 (0)