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
Show column comment in JDBC connector #1840
Conversation
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.
Looks good, just two comments
presto-mysql/src/test/java/io/prestosql/plugin/mysql/TestMySqlIntegrationSmokeTest.java
Outdated
Show resolved
Hide resolved
...tgresql/src/test/java/io/prestosql/plugin/postgresql/TestPostgreSqlIntegrationSmokeTest.java
Show resolved
Hide resolved
presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/BaseJdbcClient.java
Show resolved
Hide resolved
presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/JdbcColumnHandle.java
Outdated
Show resolved
Hide resolved
0fe37cc
to
8c0d92d
Compare
presto-base-jdbc/src/test/java/io/prestosql/plugin/jdbc/TestJdbcClient.java
Outdated
Show resolved
Hide resolved
...tgresql/src/test/java/io/prestosql/plugin/postgresql/TestPostgreSqlIntegrationSmokeTest.java
Outdated
Show resolved
Hide resolved
|
||
assertQuery( | ||
"SELECT column_name, comment FROM information_schema.columns WHERE table_schema = 'tpch' AND table_name = 'test_column_comment'", | ||
"VALUES ('col1', 'test comment'), ('col2', null), ('col3', null)"); |
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 comment for col2 is null and not ''
?
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.
In PostgreSQL, COMMENT ON object IS ''
is the same as COMMENT ON object IS NULL
(remove the existing comment). I couldn't find the document about the empty character, but even pg_catalog.pg_description
table doesn't hold the empty comment. It means this is not driver's issue.
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.
Thanks, so i suggest: #1840 (comment)
@@ -155,6 +160,43 @@ protected String getTableSchemaName(ResultSet resultSet) | |||
return resultSet.getString("TABLE_CAT"); | |||
} | |||
|
|||
@Override | |||
public List<JdbcColumnHandle> getColumns(ConnectorSession session, JdbcTableHandle tableHandle) |
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.
Don't copy.
Just add
// Note: some databases (e.g. SQL Server) do not return column remarks/comment here.
Optional<String> comment = Optional.ofNullable(emptyToNull(resultSet.getString("REMARKS")));
in BaseJdbcClient
's method
presto-mysql/src/test/java/io/prestosql/plugin/mysql/TestMySqlIntegrationSmokeTest.java
Show resolved
Hide resolved
presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/JdbcColumnHandle.java
Outdated
Show resolved
Hide resolved
{ | ||
execute("CREATE TABLE tpch.test_column_comment (col1 bigint, col2 bigint, col3 bigint)"); | ||
execute("COMMENT ON COLUMN tpch.test_column_comment.col1 IS 'test comment'"); | ||
execute("COMMENT ON COLUMN tpch.test_column_comment.col2 IS ''"); |
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.
execute("COMMENT ON COLUMN tpch.test_column_comment.col2 IS ''"); | |
execute("COMMENT ON COLUMN tpch.test_column_comment.col2 IS ''"); // it will be NULL, PostgreSQL doesn't store empty comment |
8c0d92d
to
d130a6e
Compare
Fixes #1837