Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
amirulmenjeni opened this issue Oct 10, 2024 · 6 comments
Labels
community-supported supported by the GX community stack:mssql

Comments

@amirulmenjeni
Copy link

Using GX Core version: 1.1.1

Currently I'm not able to create a table data asset from the SQLDatasource's add_table_asset method when the schema of the table I'm trying to connect to is defined in the database in the uppercase form (e.g., MY_SCHEMA):

datasource.add_table_asset(
    name="asset-name", 
    schema_name="S_EC",
    table_name="my_table",
)

Instead I got the following error:

great_expectations.datasource.fluent.interfaces.TestConnectionError: Attempt to connect to table: "my_schema.my_table" failed because the schema "my_schema" does not exist

Looking at the lines below it seems that the self.schema_name not in inspector.get_schema_names() check doesn't do case insensitive comparison.

if self.schema_name and self.schema_name not in inspector.get_schema_names():
raise TestConnectionError( # noqa: TRY003
f'Attempt to connect to table: "{self.qualified_name}" failed because the schema '
f'"{self.schema_name}" does not exist.'
)

Attempting to bracket the schema with quote characters (e.g., 'MY_SCHEMA') does persist the uppercase, but the test fails as well, complaining:

great_expectations.datasource.fluent.interfaces.TestConnectionError: Attempt to connect to table: ""MY_SCHEMA".my_table" failed because the schema ""MY_SCHEMA"" does not exist

I can still create query asset with add_query_asset method, though.

@Kilo59
Copy link
Contributor

Kilo59 commented Oct 11, 2024

I believe the SQLAlchemy behavior is to always treat lowercase identifiers as cases insensitive.
Try using a lowercase schema_name (even though your actual schema is uppercase).

@adeola-ak
Copy link
Contributor

hi @amirulmenjeni can you confirm if using a lowercase schema_name no longer resulted in an error?

@adeola-ak adeola-ak moved this from To Do to In progress in GX Core Issues Board Oct 15, 2024
@amirulmenjeni
Copy link
Author

@adeola-ak, I've tried that as well. Sorry I failed to mention that in the original post. But that also didn't work.

@adeola-ak
Copy link
Contributor

@amirulmenjeni just to confirm, your schema was created with quotations to preserve the uppercase form? therefore the schema name is "S_EC", including the quotes?

@amirulmenjeni
Copy link
Author

@adeola-ak, yes I've tried several variations, i.e., S_EC, s_ec, "S_EC"

@adeola-ak
Copy link
Contributor

Hi there. It turns out that MSSQL is actually a community-supported integration, meaning that while we welcome contributions, we typically do not fully test or support it.

Since you were able to pinpoint where the issue might originate in our codebase, I encourage you to submit a PR contribution if you're interested, which we will promptly review.

I understand this may not be the outcome you were hoping for, but I want to thank you for your patience as I investigated the matter.

I will be keeping this issue open.

@adeola-ak adeola-ak added the community-supported supported by the GX community label Oct 24, 2024
@adeola-ak adeola-ak moved this from In progress to To Do in GX Core Issues Board Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-supported supported by the GX community stack:mssql
Projects
Status: To Do
Development

No branches or pull requests

3 participants