Skip to content

Adjust getIndexInfo to return an empty ResultSet instead of a null value #2315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 22, 2025

Conversation

Paultagoras
Copy link
Contributor

Summary

  • Tweaked DatabaseMetaData.getIndexInfo to return an empty ResultSet rather than null

Closes #2286

Checklist

Delete items not relevant to your PR:

  • Closes #
  • Unit and integration tests covering the common scenarios were added
  • A human-readable description of the changes was provided to include in CHANGELOG
  • For significant changes, documentation in https://github.com/ClickHouse/clickhouse-docs was updated with further explanations or tutorials

@Paultagoras Paultagoras self-assigned this Apr 17, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates DatabaseMetaData.getIndexInfo to return an empty ResultSet instead of null, ensuring that JDBC calls do not unexpectedly receive a null value. It also renames the DatabaseMetaData class to DatabaseMetaDataImpl and updates its references, and adds a new integration test for the getIndexInfo behavior.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
jdbc-v2/src/test/java/com/clickhouse/jdbc/metadata/DatabaseMetaDataTest.java Updated test to reference DatabaseMetaDataImpl and assert an empty ResultSet for getIndexInfo
jdbc-v2/src/main/java/com/clickhouse/jdbc/metadata/DatabaseMetaDataImpl.java Renamed class from DatabaseMetaData and modified getIndexInfo to return an empty ResultSet using a SQL query
jdbc-v2/src/main/java/com/clickhouse/jdbc/ConnectionImpl.java Updated to import and reference DatabaseMetaDataImpl instead of the previous class

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
7 Security Hotspots
29.6% Coverage on New Code (required ≥ 80%)
34.8% Duplication on New Code (required ≤ 3%)
E Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@@ -1065,7 +1065,14 @@ private static String getDataTypeInfoSql() {

@Override
public ResultSet getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate) throws SQLException {
return null;
try {
String sql = "SELECT null AS TABLE_CAT, null AS TABLE_SCHEM, null AS TABLE_NAME, null AS NON_UNIQUE," +
Copy link
Contributor

Choose a reason for hiding this comment

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

I would expect that we use https://clickhouse.com/docs/sql-reference/statements/show#show-index to get information about indexes.

@Paultagoras Paultagoras requested a review from chernser April 22, 2025 06:16
Copy link
Contributor

@mzitnik mzitnik left a comment

Choose a reason for hiding this comment

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

LGTM

@Paultagoras Paultagoras merged commit a245c1f into main Apr 22, 2025
24 of 25 checks passed
@Paultagoras Paultagoras deleted the tweak-databasemetadata branch April 22, 2025 16:23
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.

If not implemented, null should not be returned
3 participants