Skip to content
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

Get ResultSet meta data before execution #1434

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Get ResultSet meta data before execution #1434

wants to merge 1 commit into from

Conversation

zhicwu
Copy link
Contributor

@zhicwu zhicwu commented Aug 28, 2023

Summary

Get ResultSet meta data before execution

Checklist

Delete items not relevant to your PR:

  • 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

@zhicwu zhicwu marked this pull request as draft August 28, 2023 14:19
@zhicwu zhicwu linked an issue Aug 28, 2023 that may be closed by this pull request
public void testGetMetaData() throws SQLException {
try (Connection conn = newConnection(new Properties());
PreparedStatement ps = conn.prepareStatement("select ? a, ? b")) {
ResultSetMetaData md = ps.getMetaData();
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if we pass DDL (e.g. CREATE TABLE) to conn.prepareStatement? It would be nice to add a test in my opinion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for taking your time to review the PR!

What happens if we pass DDL (e.g. CREATE TABLE) to conn.prepareStatement?

null will be returned at this point. Below is the check in SqlBasedPreparedStatement.java. However, in ClickHouse, create table on cluster will actually return ResultSet, but I guess we don't need that as it's not helping for push-down implementation.

if (parsedStmt.isRecognized() && !parsedStmt.isQuery()) {
    return null;
}

It would be nice to add a test in my opinion.

Yes, the implementation is incomplete and I'll add more tests for sure.

@sylph-eu
Copy link
Contributor

Hi, any plans to complete this PR?

@sylph-eu
Copy link
Contributor

JFYI #1700

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.

How to get ResultSetMetaData in ClickHousePreparedStatement
3 participants