Skip to content

Commit 4b968b5

Browse files
Gilbert09Copilot
andauthored
fix(data-modeling): Get the table from the hogql db (#42221)
Co-authored-by: Copilot <[email protected]>
1 parent 6da71e7 commit 4b968b5

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

products/data_warehouse/backend/models/modeling.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -461,12 +461,23 @@ def update_paths_from_query(
461461
)
462462
except ObjectDoesNotExist:
463463
try:
464-
parent_table = (
465-
DataWarehouseTable.objects.exclude(deleted=True)
466-
.filter(team=team, name=parent)
467-
.get()
468-
)
469-
except ObjectDoesNotExist:
464+
table = self.get_hogql_database(team).get_table(parent)
465+
if not isinstance(table, HogQLDataWarehouseTable):
466+
raise ObjectDoesNotExist()
467+
468+
if table.table_id:
469+
parent_table = (
470+
DataWarehouseTable.objects.exclude(deleted=True)
471+
.filter(team=team, id=table.table_id)
472+
.get()
473+
)
474+
else:
475+
parent_table = (
476+
DataWarehouseTable.objects.exclude(deleted=True)
477+
.filter(team=team, name=table.name)
478+
.get()
479+
)
480+
except (ObjectDoesNotExist, QueryError):
470481
raise UnknownParentError(parent, query)
471482
else:
472483
parent_id = parent_table.id.hex

0 commit comments

Comments
 (0)