Skip to content

[jdbc-v2] Added test for WITH statement with parameters. #2392

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 3 commits into from
May 28, 2025

Conversation

chernser
Copy link
Contributor

@chernser chernser commented May 27, 2025

Summary

  • Adds test for WITH clause with parameters to PreparedStatementImplTests

Closes #2391

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

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
66.7% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@mshustov mshustov requested a review from Copilot May 28, 2025 07:44
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 adds integration tests for the WITH clause using parameters in prepared statements and cleans up unused overrides in several JDBC classes.

  • Added a new test, testWithClauseWithParams, in PreparedStatementTest.java to validate parameterized WITH statements.
  • Removed redundant overridden methods from StatementImpl, DataSourceImpl, and ConnectionImpl to streamline their implementations.

Reviewed Changes

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

File Description
jdbc-v2/src/test/java/com/clickhouse/jdbc/PreparedStatementTest.java Added tests for WITH clause and improved test structure by scoping variable declarations.
jdbc-v2/src/main/java/com/clickhouse/jdbc/StatementImpl.java Removed unused override methods to rely on default implementations.
jdbc-v2/src/main/java/com/clickhouse/jdbc/DataSourceImpl.java Removed unused methods and corresponding imports related to connection building and sharding.
jdbc-v2/src/main/java/com/clickhouse/jdbc/ConnectionImpl.java Revised the array creation implementation and removed deprecated sharding key methods.
Files not reviewed (2)
  • clickhouse-client/pom.xml: Language not supported
  • pom.xml: Language not supported
Comments suppressed due to low confidence (2)

jdbc-v2/src/test/java/com/clickhouse/jdbc/PreparedStatementTest.java:332

  • Consider using a consistent method (either column labels or column indexes) for accessing result set values to improve clarity and reduce the risk of issues if the column order changes.
Assert.assertEquals(rs.getTimestamp("target_time").toLocalDateTime().truncatedTo(ChronoUnit.SECONDS), target_time.toInstant().atZone(ZoneId.of("UTC")).toLocalDateTime().truncatedTo(ChronoUnit.SECONDS));

jdbc-v2/src/main/java/com/clickhouse/jdbc/ConnectionImpl.java:553

  • [nitpick] If there's no specific need for streaming the elements, consider using Arrays.asList(elements) to simplify the code and improve readability, assuming that a direct conversion is acceptable.
List<Object> list = (elements == null || elements.length == 0) ? Collections.emptyList() : Arrays.stream(elements, 0, elements.length).collect(Collectors.toList());

@mshustov
Copy link
Member

/windsurf-review

@chernser chernser merged commit bed84ee into main May 28, 2025
21 of 23 checks passed
@chernser chernser deleted the fix_with_statement branch May 28, 2025 19:13
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.

[jdbc] Parsing statement containing WITH clause fails on client side
2 participants