Skip to content

Commit

Permalink
Fix ThoughtSpot directory name (#836)
Browse files Browse the repository at this point in the history
* Provide virtual hierarchy for ThoughtSpot

* Bump version
  • Loading branch information
elic-eon authored Apr 22, 2024
1 parent 902e444 commit f8c3810
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 11 deletions.
25 changes: 24 additions & 1 deletion metaphor/thought_spot/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
ThoughtSpotColumn,
ThoughtSpotDashboardType,
ThoughtSpotDataObject,
ThoughtSpotDataObjectType,
ThoughtSpotInfo,
VirtualView,
VirtualViewLogicalID,
Expand All @@ -58,6 +59,7 @@
)
from metaphor.thought_spot.utils import (
ThoughtSpot,
create_virtual_hierarchy,
from_list,
getColumnTransformation,
mapping_chart_type,
Expand Down Expand Up @@ -101,7 +103,28 @@ async def extract(self) -> Collection[ENTITY_TYPES]:
self.fetch_virtual_views()
self.fetch_dashboards()

return list(chain(self._virtual_views.values(), self._dashboards.values()))
virtual_hierarchies = [
create_virtual_hierarchy(
name="Answer", path=[ThoughtSpotDashboardType.ANSWER.name]
),
create_virtual_hierarchy(
name="Liveboard", path=[ThoughtSpotDashboardType.LIVEBOARD.name]
),
create_virtual_hierarchy(
name="Table", path=[ThoughtSpotDataObjectType.TABLE.name]
),
create_virtual_hierarchy(
name="Worksheet", path=[ThoughtSpotDataObjectType.WORKSHEET.name]
),
]

return list(
chain(
self._virtual_views.values(),
self._dashboards.values(),
virtual_hierarchies,
),
)

def fetch_virtual_views(self):
connections = from_list(ThoughtSpot.fetch_connections(self._client))
Expand Down
13 changes: 13 additions & 0 deletions metaphor/thought_spot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
from metaphor.models.metadata_change_event import (
ChartType,
DataPlatform,
Hierarchy,
HierarchyInfo,
HierarchyLogicalID,
HierarchyType,
ThoughtSpotDataObjectType,
)
from metaphor.thought_spot.config import ThoughtSpotRunConfig
Expand Down Expand Up @@ -273,3 +277,12 @@ def getColumnTransformation(target_column: Column) -> Optional[str]:
if target_column.expression is None or target_column.expression.token is None:
return None
return str(target_column.expression.token)


def create_virtual_hierarchy(name: str, path: List[str]) -> Hierarchy:
return Hierarchy(
logical_id=HierarchyLogicalID(path=path),
hierarchy_info=HierarchyInfo(
name=name, type=HierarchyType.THOUGHT_SPOT_VIRTUAL_HIERARCHY
),
)
16 changes: 8 additions & 8 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "metaphor-connectors"
version = "0.13.172"
version = "0.13.173"
license = "Apache-2.0"
description = "A collection of Python-based 'connectors' that extract metadata from various sources to ingest into the Metaphor app."
authors = ["Metaphor <[email protected]>"]
Expand Down Expand Up @@ -41,7 +41,7 @@ llama-index-readers-confluence = { version = "^0.1.4", optional = true }
llama-index-readers-notion = { version = "^0.1.6", optional = true }
looker-sdk = { version = "^23.6.0", optional = true }
lxml = { version = "~=5.0.0", optional = true }
metaphor-models = "0.33.1"
metaphor-models = "0.33.3"
more-itertools = { version = "^10.1.0", optional = true }
msal = { version = "^1.28.0", optional = true }
msgraph-beta-sdk = { version = "1.2.0", optional = true }
Expand Down
44 changes: 44 additions & 0 deletions tests/thought_spot/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -351,5 +351,49 @@
}
]
}
},
{
"logicalId": {
"path": [
"ANSWER"
]
},
"hierarchyInfo": {
"name": "Answer",
"type": "THOUGHT_SPOT_VIRTUAL_HIERARCHY"
}
},
{
"logicalId": {
"path": [
"LIVEBOARD"
]
},
"hierarchyInfo": {
"name": "Liveboard",
"type": "THOUGHT_SPOT_VIRTUAL_HIERARCHY"
}
},
{
"logicalId": {
"path": [
"TABLE"
]
},
"hierarchyInfo": {
"name": "Table",
"type": "THOUGHT_SPOT_VIRTUAL_HIERARCHY"
}
},
{
"logicalId": {
"path": [
"WORKSHEET"
]
},
"hierarchyInfo": {
"name": "Worksheet",
"type": "THOUGHT_SPOT_VIRTUAL_HIERARCHY"
}
}
]

0 comments on commit f8c3810

Please sign in to comment.