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

[BUG] - JDBC driver loses data when JSONEachRow is used #725

Closed
jonathanyuechun opened this issue Sep 20, 2021 · 2 comments
Closed

[BUG] - JDBC driver loses data when JSONEachRow is used #725

jonathanyuechun opened this issue Sep 20, 2021 · 2 comments

Comments

@jonathanyuechun
Copy link

Hi,

It seems that a fix was proposed for this issue:

#475

but didnt had the chance to get merged.

This issue still exists in: https://github.com/ClickHouse/clickhouse-jdbc/tree/v0.3.1

Below a snippet:

  public static void main(String... args) throws SQLException {
    String url = "jdbc:clickhouse://localhost:8123/tutorial";
    ClickHouseProperties properties = new ClickHouseProperties();
    // set connection options - see more defined in ClickHouseConnectionSettings
    properties.setClientName("Agent #1");
    // set default request options - more in ClickHouseQueryParam
    properties.setSessionId("default-session-id");
    ClickHouseDataSource dataSource = new ClickHouseDataSource(url, properties);

    String sql = "select * from visits_v1 LIMIT 10 format JSONEachRow";
    Map<ClickHouseQueryParam, String> additionalDBParams = new HashMap<>();
    // set request options, which will override the default ones in ClickHouseProperties
    additionalDBParams.put(ClickHouseQueryParam.SESSION_ID, "new-session-id");
    List<String> datas = new ArrayList<>();
    try (ClickHouseConnection conn = dataSource.getConnection();
        ClickHouseStatement stmt = conn.createStatement();
        ResultSet rs = stmt.executeQuery(sql, additionalDBParams)) {
      while (rs.next()) {
        datas.add(rs.getString(1));
      }
    }
    // expected 10 but returned 8
    System.out.println(datas.size());
  }
@jonathanyuechun jonathanyuechun changed the title JDBC driver loses data when JSONEachRow is used [BUG] - JDBC driver loses data when JSONEachRow is used Sep 20, 2021
@zhicwu zhicwu added this to the 0.3.2 Release milestone Sep 20, 2021
@zhicwu
Copy link
Contributor

zhicwu commented Sep 20, 2021

Thanks for reporting. Currently the driver relies on TabSeparatedWithNamesAndTypes format and it does not support other formats well(especially those without headers). This will be fixed in next release.

@zhicwu
Copy link
Contributor

zhicwu commented Dec 10, 2021

select * from numbers(11) LIMIT 10 format JSONEachRow works for me, but this function is currently limited to http protocol - grpc does not support query with custom format.

@zhicwu zhicwu closed this as completed Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants