Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class RowBinaryFormatWriter {

private final Object[] row;

private final boolean defaultSupport;

public RowBinaryFormatWriter(OutputStream out, TableSchema tableSchema, ClickHouseFormat format) {
if (format != ClickHouseFormat.RowBinary && format != ClickHouseFormat.RowBinaryWithDefaults) {
throw new IllegalArgumentException("Only RowBinary and RowBinaryWithDefaults are supported");
Expand All @@ -37,6 +39,7 @@ public RowBinaryFormatWriter(OutputStream out, TableSchema tableSchema, ClickHou
this.out = out;
this.tableSchema = tableSchema;
this.row = new Object[tableSchema.getColumns().size()];
this.defaultSupport = format == ClickHouseFormat.RowBinaryWithDefaults;
}

public void setValue(String column, Object value) {
Expand All @@ -48,12 +51,11 @@ public void setValue(int colIndex, Object value) {
}

public void commitRow() throws IOException {

List<ClickHouseColumn> columnList = tableSchema.getColumns();
for (int i = 0; i < row.length; i++) {
ClickHouseColumn column = columnList.get(i);

if (RowBinaryFormatSerializer.writeValuePreamble(out, true, column, row[i])) {
if (RowBinaryFormatSerializer.writeValuePreamble(out, defaultSupport, column, row[i])) {
SerializerUtils.serializeData(out, row[i], column);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,12 @@ public <T> T readValue(ClickHouseColumn column, Class<?> typeHint) throws IOExce
return (T) readGeoPolygon();
case MultiPolygon:
return (T) readGeoMultiPolygon();
case MultiLineString:
return (T) readGeoPolygon();
case Ring:
return (T) readGeoRing();

case LineString:
return (T) readGeoRing();
case JSON: // experimental https://clickhouse.com/docs/en/sql-reference/data-types/newjson
if (jsonAsString) {
return (T) readString(input);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ public static void serializeData(OutputStream stream, Object value, ClickHouseCo
serializeTupleData(stream, value, GEO_POINT_TUPLE);
break;
case Ring:
case LineString:
value = value instanceof ClickHouseGeoRingValue ? ((ClickHouseGeoRingValue)value).getValue() : value;
serializeArrayData(stream, value, GEO_RING_ARRAY);
break;
case Polygon:
case MultiLineString:
value = value instanceof ClickHouseGeoPolygonValue ? ((ClickHouseGeoPolygonValue)value).getValue() : value;
serializeArrayData(stream, value, GEO_POLYGON_ARRAY);
break;
Expand Down
Loading
Loading