aiceflower opened a new pull request, #5409:
URL: https://github.com/apache/linkis/pull/5409

   ## What changes were proposed in this pull request?
   
   This PR fixes the DB2 schema query issue in the `getAllDatabases()` method 
of DB2 SqlConnection classes. The original implementation used an invalid 
command `list database directory` which is a DB2 CLP (Command Line Processor) 
command, not a valid SQL statement for JDBC execution, causing the schema list 
retrieval to fail.
   
   **Changes:**
   1. Replace invalid `list database directory` command with proper SQL query 
against `SYSCAT.SCHEMATA`
   2. Add configurable schema query SQL 
(`wds.linkis.server.mdm.service.db2.schema.query.sql`) with default filtering 
system schemas (SYS%, NULLID, SQLJ)
   3. Update both modules:
      - 
`linkis-datasource-manager/service/jdbc/src/main/java/org/apache/linkis/metadata/query/service/db2/SqlConnection.java`
      - 
`linkis-metadata-query/service/jdbc/src/main/java/org/apache/linkis/metadata/query/service/db2/SqlConnection.java`
   
   Fixes #5408
   
   ## Why are the changes needed?
   
   The `list database directory` command is a DB2 CLP command that cannot be 
executed via JDBC `executeQuery()`. This causes SQLException when trying to get 
the schema/database list from DB2 data sources.
   
   **Brief change log:**
   - Fixed `getAllDatabases()` method to use proper SQL: `SELECT SCHEMANAME 
FROM SYSCAT.SCHEMATA WITH UR`
   - Added configurable SQL for schema query with system schema filtering
   - Renamed variable from `dataBaseName` to `schemaNames` for clarity (DB2 
uses schemas, not databases)
   
   ## How was this patch tested?
   
   - Manual testing with DB2 data source connection
   - Verified schema list retrieval works correctly
   - Tested with both user schemas and system schemas filtering
   
   ## Does this PR introduce any user-facing change?
   
   - No breaking changes
   - Users can configure the schema query SQL via 
`wds.linkis.server.mdm.service.db2.schema.query.sql` if needed
   
   ### Check List (Author)
   
   - [x] The PR title follows format: `[fix][PES][datasource] fix DB2 schema 
query to use correct SQL instead of invalid command`
   - [x] The PR has meaningful description
   - [x] Code follows Linkis style
   - [x] No new dependencies added
   - [x] No breaking changes introduced
   - [x] Related issue linked: Fixes #5408
   
   🤖 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