Skip to content

[fix][PES][datasource] fix DB2 schema query to use correct SQL instead of invalid command#983

Open
aiceflower wants to merge 1 commit intodev-2.0.0from
fix-db2-schema-query
Open

[fix][PES][datasource] fix DB2 schema query to use correct SQL instead of invalid command#983
aiceflower wants to merge 1 commit intodev-2.0.0from
fix-db2-schema-query

Conversation

@aiceflower
Copy link
Copy Markdown

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, not a valid SQL statement, 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

Why are the changes needed?

The list database directory command is a DB2 CLP (Command Line Processor) 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

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)

  • The PR title follows format: [fix][PES][datasource] fix DB2 schema query to use correct SQL instead of invalid command
  • The PR has meaningful description
  • Code follows Linkis style
  • No new dependencies added
  • No breaking changes introduced

🤖 Generated with Claude Code

…t SQL instead of invalid command

- Fix getAllDatabases() method in DB2 SqlConnection classes
- Replace invalid "list database directory" command with proper SQL query
- Add configurable schema query SQL with default filtering system schemas
- Query SYSCAT.SCHEMATA to get actual schema list from DB2

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant