Repository navigation
Fixes #36557: Keep line breaks in PowerBI Sql.Database query SQL so -- comments end at their line - #36748
Conversation
…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.
❌ PR checklist incompleteThis 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 |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
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 VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
@harshsoni2024 Ready for review and |
|



Describe your changes:
Fixes #36557
Root cause:
PowerbiSource._extract_tables_from_sqlreplaced#(lf)/#(tab)with real newlines and tabs, then ranre.sub(r"\s+", " ", ...)on the result, which put the whole query on one line beforeLineageParsersaw 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 reachesLineageParserwith its line breaks and each--comment ends at its own line. This is the approach #36207 already took for the BigQueryValue.NativeQuerypath (_parse_bigquery_query_source). It covers both callers through_parse_sql_source: dataset tables and dataflow M documents, for theSql.Database(..., [Query=...])andValue.NativeQuery(Sql.Database(...), ...)patterns.Type of change:
High-level design:
N/A — small change.
Tests:
Use cases covered
Sql.Databaseinline query with a--comment mid-SELECT (the query from the issue): bothyachtReservationandV_reservationSubCategoryare returned.--comment after a CTE: the table joined after the comment is still returned.Unit tests
test_extract_tables_from_sql_line_comment_ends_at_its_lineiningestion/tests/unit/topology/dashboard/test_powerbi.py.mainwithout the fix and passes with it.test_powerbi.py+test_powerbi_bigquery_native_query.py: 65 passed.ruff checkandruff format --checkare clean on both touched files.Backend integration tests
Ingestion integration tests
Playwright (UI) tests
Manual testing performed
None beyond the unit tests.
UI screen recording:
Not applicable — ingestion-only fix.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.Prepared with AI assistance (Claude Code, Anthropic), reviewed for correctness before submission.