File tree Expand file tree Collapse file tree 2 files changed +18
-16
lines changed
Expand file tree Collapse file tree 2 files changed +18
-16
lines changed Original file line number Diff line number Diff line change 88"""
99
1010import logging
11- import re
1211
13- from .errors import DataJointError
1412from .heading import Heading
1513from .table import Table
14+ from .utils import parse_full_table_name
1615
1716logger = logging .getLogger (__name__ .split ("." )[0 ])
1817
@@ -116,19 +115,6 @@ def delete_table_lineage(self, table_name):
116115 (self & dict (table_name = table_name )).delete_quick ()
117116
118117
119- def parse_full_table_name (full_name ):
120- """
121- Parse a full table name like `schema`.`table` into (schema, table).
122-
123- :param full_name: full table name in format `schema`.`table`
124- :return: tuple (schema, table)
125- """
126- match = re .match (r"`(\w+)`\.`(\w+)`" , full_name )
127- if not match :
128- raise DataJointError (f"Invalid table name format: { full_name } " )
129- return match .group (1 ), match .group (2 )
130-
131-
132118def compute_lineage_from_dependencies (connection , schema , table_name , attribute_name ):
133119 """
134120 Compute lineage by traversing the FK graph.
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ def get_master(full_table_name: str) -> str:
5050 :return: Supposed master full table name or empty string if not a part table name.
5151 :rtype: str
5252 """
53- match = re .match (r"(?P<master>`\w +`.`\w +)__(?P<part>\w +)`" , full_table_name )
53+ match = re .match (r"(?P<master>`[^`] +`.`[^`] +)__(?P<part>[^`] +)`" , full_table_name )
5454 return match ["master" ] + "`" if match else ""
5555
5656
@@ -149,3 +149,19 @@ def parse_sql(filepath):
149149 statement = []
150150 if statement :
151151 yield " " .join (statement )
152+
153+
154+ def parse_full_table_name (full_name ):
155+ """
156+ Parse a full table name like `schema`.`table` into (schema, table).
157+
158+ Handles special table name prefixes like ~ (hidden), # (lookup), etc.
159+
160+ :param full_name: full table name in format `schema`.`table`
161+ :return: tuple (schema, table)
162+ :raises DataJointError: if the format is invalid
163+ """
164+ match = re .match (r"`([^`]+)`\.`([^`]+)`" , full_name )
165+ if not match :
166+ raise DataJointError (f"Invalid table name format: { full_name } " )
167+ return match .group (1 ), match .group (2 )
You can’t perform that action at this time.
0 commit comments