Skip to content

[BUGFIX] Warn instead of raise when schema absent from get_schema_names() in test_connection (#10499)#11879

Open
creazyfrog wants to merge 2 commits into
great-expectations:developfrom
creazyfrog:fix/test-connection-schema-name-not-found-10499
Open

[BUGFIX] Warn instead of raise when schema absent from get_schema_names() in test_connection (#10499)#11879
creazyfrog wants to merge 2 commits into
great-expectations:developfrom
creazyfrog:fix/test-connection-schema-name-not-found-10499

Conversation

@creazyfrog
Copy link
Copy Markdown

Summary

Fixes #10499

TableAsset.test_connection raised TestConnectionError immediately when the configured schema name was not returned by inspector.get_schema_names(). On SQL Server (and potentially other backends), get_schema_names() only lists schemas the connected user has VIEW DEFINITION permission on. A user with only SELECT permission on a table in a given schema can still access the table, but the schema is absent from the inspector's list — causing false-positive failures.

The error message was:

Attempt to connect to table: 'my_schema.my_table' failed because the schema 'my_schema' does not exist.

even though the table was fully accessible.

Root Cause

The pre-check on inspector.get_schema_names() is unreliable when the connected user lacks VIEW DEFINITION on the schema. It is redundant anyway because the subsequent SELECT 1 FROM <table> LIMIT 1 query serves as a definitive accessibility test.

Changes

  • great_expectations/datasource/fluent/sql_datasource.py — Replace the hard raise TestConnectionError when effective_schema not in schema_names with a LOGGER.warning. The table-level SELECT query that follows will catch any genuine connection failures and raise TestConnectionError with a clear message.
  • tests/datasource/fluent/test_sql_datasources.py — Add TestTableAssetTestConnection with two unit tests:
    • test_schema_absent_from_get_schema_names_does_not_raise: verifies that when the schema is omitted by get_schema_names() but the table query succeeds, no error is raised.
    • test_schema_absent_and_table_inaccessible_raises: verifies that if the table query also fails, TestConnectionError is still surfaced.

Workaround (before fix)

Users had to use add_query_asset() instead of add_table_asset() to bypass the schema pre-check.

Test plan

  • TestTableAssetTestConnection::test_schema_absent_from_get_schema_names_does_not_raise
  • TestTableAssetTestConnection::test_schema_absent_and_table_inaccessible_raises
  • Manually verified against a SQL Server instance where the user has SELECT-only permission on a schema

…es() in test_connection (great-expectations#10499)

`TableAsset.test_connection` raised TestConnectionError immediately when the
configured schema was not present in `inspector.get_schema_names()`.  On SQL
Server (and other backends where users lack VIEW DEFINITION permission),
get_schema_names() only returns schemas the connected user can describe—not
every schema they can access.  This caused false-positive failures: users
with only SELECT permission on a table could not call test_connection even
though the table was reachable.

Fix: replace the hard raise with a LOGGER.warning and let the subsequent
table-level SELECT 1 query act as the definitive accessibility check.  If
the schema or table is genuinely absent the SQL error surfaces a clear
TestConnectionError; if it is accessible the connection is confirmed.

Also adds two unit tests covering both the "schema absent but table
reachable" and "schema absent and table inaccessible" paths.

Fixes great-expectations#10499
@netlify
Copy link
Copy Markdown

netlify Bot commented May 17, 2026

👷 Deploy request for niobium-lead-7998 pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit db42cb8

@gx-cla-bot
Copy link
Copy Markdown

gx-cla-bot Bot commented May 17, 2026

A new contributor, HUZZAH! Welcome and thanks for joining our community. In order to accept a pull request we require that all contributors sign our Contributor License Agreement. We have two different CLAs, depending on whether you are contributing to GX in a personal or professional capacity. Please sign the one that is applicable to your situation so that we may accept your contribution:

Individual Contributor License Agreement v1.0
Software Grant and Corporate Contributor License Agreement v1.0

Once you have signed the CLA, you can add a comment with the text @cla-bot check and the bot will update the PR status!

Please reach out to the #gx-community-support channel, on our Slack if you have any questions or if you have already signed the CLA and are receiving this message in error.

Users missing a CLA: creazyfrog

@gx-cla-bot
Copy link
Copy Markdown

gx-cla-bot Bot commented May 17, 2026

A new contributor, HUZZAH! Welcome and thanks for joining our community. In order to accept a pull request we require that all contributors sign our Contributor License Agreement. We have two different CLAs, depending on whether you are contributing to GX in a personal or professional capacity. Please sign the one that is applicable to your situation so that we may accept your contribution:

Individual Contributor License Agreement v1.0
Software Grant and Corporate Contributor License Agreement v1.0

Once you have signed the CLA, you can add a comment with the text @cla-bot check and the bot will update the PR status!

Please reach out to the #gx-community-support channel, on our Slack if you have any questions or if you have already signed the CLA and are receiving this message in error.

Users missing a CLA: creazyfrog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failing test_connection in TableAsset.test_connection for uppercase schema name defined in SQL Server / mssql

1 participant