ClickHouse / ClickHouse/clickhouse-java

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

Đang mở
#2,715 4 bình luận 1 reaction 0 người được giao Xem trên GitHub
area:data-type bug
Ngôn ngữ chính
Java
Star
1.6k
Fork
636
Merge trung bình
2 ngày 23 giờ
Pull request đã merge (30 ngày)
29

Mô tả

## 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:

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với đường dẫn bị lỗi trong com.clickhouse.jdbc.StatementImpl.executeQueryImpl tại StatementImpl.java:164 và theo dõi lời gọi từ PreparedStatementImpl.java:144. Tái hiện vấn đề bằng ClickHouseTest.java với SELECT 1 as x FORMAT JSON, sau đó xác minh rằng truy vấn JDBC tạo ra kết quả JSON như mong đợi thay vì từ chối định dạng đầu ra.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
java
Lĩnh vực
database
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
58/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.