Skip to content

Commit 1679d39

Browse files
committed
revert read col & fix reading logic
1 parent 5e62b34 commit 1679d39

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

clickhouse-data/src/main/java/com/clickhouse/data/ClickHouseColumn.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,8 @@ private static ClickHouseColumn update(ClickHouseColumn column) {
249249
case FixedString:
250250
if (size > 0) {
251251
column.precision = Integer.parseInt(column.parameters.get(0));
252-
column.estimatedByteLength += column.precision;
253-
if (column.nullable) {
254-
column.estimatedByteLength -= 1;
252+
if (!column.nullable) {
253+
column.estimatedByteLength += column.precision;
255254
}
256255
}
257256
column.template = ClickHouseStringValue.ofNull();

client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/BinaryStreamReader.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,11 @@ public <T> T readValue(ClickHouseColumn column, Class<?> typeHint) throws IOExce
112112
switch (dataType) {
113113
// Primitives
114114
case FixedString: {
115-
byte[] bytes = estimatedLen > STRING_BUFF.length ?
116-
new byte[estimatedLen] : STRING_BUFF;
117-
readNBytes(input, bytes, 0, estimatedLen);
118-
return (T) new String(bytes, 0, estimatedLen, StandardCharsets.UTF_8);
115+
int estimatedLenTemp = (estimatedLen > precision ? estimatedLen : precision);
116+
byte[] bytes = estimatedLenTemp > STRING_BUFF.length ?
117+
new byte[estimatedLenTemp] : STRING_BUFF;
118+
readNBytes(input, bytes, 0, estimatedLenTemp);
119+
return (T) new String(bytes, 0, estimatedLenTemp, StandardCharsets.UTF_8);
119120
}
120121
case String: {
121122
return (T) readString();

0 commit comments

Comments
 (0)