Skip to content

Commit 8242f73

Browse files
authored
Merge pull request #676 from Tjev/cq-440
fix(gooddata-sdk): add additional vis table type detection condition
2 parents 269289d + 4cce0c4 commit 8242f73

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

gooddata-sdk/gooddata_sdk/table.py

+18-2
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)