JackieTien97 opened a new pull request, #18962:
URL: https://github.com/apache/iotdb/pull/18962

   ## Summary
   
   Fixes in the JDBC driver for the table model (`sql_dialect=table`) that 
break generic JDBC clients such as Trino's `BaseJdbcClient` and DBeaver. This 
is a driver-only change: the server is untouched.
   
   ### DatabaseMetaData (`IoTDBRelationalDatabaseMetadata`)
   - `getTables` / `getColumns` / `getPrimaryKeys` report the real database and 
table names in `TABLE_SCHEM` / `TABLE_NAME` instead of echoing the (escaped) 
search patterns, and report `TABLE_CAT` as NULL (`getTables` had no `TABLE_CAT` 
column at all).
   - `tableNamePattern`, `columnNamePattern` and `types` are honored. A null 
pattern no longer becomes `LIKE 'null'`, and quotes in patterns are escaped.
   - An empty result set is returned instead of `null`, and no empty TsBlock is 
sent any more (it was read back as one bogus row).
   - `NULLABLE` / `IS_NULLABLE` follow the TIME category instead of the column 
name, so a custom-named time column is reported correctly. `ORDINAL_POSITION` 
and `KEY_SEQ` are numbered within each table.
   - `getPrimaryKeys` matches the given names exactly, whether or not the 
caller escaped them.
   - The SHOW / DESC fallback, used when `information_schema` cannot be 
queried, applies the same patterns. `removeEscape` previously never removed an 
escape.
   - OBJECT columns are reported as `java.sql.Types.OTHER`.
   
   ### Statements and result sets
   - Prepared executions record the query id, so `cancel()` reaches the server, 
and they send the statement `fetchSize`.
   - `setTimestamp` converts values to the server time precision (ms / us / ns).
   - `setObject` (all overloads) accepts `java.time.LocalDate`.
   - SQL completed on the client is split at `?` the way the table-model lexer 
tokenizes it: string literals, quoted identifiers and comments hide `?`, and a 
backslash is an ordinary character.
   - `NaN` is written as `'NaN'`, which the server stores as NaN. Infinity has 
no accepted SQL form, so binding it in client-completed SQL fails with a clear 
`SQLException`. Server-prepared queries still send it in binary.
   - `getObject(int, Class)` and `getObject(String, Class)` support String, 
Boolean, Integer, Long, Float, Double, byte[], Timestamp and LocalDate.
   - `getTimestamp` returns null for SQL NULL, and the by-label variant honors 
the time precision.
   - `ResultSetMetaData` describes OBJECT columns (`OBJECT`, `Types.OTHER`).
   
   ### Connection
   - `setReadOnly(true)` is accepted as a hint. Trino calls it on every read 
connection.
   - New connections are in auto-commit mode, as JDBC requires.
   - `getCatalog()` returns null in the table dialect, and `setCatalog(null)` 
is ignored. The tree dialect keeps `Apache IoTDB`.
   
   ## Known limitation (needs server work)
   `Statement.cancel()` still cannot stop a query. 
`ClientRPCServiceImpl#cancelOperation` is unimplemented and always returns 
`QUERY_NOT_ALLOWED`, and the synchronized RPC client makes a cancel from 
another thread wait for the in-flight execute RPC. Now that prepared executions 
record their query id, `cancel()` on a prepared statement reaches the server 
and fails with a `SQLException`, as it already did for plain statements.
   
   ## Tests
   - `mvn test -pl iotdb-client/jdbc`: all 121 tests pass, both in the default 
build and with `-P with-zh-locale`. 47 of them are new.
   - Checked the connection defaults, `LocalDate` binding, NaN/Infinity 
handling and client-side `?` splitting against an IoTDB 2.0.10 server.
   
   🤖 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]

Reply via email to