Skip to content

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

Merged
casionone merged 1 commit intoapache:dev-2.0.0from
aiceflower:pr-20260411-db2-schema-query
Apr 13, 2026
Merged

[fix][PES][datasource] fix DB2 schema query to use correct SQL instead of invalid command#5409
casionone merged 1 commit intoapache:dev-2.0.0from
aiceflower:pr-20260411-db2-schema-query

Conversation

@aiceflower
Copy link
Copy Markdown
Member

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)

🤖 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>
Copy link
Copy Markdown
Contributor

@casionone casionone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@casionone casionone merged commit c7a0882 into apache:dev-2.0.0 Apr 13, 2026
10 of 11 checks passed
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.

2 participants