Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ The caller needs `Workspace.Read.All` or `Workspace.ReadWrite.All`.

`notebook_execution.enabled` (off by default, requires `include_notebooks: true`) also models each notebook as a **pipeline**: one DataFlow per notebook (subtype "Fabric Spark Pipeline"), and under it one Spark-job DataJob (subtype "Fabric Spark Job") **per table the notebook writes**. Each job carries that output table's own upstreams, so lineage renders as `input → [job] → output` — precise table-to-table edges with the notebook transformation attributed, not one job with a cross-product of every table the notebook ever read and wrote. When one output table is itself an input to another output table's job in the same notebook, the two jobs are chained **job → job**. The lineage lives on the jobs, not the notebook dataset, so the notebook's code and its lineage (process) stay cleanly separated. It emits two things from the notebook's run history over `notebook_execution.history_days` (default 7): table-level **lineage** on the per-output jobs, and a **run history** of `DataProcessInstance`s on those jobs.

**Lineage.** Fabric exposes no API that lists the tables a notebook reads or writes, and the source text hides them when paths are built at run time (e.g. `spark.read.format("delta").load(f"{source}{table}")` or `DeltaTable.forPath(spark, target)`). So the connector reads the **resolved Spark physical plans** of each run instead: for every run in the window it fetches the run's SQL executions from the Spark monitoring API (`livySessions` + the Spark History Server SQL API) and extracts the `abfss://` OneLake table paths actually read and written. Attribution is **order-aware within a run**: a notebook usually reads a table in one Spark execution and writes a derived table in a later execution whose plan references a cached relation rather than the source path, so each written table is credited with the tables read earlier in the same run (the read set resets after each write). This keeps independent, sequential pipelines precise instead of collapsing a run into a cross-product, and recovers read-then-write edges that span executions. Those paths map directly to the GUID-based dataset URNs the connector emits. Set `notebook_execution.reconcile_code: true` (off by default; requires `notebook_execution.enabled`) to narrow that plan lineage with the notebook source when it is Python: each write is kept only with the tables its dataframe actually uses, and a write that exists only in a commented-out cell is dropped. The plans still supply the resolved OneLake path, so a table loaded from a run-time path stays attached to the name in the code. With the flag off, plan lineage is emitted unchanged. Because a notebook may apply only specific cells on a given run, lineage is **accumulated across all of the notebook's runs** in the window, giving a complete picture over time. Only edges to tables ingested in the same run are kept; GUID-built URNs that do not match an ingested table, and internal Spark scratch paths (shuffle, lakehouse-warmup), are dropped.
**Lineage.** Fabric exposes no API that lists the tables a notebook reads or writes, and the source text hides them when paths are built at run time (e.g. `spark.read.format("delta").load(f"{source}{table}")` or `DeltaTable.forPath(spark, target)`). So the connector reads the **resolved Spark physical plans** of each run instead: for every run in the window it fetches the run's SQL executions from the Spark monitoring API (`livySessions` + the Spark History Server SQL API) and extracts the `abfss://` OneLake table paths actually read and written. Attribution is **order-aware within a run**: a notebook usually reads a table in one Spark execution and writes a derived table in a later execution whose plan references a cached relation rather than the source path, so each written table is credited with the tables read earlier in the same run (the read set resets after each write). This keeps independent, sequential pipelines precise instead of collapsing a run into a cross-product, and recovers read-then-write edges that span executions. Those paths map directly to the GUID-based dataset URNs the connector emits. Set `notebook_execution.reconcile_code: true` (off by default; requires `notebook_execution.enabled`) to narrow that plan lineage with the notebook source when it is Python: each write is kept only with the tables its dataframe actually uses, and a write that exists only in a commented-out cell is dropped. The same pass reads column renames — `col(src).alias(dst)`, a `{source: target}` mapping dict, `alias.*` after a join, and `df["column"]` — and emits them as column-level lineage on that write's job. Column names are matched without regard to case, which is Spark's default, and the dataframe's own spelling is kept (`select("name")` still emits `NAME`). Set `notebook_execution.case_sensitive_columns: true` when the Spark session has `spark.sql.caseSensitive` enabled. The plans still supply the resolved OneLake path, so a table loaded from a run-time path stays attached to the name in the code. With the flag off, plan lineage is emitted unchanged. Because a notebook may apply only specific cells on a given run, lineage is **accumulated across all of the notebook's runs** in the window, giving a complete picture over time. Only edges to tables ingested in the same run are kept; GUID-built URNs that do not match an ingested table, and internal Spark scratch paths (shuffle, lakehouse-warmup), are dropped.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The spelling-preservation statement is not true for convert_urns_to_lowercase: true: the emitter lowercases both field paths before publishing fine-grained lineage. Qualify this statement with the configured URN normalization so users do not expect NAME in the emitted lineage when lowercasing is enabled.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At metadata-ingestion/docs/sources/fabric-onelake/fabric-onelake_post.md, line 380:

<comment>The spelling-preservation statement is not true for `convert_urns_to_lowercase: true`: the emitter lowercases both field paths before publishing fine-grained lineage. Qualify this statement with the configured URN normalization so users do not expect `NAME` in the emitted lineage when lowercasing is enabled.</comment>

<file context>
@@ -377,7 +377,7 @@ The caller needs `Workspace.Read.All` or `Workspace.ReadWrite.All`.
 `notebook_execution.enabled` (off by default, requires `include_notebooks: true`) also models each notebook as a **pipeline**: one DataFlow per notebook (subtype "Fabric Spark Pipeline"), and under it one Spark-job DataJob (subtype "Fabric Spark Job") **per table the notebook writes**. Each job carries that output table's own upstreams, so lineage renders as `input → [job] → output` — precise table-to-table edges with the notebook transformation attributed, not one job with a cross-product of every table the notebook ever read and wrote. When one output table is itself an input to another output table's job in the same notebook, the two jobs are chained **job → job**. The lineage lives on the jobs, not the notebook dataset, so the notebook's code and its lineage (process) stay cleanly separated. It emits two things from the notebook's run history over `notebook_execution.history_days` (default 7): table-level **lineage** on the per-output jobs, and a **run history** of `DataProcessInstance`s on those jobs.
 
-**Lineage.** Fabric exposes no API that lists the tables a notebook reads or writes, and the source text hides them when paths are built at run time (e.g. `spark.read.format("delta").load(f"{source}{table}")` or `DeltaTable.forPath(spark, target)`). So the connector reads the **resolved Spark physical plans** of each run instead: for every run in the window it fetches the run's SQL executions from the Spark monitoring API (`livySessions` + the Spark History Server SQL API) and extracts the `abfss://` OneLake table paths actually read and written. Attribution is **order-aware within a run**: a notebook usually reads a table in one Spark execution and writes a derived table in a later execution whose plan references a cached relation rather than the source path, so each written table is credited with the tables read earlier in the same run (the read set resets after each write). This keeps independent, sequential pipelines precise instead of collapsing a run into a cross-product, and recovers read-then-write edges that span executions. Those paths map directly to the GUID-based dataset URNs the connector emits. Set `notebook_execution.reconcile_code: true` (off by default; requires `notebook_execution.enabled`) to narrow that plan lineage with the notebook source when it is Python: each write is kept only with the tables its dataframe actually uses, and a write that exists only in a commented-out cell is dropped. The plans still supply the resolved OneLake path, so a table loaded from a run-time path stays attached to the name in the code. With the flag off, plan lineage is emitted unchanged. Because a notebook may apply only specific cells on a given run, lineage is **accumulated across all of the notebook's runs** in the window, giving a complete picture over time. Only edges to tables ingested in the same run are kept; GUID-built URNs that do not match an ingested table, and internal Spark scratch paths (shuffle, lakehouse-warmup), are dropped.
+**Lineage.** Fabric exposes no API that lists the tables a notebook reads or writes, and the source text hides them when paths are built at run time (e.g. `spark.read.format("delta").load(f"{source}{table}")` or `DeltaTable.forPath(spark, target)`). So the connector reads the **resolved Spark physical plans** of each run instead: for every run in the window it fetches the run's SQL executions from the Spark monitoring API (`livySessions` + the Spark History Server SQL API) and extracts the `abfss://` OneLake table paths actually read and written. Attribution is **order-aware within a run**: a notebook usually reads a table in one Spark execution and writes a derived table in a later execution whose plan references a cached relation rather than the source path, so each written table is credited with the tables read earlier in the same run (the read set resets after each write). This keeps independent, sequential pipelines precise instead of collapsing a run into a cross-product, and recovers read-then-write edges that span executions. Those paths map directly to the GUID-based dataset URNs the connector emits. Set `notebook_execution.reconcile_code: true` (off by default; requires `notebook_execution.enabled`) to narrow that plan lineage with the notebook source when it is Python: each write is kept only with the tables its dataframe actually uses, and a write that exists only in a commented-out cell is dropped. The same pass reads column renames — `col(src).alias(dst)`, a `{source: target}` mapping dict, `alias.*` after a join, and `df["column"]` — and emits them as column-level lineage on that write's job. Column names are matched without regard to case, which is Spark's default, and the dataframe's own spelling is kept (`select("name")` still emits `NAME`). Set `notebook_execution.case_sensitive_columns: true` when the Spark session has `spark.sql.caseSensitive` enabled. The plans still supply the resolved OneLake path, so a table loaded from a run-time path stays attached to the name in the code. With the flag off, plan lineage is emitted unchanged. Because a notebook may apply only specific cells on a given run, lineage is **accumulated across all of the notebook's runs** in the window, giving a complete picture over time. Only edges to tables ingested in the same run are kept; GUID-built URNs that do not match an ingested table, and internal Spark scratch paths (shuffle, lakehouse-warmup), are dropped.
 
 **Run history.** A Fabric run executes the whole notebook (the Job Scheduler reports one status per run, not per table), so for each run in the window the connector emits a `DataProcessInstance` on each of the notebook's per-output jobs — the whole-notebook run is recorded against every job it contains, falling back to the DataFlow only when a run resolved no per-table lineage — read from the Job Scheduler `GET /workspaces/{id}/items/{itemId}/jobs/instances` API. Each instance records start/end time and the run result (success / failure / skipped).
</file context>
Suggested change
**Lineage.** Fabric exposes no API that lists the tables a notebook reads or writes, and the source text hides them when paths are built at run time (e.g. `spark.read.format("delta").load(f"{source}{table}")` or `DeltaTable.forPath(spark, target)`). So the connector reads the **resolved Spark physical plans** of each run instead: for every run in the window it fetches the run's SQL executions from the Spark monitoring API (`livySessions` + the Spark History Server SQL API) and extracts the `abfss://` OneLake table paths actually read and written. Attribution is **order-aware within a run**: a notebook usually reads a table in one Spark execution and writes a derived table in a later execution whose plan references a cached relation rather than the source path, so each written table is credited with the tables read earlier in the same run (the read set resets after each write). This keeps independent, sequential pipelines precise instead of collapsing a run into a cross-product, and recovers read-then-write edges that span executions. Those paths map directly to the GUID-based dataset URNs the connector emits. Set `notebook_execution.reconcile_code: true` (off by default; requires `notebook_execution.enabled`) to narrow that plan lineage with the notebook source when it is Python: each write is kept only with the tables its dataframe actually uses, and a write that exists only in a commented-out cell is dropped. The same pass reads column renames — `col(src).alias(dst)`, a `{source: target}` mapping dict, `alias.*` after a join, and `df["column"]` — and emits them as column-level lineage on that write's job. Column names are matched without regard to case, which is Spark's default, and the dataframe's own spelling is kept (`select("name")` still emits `NAME`). Set `notebook_execution.case_sensitive_columns: true` when the Spark session has `spark.sql.caseSensitive` enabled. The plans still supply the resolved OneLake path, so a table loaded from a run-time path stays attached to the name in the code. With the flag off, plan lineage is emitted unchanged. Because a notebook may apply only specific cells on a given run, lineage is **accumulated across all of the notebook's runs** in the window, giving a complete picture over time. Only edges to tables ingested in the same run are kept; GUID-built URNs that do not match an ingested table, and internal Spark scratch paths (shuffle, lakehouse-warmup), are dropped.
**Lineage.** Fabric exposes no API that lists the tables a notebook reads or writes, and the source text hides them when paths are built at run time (e.g. `spark.read.format("delta").load(f"{source}{table}")` or `DeltaTable.forPath(spark, target)`). So the connector reads the **resolved Spark physical plans** of each run instead: for every run in the window it fetches the run's SQL executions from the Spark monitoring API (`livySessions` + the Spark History Server SQL API) and extracts the `abfss://` OneLake table paths actually read and written. Attribution is **order-aware within a run**: a notebook usually reads a table in one Spark execution and writes a derived table in a later execution whose plan references a cached relation rather than the source path, so each written table is credited with the tables read earlier in the same run (the read set resets after each write). This keeps independent, sequential pipelines precise instead of collapsing a run into a cross-product, and recovers read-then-write edges that span executions. Those paths map directly to the GUID-based dataset URNs the connector emits. Set `notebook_execution.reconcile_code: true` (off by default; requires `notebook_execution.enabled`) to narrow that plan lineage with the notebook source when it is Python: each write is kept only with the tables its dataframe actually uses, and a write that exists only in a commented-out cell is dropped. The same pass reads column renames — `col(src).alias(dst)`, a `{source: target}` mapping dict, `alias.*` after a join, and `df["column"]` — and emits them as column-level lineage on that write's job. Column matching ignores case by default, and the dataframe's spelling is preserved before the connector applies its configured URN normalization (`select("name")` resolves to `NAME`; with `convert_urns_to_lowercase: true`, the emitted field path is lowercased). Set `notebook_execution.case_sensitive_columns: true` when the Spark session has `spark.sql.caseSensitive` enabled. The plans still supply the resolved OneLake path, so a table loaded from a run-time path stays attached to the name in the code. With the flag off, plan lineage is emitted unchanged. Because a notebook may apply only specific cells on a given run, lineage is **accumulated across all of the notebook's runs** in the window, giving a complete picture over time. Only edges to tables ingested in the same run are kept; GUID-built URNs that do not match an ingested table, and internal Spark scratch paths (shuffle, lakehouse-warmup), are dropped.


**Run history.** A Fabric run executes the whole notebook (the Job Scheduler reports one status per run, not per table), so for each run in the window the connector emits a `DataProcessInstance` on each of the notebook's per-output jobs — the whole-notebook run is recorded against every job it contains, falling back to the DataFlow only when a run resolved no per-table lineage — read from the Job Scheduler `GET /workspaces/{id}/items/{itemId}/jobs/instances` API. Each instance records start/end time and the run result (success / failure / skipped).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ source:
# notebook_execution:
# enabled: true
# reconcile_code: false
# case_sensitive_columns: false
# history_days: 7
# notebook_pattern:
# allow:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,23 @@ class NotebookExecutionConfig(ConfigModel):
description=(
"Narrow Spark-plan lineage using the notebook source. Each write "
"keeps only the tables its dataframe actually uses, and a write that "
"exists only in a commented-out cell is dropped. The plans still "
"supply the resolved OneLake path. Off by default, so plan lineage "
"is emitted unchanged. Requires `enabled=True`."
"exists only in a commented-out cell is dropped. Column renames in "
"that dataframe (`col(src).alias(dst)`, a `{source: target}` mapping, "
'`alias.*`, and `df["column"]`) are emitted as column-level lineage '
"on the job. The plans still supply the resolved OneLake path. Off "
"by default, so plan lineage is emitted unchanged. Requires "
"`enabled=True`."
),
)
case_sensitive_columns: bool = Field(
default=False,
description=(
"Resolve notebook column names the way a case-sensitive Spark "
'session does. Off by default, so `select("name")` finds a column '
'stored as `NAME` and keeps that spelling, and `drop("name")` '
"removes it. Set true only when the Spark session has "
"`spark.sql.caseSensitive` enabled and `Name` and `NAME` are "
"different columns. Used when `reconcile_code=True`."
),
)

Expand Down
Loading