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 @@ -462,6 +462,12 @@ private static void serializeMapData(OutputStream stream, Object value, ClickHou
}

private static void serializePrimitiveData(OutputStream stream, Object value, ClickHouseColumn column) throws IOException {
//Handle null values
if (value == null && column.isNullable()) {//Only nullable columns can have null values
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it null and not nullable should we throw an exception like data is not valid

Copy link
Contributor Author

@Paultagoras Paultagoras Feb 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered doing that, but apparently there's logic for some of the data types that would then fail (like the new dynamic stuff) 🫠

BinaryStreamUtils.writeNull(stream);
return;
}

//Serialize the value to the stream based on the type
switch (column.getDataType()) {
case Int8:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class SamplePOJO {
private byte byteValue;
private Byte boxedByte;
private int int8;
private Integer int8_null;
private int int8_default;
private int int16;
private Short boxedShort;
Expand Down Expand Up @@ -100,6 +101,7 @@ public SamplePOJO() {
byteValue = (byte) random.nextInt();
boxedByte = (byte) random.nextInt();
int8 = random.nextInt(128);
int8_null = null;
int16 = random.nextInt(32768);
boxedShort = (short) random.nextInt();
int32 = random.nextInt();
Expand Down Expand Up @@ -175,7 +177,7 @@ public SamplePOJO() {
}

array = Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");
tuple = Arrays.asList(uint64, int32, string);
tuple = Arrays.asList(uint64, int32, string, null);
map = new HashMap<>();
for (int i = 0; i < 10; i++) {
map.put(String.valueOf((char) ('a' + i)), i + 1);
Expand Down Expand Up @@ -278,6 +280,14 @@ public void setInt8(int int8) {
this.int8 = int8;
}

public Integer getInt8_null() {
return int8_null;
}

public void setInt8_null(Integer int8_null) {
this.int8_null = int8_null;
}

public int getInt8Default() {
return int8_default;
}
Expand Down Expand Up @@ -721,6 +731,7 @@ public static String generateTableCreateSQL(String tableName) {
return "CREATE TABLE " + tableName + " (" +
"byteValue Int8," +
"int8 Int8, " +
"int8_null Nullable(Int8), " +
"boxedByte Int8, " +
"int8_default Int8 DEFAULT 0, " +
"int16 Int16, " +
Expand Down Expand Up @@ -770,7 +781,7 @@ public static String generateTableCreateSQL(String tableName) {
"ipv4 IPv4, " +
"ipv6 IPv6, " +
"array Array(String), " +
"tuple Tuple(UInt64, Int32, String), " +
"tuple Tuple(UInt64, Int32, String, Nullable(Int16)), " +
"map Map(String, Int32), " +
"nested Nested (innerInt Int32, innerString String, " +
"innerNullableInt Nullable(Int32)), " +
Expand Down
Loading