-
Notifications
You must be signed in to change notification settings - Fork 100
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
SQLAlchemy 2: implement and refactor schema reflection methods #249
Conversation
5 skipped, 3 warnings, 727 errors in 40.01s Signed-off-by: Jesse Whitehouse <[email protected]>
It requires the implementation of raising NoSuchTableError for the different methods it checks. And hooboy was this difficult to track down! I found that these tests were mostly failing during setup and teardown because I didn't understand that two different schemas are required. This is covered in the SQLAlchemy tests documentation here: https://github.com/sqlalchemy/sqlalchemy/blob/main/README.unittests.rst#database-configuration The skipped tests happen because of exclusions, which is why the skip log information isn't as pleasant as our other tests. test_suite.py::ComponentReflectionTest_databricks+databricks::test_not_existing_table[get_check_constraints-_exclusions_06] SKIPPED test_suite.py::ComponentReflectionTest_databricks+databricks::test_not_existing_table[get_columns-_exclusions_01] b'table_does_not_exists' PASSED test_suite.py::ComponentReflectionTest_databricks+databricks::test_not_existing_table[get_foreign_keys-_exclusions_03] b'No such table table_does_not_exists' PASSED test_suite.py::ComponentReflectionTest_databricks+databricks::test_not_existing_table[get_indexes-_exclusions_04] SKIPPED test_suite.py::ComponentReflectionTest_databricks+databricks::test_not_existing_table[get_pk_constraint-_exclusions_02] b'No such table table_does_not_exists' PASSED test_suite.py::ComponentReflectionTest_databricks+databricks::test_not_existing_table[get_table_comment-_exclusions_07] SKIPPED test_suite.py::ComponentReflectionTest_databricks+databricks::test_not_existing_table[get_table_options-_exclusions_00] SKIPPED test_suite.py::ComponentReflectionTest_databricks+databricks::test_not_existing_table[get_unique_constraints-_exclusions_05] SKIPPED Signed-off-by: Jesse Whitehouse <[email protected]>
Signed-off-by: Jesse Whitehouse <[email protected]>
call to get_columns Signed-off-by: Jesse Whitehouse <[email protected]>
This passes the HasTableTest test group in the dialect compliance test suite Signed-off-by: Jesse Whitehouse <[email protected]>
This now PASSES test_get_primary_keys and test_get_pk_constraint Needs further refactor into actual parse methods... Signed-off-by: Jesse Whitehouse <[email protected]>
Signed-off-by: Jesse Whitehouse <[email protected]>
DBR_LTE_12_NOT_FOUND_STRING = "Table or view not found" | ||
DBR_GT_12_NOT_FOUND_STRING = "TABLE_OR_VIEW_NOT_FOUND" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These duplicate lines will be removed in a subsequent PR.
DBR_LTE_12_NOT_FOUND_STRING = "Table or view not found" | ||
DBR_GT_12_NOT_FOUND_STRING = "TABLE_OR_VIEW_NOT_FOUND" | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is all of this stuff in init.py?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a byproduct of earlier decisions. I'll move it out of init.py in a follow-up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The guidance from sqlalchemy is that this should be in a file called base.py
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved assuming followup refactor from _init_,py to base.py. Documentation and style looks good.
Background
The biggest piece of work required for this PR was figuring how to get
ComponentReflectionTest
to even run as it's setUp and tearDown methods were failing for various reasons.Description
This PR changes the has_table, get_pk_constraint, and get_foreign_keys methods into functional shape. They now pass the related tests in ComponentReflectionTest.
get_foreign_keys
is finished, following the guidance from @benc-db with regard to encapsulating strange parsing logic into more, smaller methods.In a follow-up PR I will make the same refactor to
get_pk_constraint
, but I wanted to get eyes on the approach forget_foreign_keys
before I proceed.I implemented a new
_describe_table_extended
method that is re-used by severaral methods.