Skip to content

branch-4.1: [refactor](jdbc) Unify JDBC scanning into FileQueryScanNode/JniReader framework (#61141)#61733

Draft
morningman wants to merge 1 commit intoapache:branch-4.1from
morningman:41_bp61141
Draft

branch-4.1: [refactor](jdbc) Unify JDBC scanning into FileQueryScanNode/JniReader framework (#61141)#61733
morningman wants to merge 1 commit intoapache:branch-4.1from
morningman:41_bp61141

Conversation

@morningman
Copy link
Contributor

bp #61141

@morningman morningman requested a review from yiguolei as a code owner March 25, 2026 18:05
@Thearas
Copy link
Contributor

Thearas commented Mar 25, 2026

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

… framework (apache#61141)

Refactor the JDBC data source scanning architecture to integrate with
the
unified FileScanner/JniReader framework, replacing the standalone
ExternalScanNode-based JDBC scan path.

The JDBC scan path was independently implemented with its own operator
(JDBCScanLocalState), scanner (JdbcScanner), and JNI connector
(JniConnector
→ BaseJdbcExecutor hierarchy), while other JNI-based data sources
(Paimon,
Hudi, MaxCompute, TrinoConnector) already use the unified FileScanner →
JniReader → JniScanner path. This caused code duplication, maintenance
burden,
and architectural inconsistency.

1. BE: Split JniConnector into two focused classes:
- JniReader: JNI lifecycle management (open/read/close), base class for
all JNI readers (PaimonJniReader, HudiJniReader, JdbcJniReader, etc.)
   - JniDataBridge: Stateless data exchange between C++ Blocks and Java
     shared memory via JNI

2. Java: Introduce Strategy Pattern for database-specific type handling:
- JdbcTypeHandler interface with DefaultTypeHandler base implementation
   - Per-database handlers: MySQLTypeHandler, OracleTypeHandler,
     PostgreSQLTypeHandler, ClickHouseTypeHandler, SQLServerTypeHandler,
DB2TypeHandler, SapHanaTypeHandler, TrinoTypeHandler, GbaseTypeHandler
   - JdbcTypeHandlerFactory for handler selection
   - JdbcJniScanner (extends JniScanner) for read path
   - JdbcJniWriter (extends JniWriter) for write path
   - Old BaseJdbcExecutor subclasses marked @deprecated but preserved

3. FE: Migrate JdbcScanNode from ExternalScanNode to FileQueryScanNode:
   - JdbcScanNode now extends FileQueryScanNode
   - Introduces JdbcSplit (extends FileSplit) to carry JDBC params
   - Uses TFileScanRange with FORMAT_JNI and table_format_type="jdbc"
   - Adds jdbc_params field to TTableFormatFileDesc in Thrift
   - Adapts PhysicalPlanTranslator.visitPhysicalJdbcScan() accordingly

4. BE: Add JdbcJniReader and integrate into FileScanner:
- JdbcJniReader handles special types (bitmap, HLL, quantile_state,
JSONB)
     via string-based intermediary and CAST
   - FileScanner._get_next_reader() adds "jdbc" table_format_type branch
   - JdbcUtils utility for JDBC driver URL resolution
   - Existing JdbcScanner preserved as transitional (deprecated)

All predicate push-down logic (createJdbcFilters, getJdbcQueryStr, etc.)
is preserved from the original JdbcScanNode implementation.
@morningman
Copy link
Contributor Author

run buildall

@hello-stephen
Copy link
Contributor

Cloud UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 78.47% (1786/2276)
Line Coverage 64.30% (32046/49838)
Region Coverage 65.13% (16031/24612)
Branch Coverage 55.65% (8536/15340)

@hello-stephen
Copy link
Contributor

FE UT Coverage Report

Increment line coverage 0.00% (0/100) 🎉
Increment coverage report
Complete coverage report

@morningman morningman marked this pull request as draft March 25, 2026 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants