Sub topic 16
Discovering features and tracing lineage
This chapter assumes you can create a feature table and write to it, as in the earlier chapters. It also assumes you know Unity Catalog's catalog.schema.table naming and have basic SQL skills. Here you will learn how to find existing features before you build new ones, document them, and trace where their data comes from and where it is used.
Why discovery matters
Teams often compute the same feature several times under different names. One team builds order_count_90d, and another builds orders_last_quarter from the same source with a slightly different window. The two versions disagree, and a model built on one cannot reuse the other's pipeline.
A feature table in Unity Catalog is a Delta table with a primary key. Every governance tool that works on tables therefore works on feature tables too:
- Search and browsing in Catalog Explorer.
- Comments and tags.
- Permissions.
- Lineage.
You don't need a separate registry.
Finding feature tables
You can find feature tables in three ways:
- Catalog Explorer. Browse catalog, schema, then table. You can also use the global search bar to look for table or column names. The table page shows the columns, the primary key, the comment, the tags, and the sample data if you have access.
- The Features UI. The workspace has a Features page that lists feature tables you can access. Use it when you want to see only feature tables and not every table in the metastore.
- SQL.
information_schemais the most scriptable option. It lets you search across a whole catalog.
-- Find columns whose names mention "order" in the main catalog's ml schema
SELECT table_schema, table_name, column_name, data_type, comment
FROM main.information_schema.columns
WHERE table_schema = 'ml'
AND lower(column_name) LIKE '%order%'
ORDER BY table_name, ordinal_position;You only see objects you have privileges on. Unity Catalog hides the rest, so an empty result can mean "no such feature" or "no access".
Making features discoverable
Search is only as good as the metadata. Three kinds of metadata help most.
- Table comments say what the table is, what entity it describes, and how fresh it is.
- Column comments define each feature, including its unit, window, and null behavior.
- Tags are key-value pairs you can filter on, such as owner team or domain.
COMMENT ON TABLE main.ml.user_features IS
'Per-user order features over the last 90 days. Refreshed daily at 02:00 UTC.';
ALTER TABLE main.ml.user_features
ALTER COLUMN order_count_90d COMMENT 'Number of orders in the last 90 days. 0 if none.';
ALTER TABLE main.ml.user_features
SET TAGS ('domain' = 'sales', 'owner_team' = 'growth-ml', 'pii' = 'false');Column comments matter more than they look. The name avg_order_amount_90d doesn't say whether the amount includes tax or refunds. A one-line comment prevents a wrong guess.
You can also set the description when you create the table. The description argument to create_table from earlier chapters becomes the table comment.
Access control and what others can see
Discovery respects permissions. To use a feature table, a user needs:
USE CATALOGon the catalog.USE SCHEMAon the schema.SELECTon the table.
To write to it, they also need MODIFY.
GRANT USE CATALOG ON CATALOG main TO `data-scientists`;
GRANT USE SCHEMA ON SCHEMA main.ml TO `data-scientists`;
GRANT SELECT ON TABLE main.ml.user_features TO `data-scientists`;A model that uses features also needs the caller to be able to read them. When you score with a logged model, lookups run with the caller's access to the feature tables. If a scoring job fails with a permissions error, check SELECT on each feature table the model references.
What lineage is
Lineage is a record of how data flows. Unity Catalog captures it automatically from queries and jobs that run on Unity Catalog-enabled compute. You don't instrument anything. It works at two levels:
- Table lineage shows that table B was built from table A.
- Column lineage shows that column
order_count_90din B was derived from specific columns in A.
For features, lineage answers questions in two directions.
- Upstream: which raw tables and columns produce this feature? This matters when a source table changes its schema or has a data quality incident.
- Downstream: which models, notebooks, and jobs consume this feature? This matters before you change or drop a feature.
Lineage for models
When you log a model with fe.log_model and a training_set, the model is stored with metadata about which feature tables and features it uses. Unity Catalog shows this on the model page and on the feature table page, so you can go from a table to the models that depend on it.
This is the main lineage advantage of logging a model with its feature lookups. If you logged a plain scikit-learn model after calling training_set.load_df() and toPandas(), the model would carry no link to its features. The lineage you get depends on how you logged it.
Viewing lineage in the UI
Open the table in Catalog Explorer and select the Lineage tab. You see upstream and downstream tables, and you can open a graph view. Selecting a column shows column lineage. The page also lists notebooks, jobs, and queries that read or wrote the table. This is often the fastest way to find out who to contact before changing a feature.
Querying lineage with system tables
The UI is good for browsing. For audits or impact checks across many tables, query the lineage system tables. They require that system tables are enabled for your metastore and that you have access to the system.access schema.
-- Which tables and models read main.ml.user_features?
SELECT DISTINCT
target_table_full_name,
target_type,
entity_type
FROM system.access.table_lineage
WHERE source_table_full_name = 'main.ml.user_features'
AND event_time >= current_date() - INTERVAL 30 DAYS;-- Which source columns feed order_count_90d?
SELECT DISTINCT
source_table_full_name,
source_column_name
FROM system.access.column_lineage
WHERE target_table_full_name = 'main.ml.user_features'
AND target_column_name = 'order_count_90d'
AND event_time >= current_date() - INTERVAL 30 DAYS;Filtering on event_time keeps the scan small and shows current dependencies. The entity_type column says what kind of object ran the query, such as a notebook or job. That lets you list consumers by workload.
Limits and gotchas
- Lineage depends on how the work ran. Queries on compute that isn't Unity Catalog-enabled, or data copied out through files, leave gaps. A pandas step that writes a CSV and reloads it breaks the chain.
- Lineage is retained for a limited time. Check your workspace documentation for the current retention period. Don't rely on it as a permanent audit log, and export it if you need a longer record.
- Column lineage is derived, not semantic. If a feature is computed from three columns, all three show up as sources. Lineage doesn't tell you the formula, so keep the logic in the column comment or the pipeline code.
- Metadata goes stale. A comment saying "refreshed daily" is wrong once someone moves the job to weekly. Update it in the same change as the schedule.
- Dropping a table breaks dependents. Lineage shows who would be affected, but it doesn't block the drop. Check downstream before you drop or rename a feature table.
A practical checklist before building a new feature
- Search
information_schema.columnsand Catalog Explorer for the concept. - If a candidate exists, read its comments, tags, and freshness note.
- Check its upstream lineage to confirm the source and window match what you need.
- Request
SELECTaccess, or reuse the table via aFeatureLookup. - Only if nothing fits, create a new feature table. Add a table comment, column comments, and tags from the start.
Exercise
You plan to rename the column avgorderamount90d in main.ml.userfeatures. Name two ways to find out what depends on it, and explain one reason the results might be incomplete.
Show answer
Open the Lineage tab for the table in Catalog Explorer and select the column, or query system.access.columnlineage (and system.access.tablelineage) with sourcetablefullname = 'main.ml.userfeatures' and a recent eventtime filter. The results can be incomplete when a consumer ran on compute that isn't Unity Catalog-enabled, when data was exported to files and reloaded, or when the consumer ran outside the lineage retention window. Models logged without a trainingset also carry no link to their features.
Exercise
A colleague can see main.ml.user_features in Catalog Explorer but a batch scoring job running under their identity fails when it loads the model's features. Which privileges would you check?
Show answer
Check that they have USE CATALOG on main, USE SCHEMA on main.ml, and SELECT on main.ml.user_features, plus the same on every other feature table the model references. Lookups at scoring time use the caller's access to those tables.