Skip to content

Commit 21d436a

Browse files
committed
Fixing read FixedString using precision
1 parent 1679d39 commit 21d436a

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ public <T> T readValue(ClickHouseColumn column, Class<?> typeHint) throws IOExce
103103

104104
ClickHouseColumn actualColumn = column.getDataType() == ClickHouseDataType.Dynamic ? readDynamicData() : column;
105105
ClickHouseDataType dataType = actualColumn.getDataType();
106-
int estimatedLen = actualColumn.getEstimatedLength();
107106
int precision = actualColumn.getPrecision();
108107
int scale = actualColumn.getScale();
109108
TimeZone timezone = actualColumn.getTimeZoneOrDefault(timeZone);
@@ -112,11 +111,10 @@ public <T> T readValue(ClickHouseColumn column, Class<?> typeHint) throws IOExce
112111
switch (dataType) {
113112
// Primitives
114113
case FixedString: {
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);
114+
byte[] bytes = precision > STRING_BUFF.length ?
115+
new byte[precision] : STRING_BUFF;
116+
readNBytes(input, bytes, 0, precision);
117+
return (T) new String(bytes, 0, precision, StandardCharsets.UTF_8);
120118
}
121119
case String: {
122120
return (T) readString();

0 commit comments

Comments
 (0)