feat(powerbi): walk IfExpression branches and expand NativeQuery platform support#16757
Open
feat(powerbi): walk IfExpression branches and expand NativeQuery platform support#16757
Conversation
…form support - Add IfExpression handler to _walk() in resolver.py so conditional data sources (e.g. dev/prod switching) produce lineage from both branches; uses seen.copy() for the false branch matching the ListExpression pattern - Expand NativeQueryLineage.SUPPORTED_NATIVE_QUERY_DATA_PLATFORM to include Sql.Database (MSSql) and PostgreSQL.Database, enabling Value.NativeQuery inline-SQL lineage extraction for those platforms
Contributor
|
Linear: ING-2052 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Connector Tests ResultsAll connector tests passed for commit To skip connector tests, add the Autogenerated by the connector-tests CI pipeline. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📋 Summary
Two targeted fixes to the PowerBI M-Query lineage layer that unblock previously-silent lineage extractions:
IfExpressionsupport — the M-Query resolver now walks both branches ofif/then/elseexpressions, so conditional data sources (e.g. dev/prod environment switching) emit lineage from both environments instead of silently producing nothing.NativeQueryplatform expansion —Value.NativeQuerywrappingSql.Database(MSSql) orPostgreSQL.Databasenow proceeds to SQL parsing instead of bailing out with "unsupported platform", enabling table-level lineage extraction from inline SQL strings on those platforms.🎯 Motivation
After replacing the Lark parser with the Microsoft
powerquery-parserbridge (#16685), the resolver became accurate — but the pattern handler layer had two gaps that silently dropped lineage for common real-world patterns:if/then/elseproduced zero lineage because_walk()had no handler forIfExpressionnodes.Value.NativeQuery— inline SQL wrapped inValue.NativeQuery(Sql.Database(...), "SELECT ...", null)silently bailed out becauseSql.DatabaseandPostgreSQL.Databasewere not in theNativeQueryLineageplatform map.🔧 Changes Overview
Change 1 —
IfExpressionsupport in the resolver (resolver.py)Before: Any M-Query with a conditional data source hit the unhandled fallthrough and logged a debug message. Zero lineage emitted.
After: Both branches are walked and lineage is captured from both environments.
DataHub captures lineage from both branches rather than guessing which is active — consistent with how
ListExpression(used byTable.Combine) is handled.The implementation uses
seen.copy()for the false branch, matching theListExpressionpattern, so sibling paths don't incorrectly trigger circular-reference detection.Change 2 —
NativeQueryplatform expansion (pattern_handler.py)Before:
Value.NativeQueryonly recognized Snowflake, Redshift, and DatabricksMultiCloud as valid inner platforms. WrappingSql.Database(...)orPostgreSQL.Database(...)silently returned empty lineage.After:
Sql.Database(MSSql) andPostgreSQL.Databaseare now recognized, so SQL parsing proceeds and table-level lineage is extracted from the raw query string.🏗️ Architecture/Design Notes
IfExpressionfollows the same open/closed pattern as the other_walk()node handlers — early-return per kind, withseen.copy()for independent execution paths.NativeQueryLineagealready had theis_native_parsing_supported()guard andcurrent_data_platformfield; only the platform map needed extending.Sql.Databases(plural / three-level navigation) is handled in a separate PR (feat(ingest/powerbi): support 'Sql.Databases' M-Query data access function #16616) and intentionally excluded here.🧪 Testing
test_if_expression_walks_both_branches— integration test using a real M-Query withif/then/else; asserts both branch URNs are present in lineage output.test_native_query_mssql_and_postgres_supported— assertsSql.DatabaseandPostgreSQL.Databaseare recognized; asserts unknown platforms (e.g.Excel.Workbook) are not.📊 Impact Assessment
m_query/resolver.py,m_query/pattern_handler.pyIfExpressionnodes and the two new platform map entries.🔗 References
Sql.Databasesplural handler, in review)