wangzhigang1999 opened a new pull request, #7442: URL: https://github.com/apache/kyuubi/pull/7442
### Why are the changes needed? The JDBC engine used to answer metadata requests with dialect-specific, hand-written `INFORMATION_SCHEMA` SQL for `getCatalogs`, `getSchemas`, `getTables`, `getColumns`, `getTypeInfo`, `getFunctions`, `getPrimaryKeys`, and `getCrossReference`. That path was hard to keep aligned with the JDBC contract. Clients could see swapped or missing catalog/schema columns, backend-specific labels such as Impala's `TABLE_MD`, and inconsistent metadata filter handling across dialects. This PR replaces those per-dialect SQL builders with the standard JDBC `DatabaseMetaData.getXxx(...)` APIs from the backend driver, while keeping catalog-vs-schema conventions and metadata-only label normalization in `JdbcDialect`. ### What changes? - Replace the hand-written metadata SQL path with backend `DatabaseMetaData` calls. - Add dialect support for database-term handling and metadata column-label normalization. - Pass the resolved session dialect consistently through metadata operations. - Apply the URL-level database before running per-session initialize SQL. - Add `ResultSetFetchIterator` for correct metadata streaming, partial fetch, and idempotent close behavior. ### Compatibility notes Metadata result sets now follow the JDBC spec more closely. Clients using spec column names should benefit; clients depending on the old non-spec labels or catalog/schema layout may need updates. When the JDBC URL carries a database, `JdbcSessionImpl` now switches to it before executing the per-session initialize SQL, so init SQL runs in the URL-specified database rather than the driver's default. ### How was this patch tested? - Updated existing per-dialect `OperationSuite` coverage for MySQL, PostgreSQL, Oracle, Phoenix, ClickHouse, Doris, StarRocks, and Impala. - Added backend metadata contract suites that verify the Hive JDBC client over Thrift sees JDBC-spec column names, key fields, and metadata filters. - Added `ResultSetFetchIteratorSuite` for prefetch, partial fetch, and close behavior. - Verified end-to-end via beeline against all eight dialects (MySQL, PostgreSQL, Oracle, Phoenix, ClickHouse, Doris, StarRocks, Impala): metadata operations return JDBC-spec column layouts and `SELECT` against existing tables succeeds. - Full DDL/DML cycles (`DROP IF EXISTS` -> `CREATE` -> `INSERT` -> `SELECT` -> `DROP`) verified on StarRocks, Doris, MySQL, PostgreSQL, and ClickHouse; Oracle / Phoenix / Impala excluded since their DDL grammar diverges. ### Was this patch authored or co-authored using generative AI tooling? Yes. Claude Opus 4.7 helped draft parts of the test cases and local test-environment setup. The implementation, test results, and final changes were reviewed and validated by the author. -- 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]
