Repository navigation
fix(ingestion): improve Unity Catalog test-connection step quality - #28647
Conversation
9e9fd8e to
f2369b1
Compare
| { | ||
| "name": "GetViews", | ||
| "description": "From a given schema, list the views belonging to that schema. If no schema is specified, we'll list the tables of a random schema.", | ||
| "description": "From a given schema, list the views belonging to that schema. If no schema is specified, we'll list the views of a random schema.", |
There was a problem hiding this comment.
💡 Quality: GetViews description still says 'random schema'
The GetViews step description in unitycatalog.json was updated (in this diff) to '...we'll list the views of a random schema.' but the resolution logic in get_schemas() actually picks the first schema returned by connection.schemas.list(...), not a random one. The same wording inaccuracy applies to the sibling GetTables/GetSchemas descriptions. Since this line was edited here, consider rewording to 'the first available schema' for accuracy. Low impact (user-facing description only).
Match the description to the actual first-schema resolution behavior.:
"description": "From a given schema, list the views belonging to that schema. If no schema is specified, we'll list the views of the first available schema.",
Was this helpful? React with 👍 / 👎
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
There was a problem hiding this comment.
Pull request overview
This PR improves the Unity Catalog ingestion connector’s test-connection flow so that it validates the configured catalog/schema correctly, fails loudly with actionable errors when catalog/schema resolution fails, and properly separates the “GetViews” step from “GetTables”. It also promotes step functions to module-level for easier unit testing and adds unit coverage for the new behavior.
Changes:
- Fix test-connection step wiring so
GetViewsuses a dedicatedget_views()implementation (instead of reusingget_tables()), andGetDatabases/GetSchemasvalidate the configured catalog/schema viaget(). - Make
GetTables/GetViewsraiseSourceConnectionExceptionwhen catalog/schema aren’t resolved to avoid silent no-ops. - Update Unity Catalog test-connection definition messaging and add new unit tests + basedpyright baseline adjustment.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| openmetadata-service/src/main/resources/json/data/testConnections/database/unitycatalog.json | Updates step error message and clarifies GetViews step description. |
| ingestion/src/metadata/ingestion/source/database/unitycatalog/connection.py | Refactors test-connection steps into module-level functions; fixes GetViews wiring; adds explicit failure on unresolved catalog/schema. |
| ingestion/tests/unit/topology/database/test_unity_catalog_connection.py | Adds unit tests for catalog/schema validation, unresolved failures, GetViews behavior, and test-connection wiring. |
| ingestion/.basedpyright/baseline.json | Removes a resolved basedpyright baseline entry related to the updated typing/wiring. |
Address Copilot review on PR #28647: get_views() only broke on finding a view, so a schema with no views forced a full paginated tables.list scan that could trip the overall test-connection timeout on large schemas. Cap the scan at VIEW_LISTING_SCAN_LIMIT (100) items and request lightweight listings (omit_columns/omit_properties). The step still validates that view listing works and exposes view types without enumerating every object. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
🟡 Playwright Results — all passed (12 flaky)✅ 4299 passed · ❌ 0 failed · 🟡 12 flaky · ⏭️ 88 skipped
🟡 12 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
Address Copilot review on PR #28647: get_views() only broke on finding a view, so a schema with no views forced a full paginated tables.list scan that could trip the overall test-connection timeout on large schemas. Cap the scan at VIEW_LISTING_SCAN_LIMIT (100) items and request lightweight listings (omit_columns/omit_properties). The step still validates that view listing works and exposes view types without enumerating every object. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
6652d80 to
dc92f49
Compare
| { | ||
| "name": "GetViews", | ||
| "description": "From a given schema, list the views belonging to that schema. If no schema is specified, we'll list the tables of a random schema.", | ||
| "description": "From a given schema, list the views belonging to that schema. If no schema is specified, we'll list the views of a random schema.", |
There was a problem hiding this comment.
💡 Quality: Step descriptions still say 'random schema' but code picks first
The GetTables (L27) and GetViews (L33) step descriptions both state "If no schema is specified, we'll list the ... of a random schema." This wording is inaccurate: the connection code (get_catalogs/get_schemas in connection.py) deterministically selects the first non-internal catalog and the first schema (not a random one), and now also validates an explicitly configured catalog/databaseSchema when provided. The previous review already flagged the GetViews description for this; the diff updated "tables" → "views" but kept the misleading "random". Suggest replacing "a random schema" with "the first available schema" (and similarly mention the configured catalog/schema), and applying the same fix to GetTables for consistency.
Replace 'random schema' with 'first available schema' in both GetTables and GetViews descriptions to match the actual selection logic.:
"description": "From a given schema, list the tables belonging to that schema. If no schema is specified, we'll list the tables of the first available schema.",
...
"description": "From a given schema, list the views belonging to that schema. If no schema is specified, we'll list the views of the first available schema.",
Was this helpful? React with 👍 / 👎
|
The Python checkstyle failed. Please run You can install the pre-commit hooks with |
- Give GetViews its own validation function that filters for VIEW and MATERIALIZED_VIEW table types instead of reusing the GetTables partial - Fail GetTables/GetViews loudly when the catalog/schema could not be resolved by previous steps, instead of silently passing - Honor the configured catalog and databaseSchema in the GetDatabases and GetSchemas steps, validating access to those exact objects - Rewrite the CheckAccess error message to be auth-agnostic and fix typos Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Address Copilot review on PR #28647: get_views() only broke on finding a view, so a schema with no views forced a full paginated tables.list scan that could trip the overall test-connection timeout on large schemas. Cap the scan at VIEW_LISTING_SCAN_LIMIT (100) items and request lightweight listings (omit_columns/omit_properties). The step still validates that view listing works and exposes view types without enumerating every object. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
dc92f49 to
871dff7
Compare
|
The Python checkstyle failed. Please run You can install the pre-commit hooks with |
The # noqa: PLR1704 on the get_tags context manager was carried over from the earlier standalone test_connection function, where 'connection' shadowed a function parameter. In the class-based structure 'connection' is a local, so PLR1704 never fires and ruff flags the directive as unused (RUF100). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Code Review 👍 Approved with suggestions 0 resolved / 2 findingsRefactors Unity Catalog connection steps to properly validate configured catalogs and schemas and introduces explicit view validation. Please update the step descriptions for GetTables and GetViews to accurately reflect that they list the first available schema rather than a random one. 💡 Quality: GetViews description still says 'random schema'📄 openmetadata-service/src/main/resources/json/data/testConnections/database/unitycatalog.json:33 📄 ingestion/src/metadata/ingestion/source/database/unitycatalog/connection.py:116-120 The Match the description to the actual first-schema resolution behavior.💡 Quality: Step descriptions still say 'random schema' but code picks first📄 openmetadata-service/src/main/resources/json/data/testConnections/database/unitycatalog.json:27 📄 openmetadata-service/src/main/resources/json/data/testConnections/database/unitycatalog.json:33 The Replace 'random schema' with 'first available schema' in both GetTables and GetViews descriptions to match the actual selection logic.🤖 Prompt for agentsOptionsDisplay: compact → Showing less information. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |



Fixes #28862
Describe your changes:
Part of an internal Unity Catalog connector reliability audit (test-connection step quality cluster).
This PR fixes four issues in the Unity Catalog test connection flow:
GetViewsnever actually validated views — it was bound to the same partial asGetTables. It now has its ownget_views()step that filterstables.list()forVIEW/MATERIALIZED_VIEWtable types.GetTables/GetViewssilently no-oped when catalog/schema were unresolved — they now raiseSourceConnectionExceptionwith an actionable message (pointing atUSE CATALOG/USE SCHEMAprivileges) so the step fails loudly instead of green-lighting a broken setup.catalog/databaseSchemawere ignored —GetDatabasesandGetSchemasnow validate access to the exact configured objects viacatalogs.get()/schemas.get()instead of picking a random catalog/schema.CheckAccesserror message assumed token auth and had typos ("validate to token", "hostport") — rewritten to be auth-agnostic.The step functions were promoted from nested closures to module-level functions, mirroring the Databricks connector pattern and making them unit-testable.
Type of change:
High-level design:
N/A — small change.
Tests:
Use cases covered
catalog/databaseSchemavalidates access to those exact objectsGetTables/GetViewsfail with a clear privilege message when catalog/schema resolution fails, instead of passing silentlyGetViewsvalidates view listing specifically (filtersVIEW/MATERIALIZED_VIEW)Unit tests
ingestion/tests/unit/topology/database/test_unity_catalog_connection.py(12 new tests; 14 total in file)test_unity_catalog*.py,test_unitycatalog*.py)Backend integration tests
Ingestion integration tests
Playwright (UI) tests
Manual testing performed
UI screen recording / screenshots:
Not applicable.
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.
For JSON Schema changes: I updated the migration scripts or explained why it is not needed — only
testConnections/database/unitycatalog.jsonstep descriptions/error messages changed; these are re-seeded on server startup, no migration needed.I have added tests (unit / integration / Playwright as applicable) and listed them above.
I have added tests around the new logic.
For connector/ingestion changes: I updated the documentation.
🤖 Generated with Claude Code
Greptile Summary
This PR fixes four correctness issues in the Unity Catalog test-connection flow:
GetViewswas wired toget_tables, configured catalog/schema were ignored in favour of random picks,GetTables/GetViewssilently passed when catalog or schema could not be resolved, and theCheckAccesserror message had typos and assumed token auth. The step functions are promoted from nested closures to module-level functions, and 12 new unit tests are added.get_catalogs/get_schemasnow callcatalogs.get()/schemas.get()when a catalog or schema is configured, validating access to the exact configured object instead of falling back to a random one.get_viewshas its own implementation that callstables.list()and filters forVIEW/MATERIALIZED_VIEWtypes, capped atVIEW_LISTING_SCAN_LIMIT(100) objects to avoid pagination timeouts on large schemas._require_resolved_catalog_and_schemaraisesSourceConnectionExceptionloudly when either value is unset, replacing the previous silent no-op.Confidence Score: 5/5
Safe to merge — all changes are additive improvements to the test-connection flow with no impact on the ingestion runtime path.
The changes are well-scoped: four module-level functions replace nested closures, each with a clear contract. No ingestion runtime logic is touched. Twelve new unit tests cover the happy path, the configured-catalog/schema fast path, and all error branches. Two known concerns (silent pass on empty catalog list, combined error message when only one value is unresolved) are already tracked in prior review threads. No new defects are introduced by this PR.
No files require special attention beyond what is already noted in prior threads on connection.py.
Important Files Changed
Sequence Diagram
%%{init: {'theme': 'neutral'}}%% sequenceDiagram participant TC as test_connection_steps participant GD as get_catalogs participant GS as get_schemas participant GT as get_tables participant GV as get_views participant SDK as WorkspaceClient TC->>GD: call(connection, table_obj, catalog?) alt catalog configured GD->>SDK: catalogs.get(catalog_name) SDK-->>GD: CatalogInfo GD->>GD: "table_obj.catalog_name = name" else no catalog configured GD->>SDK: catalogs.list() SDK-->>GD: iterator GD->>GD: pick first non-internal catalog end TC->>GS: call(connection, table_obj, schema?) alt catalog unresolved GS-->>TC: SourceConnectionException else schema configured GS->>SDK: schemas.get("catalog.schema") SDK-->>GS: SchemaInfo GS->>GS: "table_obj.schema_name = name" else no schema configured GS->>SDK: schemas.list(catalog_name) SDK-->>GS: iterator GS->>GS: pick first schema end TC->>GT: call(connection, table_obj) alt catalog or schema unresolved GT-->>TC: SourceConnectionException else both resolved GT->>SDK: "tables.list(catalog, schema, max_results=1)" SDK-->>GT: iterator GT->>GT: "table_obj.name = first table" end TC->>GV: call(connection, table_obj) alt catalog or schema unresolved GV-->>TC: SourceConnectionException else both resolved GV->>SDK: "tables.list(catalog, schema, max_results=100, omit_columns, omit_properties)" SDK-->>GV: iterator GV->>GV: scan ≤100 items, break on VIEW or limit end%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%% sequenceDiagram participant TC as test_connection_steps participant GD as get_catalogs participant GS as get_schemas participant GT as get_tables participant GV as get_views participant SDK as WorkspaceClient TC->>GD: call(connection, table_obj, catalog?) alt catalog configured GD->>SDK: catalogs.get(catalog_name) SDK-->>GD: CatalogInfo GD->>GD: "table_obj.catalog_name = name" else no catalog configured GD->>SDK: catalogs.list() SDK-->>GD: iterator GD->>GD: pick first non-internal catalog end TC->>GS: call(connection, table_obj, schema?) alt catalog unresolved GS-->>TC: SourceConnectionException else schema configured GS->>SDK: schemas.get("catalog.schema") SDK-->>GS: SchemaInfo GS->>GS: "table_obj.schema_name = name" else no schema configured GS->>SDK: schemas.list(catalog_name) SDK-->>GS: iterator GS->>GS: pick first schema end TC->>GT: call(connection, table_obj) alt catalog or schema unresolved GT-->>TC: SourceConnectionException else both resolved GT->>SDK: "tables.list(catalog, schema, max_results=1)" SDK-->>GT: iterator GT->>GT: "table_obj.name = first table" end TC->>GV: call(connection, table_obj) alt catalog or schema unresolved GV-->>TC: SourceConnectionException else both resolved GV->>SDK: "tables.list(catalog, schema, max_results=100, omit_columns, omit_properties)" SDK-->>GV: iterator GV->>GV: scan ≤100 items, break on VIEW or limit endReviews (4): Last reviewed commit: "fix(ingestion): remove unused noqa direc..." | Re-trigger Greptile