-
Notifications
You must be signed in to change notification settings - Fork 110
Add support for table comments #308
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
Add support for table comments #308
Conversation
0e6a2ec
to
9c8cbed
Compare
Signed-off-by: Christophe Bornet <[email protected]>
"""This test confirms that a table comment can be dropped. | ||
The difference with TableDDLTest is that the comment value is '' and not None after | ||
being dropped. | ||
""" |
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.
BTW this is surprising. From the docs we could expect the comment to be set to NULL and not ''.
But that's what I get when I test on databricks cloud.
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.
I adapted for this in #328 by simply coercing the ''
value into a NoneType
. This passes SQLAlchemy's reusable tests.
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.
Nice 👍
5e82562
to
e49eed3
Compare
Signed-off-by: Christophe Bornet <[email protected]>
@susodapop can we get help taking a peek at this one? |
Hello @nagyryan @susodapop @yansonggao-db @andrefurlan-db can one you help @cbornet get this reviewed and merged please? For context @cbornet and I are working on some LangChain apps and require this PR. Ideally we would use an official release instead of using a fork. We know of other devs that in same situation too |
Please let @cbornet or I know if there is anything we can do to move this along |
This is being reviewed and tested internally as we need to enable a few e2e
test and run the whole suite.
…On Tue, Jan 23, 2024 at 12:25 PM Nadir J ***@***.***> wrote:
Please let @cbornet <https://github.com/cbornet> or I know if there is
anything we can do move this along
—
Reply to this email directly, view it on GitHub
<#308 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AECG7B3D2HGQ2XMJYCDWSPTYP7W77AVCNFSM6AAAAABBEKINDGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBWGU3DEOJWGM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Signed-off-by: Jesse Whitehouse <[email protected]>
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.
Overall the change code looks great. I'm running all the tests and going to add some unit tests for the statement rendering.
@@ -61,7 +67,7 @@ def get_column_specification(self, column, **kwargs): | |||
feature in the future, similar to the Microsoft SQL Server dialect. | |||
""" | |||
if column is column.table._autoincrement_column or column.autoincrement is True: | |||
logger.warn( | |||
logger.warning( |
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.
Good catch 🙏
|
||
@requirements.comment_reflection | ||
@util.provide_metadata | ||
def test_drop_table_comment(self, connection): |
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.
Since I merged #328 do we still need to override this test?
@@ -251,36 +249,7 @@ class FutureWeCanSetDefaultSchemaWEventsTest(FutureWeCanSetDefaultSchemaWEventsT | |||
pass | |||
|
|||
|
|||
class FutureTableDDLTest(FutureTableDDLTest): |
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.
Perfect!
@@ -55,6 +55,7 @@ class SkipReason(Enum): | |||
TIMEZONE_OPT = "timezone-optional TIMESTAMP fields" | |||
TRANSACTIONS = "transactions" | |||
UNIQUE = "UNIQUE constraints" | |||
DROP_TBL = "drop table comment" |
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.
Since ''
is identical to None
as far as sqlalchemy is concerned, I think we needn't list this as unsupported. We can just document the behaviour. Thoughts?
Signed-off-by: Jesse Whitehouse <[email protected]>
class. Scaffold in the Table Comment unit tests. Signed-off-by: Jesse Whitehouse <[email protected]>
Signed-off-by: Jesse Whitehouse <[email protected]>
src/databricks/sqlalchemy/base.py
Outdated
table_name=table_name, | ||
schema_name=schema, | ||
) | ||
# Type ignore is because mypy knows that self._describe_table_extended *can* |
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.
We can actually catch this using isinstance
to avoid the mypy error like we do in get_pk_constraint
.
Signed-off-by: Jesse Whitehouse <[email protected]>
Signed-off-by: Jesse Whitehouse <[email protected]>
Signed-off-by: Jesse Whitehouse <[email protected]>
Signed-off-by: Jesse Whitehouse <[email protected]>
Signed-off-by: Jesse Whitehouse <[email protected]>
I pushed a few commits making these changes:
I concur with your choice not to use the thrift |
This was missed in databricks#328 Signed-off-by: Jesse Whitehouse <[email protected]>
Awesome ! |
NB: I didn't find a way to get the comments of temporary views
information_schema
DESCRIBE TABLE EXTENDED
doesn't return anything for temporary viewsSHOW CREATE TABLE
isn't supported for temporary viewsSHOW TABLE EXTENDED
doesn't report comments for temporary views (it does for default views)TGetTablesResp
message contains the temporary views but theREMARKS
field is empty for all tablesThe TCK tests
test_comments_unicode
andtest_comments_unicode_full
are still skipped at the moment since they also test column comments which are added in another PR: #306