Fixes #29765: refactor(databricks): migrate test-connection to declarative @check framework#29773
Fixes #29765: refactor(databricks): migrate test-connection to declarative @check framework#29773IceS2 wants to merge 1 commit into
Conversation
…ative @check framework Replace the DatabricksConnection.test_connection override with a checks() provider driven by BaseConnection.test_connection. Implements all 13 seeded steps via DatabricksChecks, adds a Databricks ErrorPack folding in the shared network pack, gates on a TCP preflight, and marks CheckAccess as ConnectionGate. Adds the 7 greenfield lineage/tag/view-definition members to the shared DatabaseStep enum.
| def _summarize(rows: Sequence[object], noun: str) -> str: | ||
| """``N <noun>s enumerated`` (``N+`` at the row cap), or ``no <noun>s enumerated``. | ||
|
|
||
| The ``+`` marks a capped sample so the figure is not read as an exact total.""" | ||
| count = len(rows) | ||
| if not count: | ||
| return f"no {noun}s enumerated" | ||
| suffix = "+" if count >= DEFAULT_SAMPLE_ROWS else "" | ||
| plural = noun if count == 1 else f"{noun}s" | ||
| return f"{count}{suffix} {plural} enumerated" |
There was a problem hiding this comment.
💡 Quality: "+" suffix in _summarize misleads: list ops are never capped
_summarize appends a + when count >= DEFAULT_SAMPLE_ROWS (100), with the comment stating the + marks a capped sample so the figure is not read as an exact total. However _summarize is only used via _list, whose backing wrapper methods (get_catalogs, get_schemas, get_tables, get_views) all return uncapped fetchall() results. The capping (fetchmany(max_rows)) only exists in run_sql, whose checks use their own summarize lambdas that ignore rows and never call _summarize. So a schema with exactly 100+ tables/views/schemas will be reported as e.g. 100+ tables enumerated, wrongly implying truncation when it is in fact the exact total. Either cap the wrapper listings to match the summary semantics, or drop the + suffix (and comment) from _summarize since these counts are always exact.
Drop the misleading '+' suffix since _list results are uncapped exact counts.:
def _summarize(rows: Sequence[object], noun: str) -> str:
"""``N <noun>s enumerated`` or ``no <noun>s enumerated``."""
count = len(rows)
if not count:
return f"no {noun}s enumerated"
plural = noun if count == 1 else f"{noun}s"
return f"{count} {plural} enumerated"
- Apply fix
Check the box to apply the fix or reply for a change | Was this helpful? React with 👍 / 👎
Code Review 👍 Approved with suggestions 0 resolved / 1 findingsMigrates Databricks connection testing to the declarative 💡 Quality: "+" suffix in _summarize misleads: list ops are never capped📄 ingestion/src/metadata/ingestion/source/database/databricks/connection.py:139-148 📄 ingestion/src/metadata/ingestion/source/database/databricks/connection.py:283-293
Drop the misleading '+' suffix since _list results are uncapped exact counts.🤖 Prompt for agentsOptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
Fixes #29765
Migrates the Databricks connector's test-connection off the legacy
test_connection_stepshelper onto the declarative@check/ChecksProvider/ErrorPackframework.What changed
databricks/connection.py: removed theDatabricksConnection.test_connectionoverride; addedDatabricksChecks(aChecksProvider) with one@checkper seeded step and achecks()method._get_clientnow registersengine.disposeon close. TheDatabricksEngineWrapperand lazy catalog scoping are preserved; every step builds its statement inside its@checkmethod, so nothing touches the network before theCheckAccessgate.CheckAccess(TCP preflight to the workspace host:443 +SELECT 1),GetDatabases(catalogs),GetSchemas,GetTables,GetViews,GetQueries,GetViewDefinitions,GetCatalogTags,GetSchemaTags,GetTableTags,GetColumnTags,GetTableLineage,GetColumnLineage.DATABRICKS_ERRORS: anErrorPackkeyed on stable databricks-sql / thrift message tokens (invalid/expired token, forbidden,PERMISSION_DENIED/INSUFFICIENT_PERMISSIONS,TABLE_OR_VIEW_NOT_FOUND,SCHEMA_NOT_FOUND, catalog "does not exist"), folding in the sharedNETWORK_ERRORSpack.checks/database.py: added the 7 greenfield members (GetViewDefinitions,GetCatalogTags,GetSchemaTags,GetTableTags,GetColumnTags,GetTableLineage,GetColumnLineage) to the sharedDatabaseStepenum. No existing shared logic was touched.databricks.json: markedCheckAccesswith"category": "ConnectionGate"so the runner short-circuits on a failed gate.tests/unit/source/database/databricks/test_connection.py(step coverage, error-pack classification, gate preflight, lazy construction); updated the topology test's wrapper assertions to check the materialized rows and dropped the obsoletetest_connection_stepswiring test.