Skip to content

[jdbc-v2] [output format] SQL Error [HY000]: Only RowBinaryWithNameAndTypes is supported for output format. Please check your query. #2715

Description

@ikfid

Description

Migrating from clickhouse jdbc driver 0.6.5 to clickhouse jdbc v2 driver 0.9.6, some queries stopped working.

Steps to reproduce

  1. SELECT 1 as x FORMAT JSON

Error Log or Exception StackTrace

Exception in thread "main" java.sql.SQLException: Only RowBinaryWithNameAndTypes is supported for output format. Please check your query.
	at com.clickhouse.jdbc.StatementImpl.executeQueryImpl(StatementImpl.java:164)
	at com.clickhouse.jdbc.PreparedStatementImpl.executeQuery(PreparedStatementImpl.java:144)
	at ClickHouseTest.main(ClickHouseTest.java:18)

Clickhouse server does not produce any error, and 'clickhouse client' executes the above query without issues, therefore, I assume, there is some issue at the jdbc client side.

Expected output

{                     
 "meta":              
 [                    
  {                   
   "name": "x",       
   "type": "UInt8"    
  }                   
 ],                   
                      
 "data":              
 [                    
  {                   
   "x": 1             
  }                   
 ],                   
                      
 "rows": 1,           
                      
 "statistics":        
 {                    
  "elapsed": 0.001607,
  "rows_read": 1,     
  "bytes_read": 1     
 }                    
}                     

Sample code

implementation "com.clickhouse:clickhouse-jdbc-all:0.9.6"

import javax.sql.DataSource;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Properties;

public class ClickHouseTest {

    public static void main(String[] args) throws Exception {
        Properties properties = new Properties();
        properties.setProperty("user", "default");
        properties.setProperty("password", "");

        DataSource dataSource = new com.clickhouse.jdbc.DataSourceImpl("jdbc:clickhouse://127.0.0.1:8123", properties);
        Connection connection = dataSource.getConnection();
        PreparedStatement stmt = connection.prepareStatement("SELECT 1 as x FORMAT JSON");
        ResultSet rs = stmt.executeQuery();
        while (rs.next()) {
            String json = rs.getString(1);
            System.out.println(json);
        }
        stmt.close();
        connection.close();
    }
}

Environment

  • Cloud
  • Client version: 0.9.6
  • Language version: 21
  • OS:

ClickHouse Server

  • ClickHouse Server version: 26.1.1.399
  • ClickHouse Server non-default settings, if any:

Activity

  1. chernser commented on Jul 16, 2026

    @chernser
    Contributor

    @ikfid

    Thank you for reporting the issue!

    We have not ported this "feature" because wanted to make V2 following standard. In this particular case we also need to support JSON format because it is not just JSON but data + metadata. Metadata should be parsed into ResultSetMetadata to keep JDBC driver usable.
    In 0.10.0-rc1 we have added support for JSONEachRow in the way you can plugin your favorite JSON library and get already parsed data. https://github.com/ClickHouse/clickhouse-java/tree/main/examples/jdbc-v2-json-processors
    Would it work in your case?

    This code will work only with ClickHouse driver. Would it more convenient if we add a shortcut method to make request with internal client?

    Sorry for breaking the compatibility but we have to handle many use-cases.

    Thanks!

  2. ikfid commented on Jul 17, 2026

    @ikfid
    Author

    @chernser , thanks for providing your feedback for this issue.

    I've checked again the use case I had in mind and, to be honest, cannot recall the exact details.
    The production code is relying on JSONEachRow since 2025, while I opened the ticket in 2026.

    Therefore, I think, I reported this ticket because of another use case - querying data via DBeaver.
    Imagine, I have clickhouse client and DBeaver client. In both I wanted to execute the same query with FORMAT JSON output.
    but it worked fine in clickhouse client and stopped working in DBeaver (relying on JDBC drivers). I guess, that was the case.
    Also, I can recall explain plain <sql> in DBeaver failed with exact same exception. Maybe this also triggered me to report this ticket. I just don't remember how far I went in root cause analysis 😄.

    Having said that - I certainly can fix my code (it's already fixed), but cannot make something get to work in DBeaver that used to work there, and hard to explain why it continues working in clickhouse client and not in DBeaver.

  3. telperions commented on Jul 17, 2026

    @telperions

    There also will be nice to have a support for FORMAT Null for query speed evaluation, since it just executes query and not returns any data to client. It was supported back in 0.6.3. And now we can not use it in Datagrip/DBeaver

  4. chernser commented on Jul 28, 2026

    @chernser
    Contributor

    @telperions added as another issue #2963

    @ikfid I will see what we can do here.

  5. added this to the 0.12.0 milestone on Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions