perkolatte opened a new pull request, #71088:
URL: https://github.com/apache/doris/pull/71088

   ### Background
   
   A JDBC catalog maps the tables of an external database into Doris. Doris 
reads a table's comment from the connector's `getTableComment()` and shows it 
in `SHOW TABLE STATUS` and `information_schema.tables`. On `master` the JDBC 
catalog runs in the `fe-connector-jdbc` plugin, where only the MySQL client 
overrides `getTableComment()`; every other database inherits the base method, 
which returns an empty string.
   
   ### What problem does this PR solve?
   
   Issue Number: close #70530
   Related PR: #54088 (added table comments for MySQL)
   PR Type: Enhancement
   
   Problem Summary:
   
   Users of Oracle and SAP HANA catalogs see an empty comment for every table, 
although the tables have comments in the source database. This PR reads the 
comment from each database's dictionary: `ALL_TAB_COMMENTS` for Oracle, and 
`SYS.TABLES` with `SYS.VIEWS` for SAP HANA. It moves the MySQL client's 
prepared-statement lookup into a shared helper, 
`JdbcConnectorClient.queryTableComment()`, that the three clients use. Other 
databases are unchanged.
   
   | `getTableComment("DORIST", ...)` on Oracle 23ai Free | Before | After |
   |---|---|---|
   | table `ORDERS`, comment `订单表 orders table` | `""` | `订单表 orders table` |
   | view `ORDERS_V`, comment `orders view` | `""` | `orders view` |
   | table `NO_COMMENT`, no comment | `""` | `""` |
   
   ### Details
   
   - **Before and after:** before, Oracle and SAP HANA tables and views have an 
empty comment. After, they have the comment from the source database, and 
tables without one still have an empty comment.
   - **Configs and defaults:** None.
   - **Impact on existing users:** comments appear for Oracle and SAP HANA 
catalogs after the upgrade, with no change to SQL or settings. Reading a 
comment runs one query against the source database for each table it is read 
for, as MySQL catalogs already do. A failed lookup still shows an empty 
comment, because `PluginDrivenExternalTable.getComment()` catches the error and 
returns `""`. An OceanBase catalog in Oracle mode delegates to the Oracle 
client, so it now queries `ALL_TAB_COMMENTS` too.
   
   ### Testing
   
   - `JdbcTableCommentTest` (new, 4 tests): with fake JDBC objects, checks the 
query and bound parameters of the Oracle, SAP HANA, and MySQL clients, and that 
a missing row or a `NULL` comment gives `""`. The 31 tests of the 
`Jdbc*ConnectorClientTest` classes and `JdbcTableCommentTest` pass locally with 
JDK 17.
   - Oracle: ran `JdbcOracleConnectorClient.getTableComment()` locally against 
Oracle Database 23ai Free (`gvenzl/oracle-free:23-slim-faststart`) with 
`ojdbc11` 23.6, on the objects in the table above, plus a name that does not 
exist (`""`). This ran through the client, not a Doris cluster.
   - SAP HANA: covered only by the unit test; not run against a SAP HANA 
database.
   
   ### Notes for Reviewers
   
   - Oracle's `DatabaseMetaData.getTables()` leaves `REMARKS` null unless the 
connection sets `remarksReporting`, so the Oracle client queries 
`ALL_TAB_COMMENTS` rather than reading `REMARKS`. The view lists only objects 
the catalog user can access, the same objects the catalog lists.
   - SAP HANA keeps table comments in `SYS.TABLES.COMMENTS` and view comments 
in `SYS.VIEWS.COMMENTS`, so its query is a `UNION ALL` of the two.
   - `branch-4.1` and earlier read comments through the fe-core `JdbcClient` 
classes, which the issue cites; a backport would need the same overrides in 
`JdbcOracleClient` and `JdbcSapHanaClient`.
   
   ### Release note
   
   Oracle and SAP HANA JDBC catalogs now show table and view comments from the 
source database in `SHOW TABLE STATUS` and `information_schema.tables`, instead 
of an empty comment.
   
   ### Check List (For Author)
   
   - Behavior changed: No
   - Does this need documentation: No
   - Pre-submission status: Partially verified: SAP HANA is not run against a 
real database, and neither database is run through a Doris cluster
   
   ### AI Disclosure
   
   - Tool: Claude Code (Claude Opus 5.5)
   - Generated: code, tests, this description
   - Human review: not stated
   - Prompts: The author asked for unclaimed Doris FE issues to fix, chose 
#70530, and asked for it to be verified against a real Oracle database for free.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to