Skip to content

Fixes #36557: Keep line breaks in PowerBI Sql.Database query SQL so -- comments end at their line - #36748

Merged
stout-yeoman merged 1 commit into
open-metadata:mainfrom
zerafachris:fix/powerbi-sql-line-comments-36557
Nov 4, 2026
Merged

stout-yeoman merged 1 commit into
open-metadata:mainfrom
zerafachris:fix/powerbi-sql-line-comments-36557

Conversation

@zerafachris

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #36557

Root cause: PowerbiSource._extract_tables_from_sql replaced #(lf)/#(tab) with real newlines and tabs, then ran re.sub(r"\s+", " ", ...) on the result, which put the whole query on one line before LineageParser saw it. A -- line comment then ran to the end of the query, so every table referenced after the first comment was dropped. Ingestion still reported success.

What changed: the whitespace collapse is removed (only .strip() remains), so the SQL reaches LineageParser with its line breaks and each -- comment ends at its own line. This is the approach #36207 already took for the BigQuery Value.NativeQuery path (_parse_bigquery_query_source). It covers both callers through _parse_sql_source: dataset tables and dataflow M documents, for the Sql.Database(..., [Query=...]) and Value.NativeQuery(Sql.Database(...), ...) patterns.

Type of change:

  • Bug fix

High-level design:

N/A — small change.

Tests:

Use cases covered

  • Sql.Database inline query with a -- comment mid-SELECT (the query from the issue): both yachtReservation and V_reservationSubCategory are returned.
  • A -- comment after a CTE: the table joined after the comment is still returned.

Unit tests

  • Added test_extract_tables_from_sql_line_comment_ends_at_its_line in ingestion/tests/unit/topology/dashboard/test_powerbi.py.
  • It fails on main without the fix and passes with it.
  • test_powerbi.py + test_powerbi_bigquery_native_query.py: 65 passed. ruff check and ruff format --check are clean on both touched files.

Backend integration tests

  • Not applicable (no backend API changes).

Ingestion integration tests

  • Not applicable (unit-level parsing fix; no connector integration test exists for this path).

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

None beyond the unit tests.

UI screen recording:

Not applicable — ingestion-only fix.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.

Prepared with AI assistance (Claude Code, Anthropic), reviewed for correctness before submission.

…uery SQL so -- comments end at their line

_extract_tables_from_sql turned #(lf) into newlines and then collapsed all
whitespace onto one line before calling LineageParser. A -- comment then ran
to the end of the query, so every table after it was dropped from lineage.
The SQL now reaches LineageParser with its line breaks, as the BigQuery
native query path already does since open-metadata#36207.
@zerafachris
zerafachris requested a review from a team as a code owner October 31, 2026 13:09
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@gitar-bot

gitar-bot Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved

🟡 Medium risk · Preserving line breaks changes PowerBI SQL lineage extraction, and parser differences could still omit or misattribute table dependencies.

Removes the whitespace collapse in PowerBI _extract_tables_from_sql so SQL from Sql.Database queries keeps its line breaks, letting -- comments end at their line instead of swallowing later table references. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@zerafachris

Copy link
Copy Markdown
Contributor Author

@harshsoni2024 Ready for review and safe to test when you get a chance — thanks!

@stout-yeoman stout-yeoman added the safe to test Add this label to run secure Github workflows on PRs label Nov 4, 2026
@sonarqubecloud

sonarqubecloud Bot commented Nov 4, 2026

Copy link
Copy Markdown

@stout-yeoman
stout-yeoman enabled auto-merge (squash) November 4, 2026 20:47
@stout-yeoman
stout-yeoman merged commit 5474638 into open-metadata:main Nov 4, 2026
117 of 127 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.1 safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PowerBI lineage: -- SQL comments in Sql.Database(..., [Query=...]) swallow the rest of the query (no/partial lineage)

2 participants