[jdbc-v2] RowBinary writer: setTime/setObject fail for Time and Time64 columns, setObject(java.sql.Array) fails for Array columns
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 40/100
Hướng nghiên cứu
Start in WriterStatementImpl.java: setTime (around line 390), setArray (around 378) and setObject(int, Object) (around 438), which pass Time, LocalTime and java.sql.Array values to the RowBinary writer. Then read SerializerUtils.java around convertToInteger (about line 746), serializeTime64 (about line 854) and serializeArrayData (about line 557). Run the 44-line reproduction program with the writer on and off; done means the writer-on rows store the same values as the SQL path, and the design choice about where to convert Time is recorded.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
With beta.row_binary_for_simple_insert=true, executeUpdate() and addBatch() of a simple INSERT ... VALUES (?, ...) fail with SQLException in these cases:
- A
Time,Nullable(Time)orTime64column, bound withsetTime(...), or withsetObject(...)and ajava.sql.Timeorjava.time.LocalTimevalue. Only a number of seconds works (setObject(i, 47655)stores13:14:15). - An
Array(...)column, bound withsetObject(...)and ajava.sql.ArrayfromConnection#createArrayOf.setArray(...)with the same value works.
With the writer off, all these cases store the value.
Root cause:
Time:WriterStatementImpl.setTime(WriterStatementImpl.java:390) gives the writer aLocalTime, andsetObject(:438) gives it the value unchanged.SerializerUtilswritesTimewithconvertToInteger(SerializerUtils.java:746, throws at:1066), andTime64withserializeTime64, which accepts onlyLong,BigIntegerandInstant(throws at:854).Array:WriterStatementImpl.setObject(int, Object)(:438) passes thejava.sql.Arraywrapper, butserializeArrayDataaccepts only aListor a Java array (throws atSerializerUtils.java:557).setArray(WriterStatementImpl.java:378) and the SQL path (PreparedStatementImpl.java:796) unwrap it withgetArray().
The Time fix needs a decision: convert the value in WriterStatementImpl (jdbc-v2 only), or let SerializerUtils accept LocalTime (also for client-v2 RowBinaryFormatWriter and POJO inserts).
Polyglot AI can open a fix PR if a maintainer assigns this issue to @polyglotAI-bot.
Related: #3416 (open) makes the typed setObject overloads call setObject(int, Object), so they get the same failures.
Steps to reproduce
- Connect with
beta.row_binary_for_simple_insert=true. - Prepare
INSERT INTO t VALUES (?, ?, ?)for a table with aTime,Time64(3)orArray(Int32)column in the middle. - Bind that column with
setTime, or withsetObjectand ajava.sql.Timeor acreateArrayOf(...)value, then callexecuteUpdate().
Error Log or Exception StackTrace
setTime(Time) -> Time writer=true FAIL java.lang.IllegalArgumentException: Cannot convert 13:14:15 to Integer
setTime(Time) -> Time writer=false stored 13:14:15
setObject(Time) -> Time writer=true FAIL java.lang.IllegalArgumentException: Cannot convert 13:14:15 to Integer
setObject(Time) -> Time writer=false stored 13:14:15
setTime(Time) -> Time64(3) writer=true FAIL java.lang.UnsupportedOperationException: Cannot convert class java.time.LocalTime to Time64
setTime(Time) -> Time64(3) writer=false stored 13:14:15.000
setObject(createArrayOf) -> Array(Int32) writer=true FAIL com.clickhouse.client.api.ClientException: Cannot write value of class class com.clickhouse.jdbc.types.Array into column with array type Array(Int32)
setObject(createArrayOf) -> Array(Int32) writer=false stored [1,2]
setArray(createArrayOf) -> Array(Int32) writer=true stored [1,2]
setArray(createArrayOf) -> Array(Int32) writer=false stored [1,2]
Expected Behaviour
The writer stores the same values as the SQL path. For the rows that the SQL path inserted, the server returns toString(v) = 13:14:15 (Time), 13:14:15.000 (Time64(3)) and [1,2] (Array(Int32)).
Code Example
Reproduction program (Java, 44 lines)
import java.sql.*;
import java.util.Properties;
public class Repro {
interface Bind { void bind(Connection c, PreparedStatement ps) throws SQLException; }
static void run(String name, String type, Bind bind) throws SQLException {
for (boolean writer : new boolean[]{true, false}) {
Properties p = new Properties();
p.setProperty("user", "default");
p.setProperty("password", System.getenv("CLICKHOUSE_PASSWORD"));
p.setProperty("beta.row_binary_for_simple_insert", String.valueOf(writer));
p.setProperty("clickhouse_setting_enable_time_time64_type", "1");
try (Connection c = new com.clickhouse.jdbc.Driver().connect("jdbc:clickhouse://clickhouse:8123/default", p);
Statement s = c.createStatement()) {
s.execute("CREATE OR REPLACE TABLE t (id Int32, v " + type + ", tail Int32) ENGINE = Memory");
String result;
try (PreparedStatement ps = c.prepareStatement("INSERT INTO t VALUES (?, ?, ?)")) {
ps.setInt(1, 1);
bind.bind(c, ps);
ps.setInt(3, 7);
ps.executeUpdate();
ResultSet rs = s.executeQuery("SELECT toString(v) FROM t");
rs.next();
result = "stored " + rs.getString(1);
} catch (SQLException e) {
result = "FAIL " + e.getMessage();
}
System.out.printf("%-40s writer=%-5s %s%n", name + " -> " + type, writer, result);
}
}
}
public static void main(String[] args) throws SQLException {
Time time = Time.valueOf("13:14:15");
run("setTime(Time)", "Time", (c, ps) -> ps.setTime(2, time));
run("setObject(Time)", "Time", (c, ps) -> ps.setObject(2, time));
run("setTime(Time)", "Time64(3)", (c, ps) -> ps.setTime(2, time));
run("setObject(createArrayOf)", "Array(Int32)",
(c, ps) -> ps.setObject(2, c.createArrayOf("Int32", new Integer[]{1, 2})));
run("setArray(createArrayOf)", "Array(Int32)",
(c, ps) -> ps.setArray(2, c.createArrayOf("Int32", new Integer[]{1, 2})));
}
}
Configuration
Client Configuration
p.setProperty("beta.row_binary_for_simple_insert", "true");
p.setProperty("clickhouse_setting_enable_time_time64_type", "1");
Environment
- Cloud
- Client version: jdbc-v2 0.12.0-rc1-SNAPSHOT (
mainat 051a7ecfd) - Language version: Java 17 (OpenJDK 17.0.21.1)
- OS: Linux (Docker)
ClickHouse Server
- ClickHouse Server version: 26.10.4.207
- ClickHouse Server non-default settings, if any:
enable_time_time64_type=1(sent by the client) CREATE TABLEstatements for tables involved: in the code example- Sample data for all these tables: none (the code example inserts the row)
Classification: impact: none · area: Data types & formats (Time, Time64, Array)
Found by automated analysis (Polyglot AI) while working on #3408. Verified against a live server.
- Ngôn ngữ chính
- Java
- Star
- 1.6k
- Fork
- 657
- Merge trung bình
- 2 ngày 6 giờ
- Pull request đã merge (30 ngày)
- 36
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ClickHouse/clickhouse-java
-
api-diagnostics bug jdbc
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
ClickHouse/clickhouse-java#3464 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
tests
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
ClickHouse/clickhouse-java#3452 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug jdbc performance queries sql-parser
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
ClickHouse/clickhouse-java#3451 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug jdbc legacy queries
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
ClickHouse/clickhouse-java#3444 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
api-diagnostics bug client jdbc
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
ClickHouse/clickhouse-java#3439 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của ClickHouse/clickhouse-java
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 60/100
quelea-projection/Quelea#749 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
free_port can hand one port to two callers, so the fixed-port http tests fail in parallel runsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 92/100
erkamyaman/rust-anything#963 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 76/100
-
Deferred
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Sanne/incus-spawn#2768 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
morluto/rea#15041 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày