Skip to content

Commit 70b0b9e

Browse files
committed
Use Heading instead of SQL to get attribute names
1 parent 8ecea36 commit 70b0b9e

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

datajoint/lineage.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -224,26 +224,21 @@ def compute_all_lineage_for_table(connection, schema, table_name):
224224
:param table_name: table name
225225
:return: dict mapping attribute_name -> lineage (or None)
226226
"""
227-
# Get all attributes for this table
228-
result = connection.query(
229-
"""
230-
SELECT column_name
231-
FROM information_schema.columns
232-
WHERE table_schema = %s AND table_name = %s
233-
ORDER BY ordinal_position
234-
""",
235-
args=(schema, table_name),
227+
# Get all attributes using Heading
228+
heading = Heading(
229+
table_info=dict(
230+
conn=connection,
231+
database=schema,
232+
table_name=table_name,
233+
context=None,
234+
)
236235
)
237-
attributes = [row[0] for row in result]
238236

239237
# Compute lineage for each attribute
240-
lineage_map = {}
241-
for attr in attributes:
242-
lineage_map[attr] = compute_lineage_from_dependencies(
243-
connection, schema, table_name, attr
244-
)
245-
246-
return lineage_map
238+
return {
239+
attr: compute_lineage_from_dependencies(connection, schema, table_name, attr)
240+
for attr in heading.names
241+
}
247242

248243

249244
def migrate_schema_lineage(connection, schema):

0 commit comments

Comments
 (0)