Skip to content

Commit 1489bcd

Browse files
committed
Update readme file
1 parent 628cfcb commit 1489bcd

File tree

5 files changed

+72
-37
lines changed

5 files changed

+72
-37
lines changed

README.md

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -132,43 +132,44 @@ Planned for a future release — a complete end-to-end example will be added onc
132132

133133
## Supported ClickHouse Types
134134

135-
| Java Type | ClickHouse Type | Supported | Serialize Method |
136-
|-----------------|-----------------|-----------|------------------------|
137-
| byte/Byte | Int8 || Serialize.writeInt8 |
138-
| short/Short | Int16 || Serialize.writeInt16 |
139-
| int/Integer | Int32 || Serialize.writeInt32 |
140-
| long/Long | Int64 || Serialize.writeInt64 |
141-
| BigInteger | Int128 || N/A |
142-
| BigInteger | Int256 || N/A |
143-
| byte/Byte | UInt8 || N/A |
144-
| short/Short | UInt16 || N/A |
145-
| int/Integer | UInt32 || N/A |
146-
| long/Long | UInt64 || N/A |
147-
| BigInteger | UInt128 || N/A |
148-
| BigInteger | UInt256 || N/A |
149-
| BigDecimal | BigDecimal || N/A |
150-
| BigDecimal | BigDecimal || N/A |
151-
| BigDecimal | BigDecimal || N/A |
152-
| BigDecimal | BigDecimal || N/A |
153-
| float/Float | Float || Serialize.writeFloat32 |
154-
| double/Double | Double || Serialize.writeFloat64 |
155-
| boolean/Boolean | Boolean || Serialize.writeBoolean |
156-
| String | String || Serialize.writeString |
157-
| String | FixedString || N/A |
158-
| LocalDate | Date || N/A |
159-
| LocalDate | Date32 || N/A |
160-
| LocalDateTime | DateTime || N/A |
161-
| LocalDateTime | DateTime64 || N/A |
162-
| int/Integer | Time || N/A |
163-
| long/Long | Time64 || N/A |
164-
| byte/Byte | Enum8 || Serialize.writeInt8 |
165-
| int/Integer | Enum16 || Serialize.writeInt16 |
166-
| String | JSON || N/A |
167-
| Array<Type> | Array<Type> || N/A |
168-
| Map<Type,Type> | Map<Type,Type> || N/A |
169-
| Tuple<Type,..> | Map<T1,T2,..> || N/A |
170-
| Map<Type,Type> | Map<Type,Type> || N/A |
171-
| Object | Variant || N/A |
135+
| Java Type | ClickHouse Type | Supported | Serialize Method |
136+
|-----------------|-----------------|-----------|-------------------------|
137+
| byte/Byte | Int8 || Serialize.writeInt8 |
138+
| short/Short | Int16 || Serialize.writeInt16 |
139+
| int/Integer | Int32 || Serialize.writeInt32 |
140+
| long/Long | Int64 || Serialize.writeInt64 |
141+
| BigInteger | Int128 || Serialize.writeInt124 |
142+
| BigInteger | Int256 || Serialize.writeInt256 |
143+
| byte/Byte | UInt8 || N/A |
144+
| short/Short | UInt16 || N/A |
145+
| int/Integer | UInt32 || N/A |
146+
| long/Long | UInt64 || N/A |
147+
| BigInteger | UInt128 || N/A |
148+
| BigInteger | UInt256 || N/A |
149+
| BigDecimal | Decimal || N/A |
150+
| BigDecimal | Decimal32 || N/A |
151+
| BigDecimal | Decimal64 || N/A |
152+
| BigDecimal | Decimal128 || N/A |
153+
| BigDecimal | Decimal256 || N/A |
154+
| float/Float | Float || Serialize.writeFloat32 |
155+
| double/Double | Double || Serialize.writeFloat64 |
156+
| boolean/Boolean | Boolean || Serialize.writeBoolean |
157+
| String | String || Serialize.writeString |
158+
| String | FixedString || N/A |
159+
| LocalDate | Date || N/A |
160+
| LocalDate | Date32 || N/A |
161+
| LocalDateTime | DateTime || N/A |
162+
| LocalDateTime | DateTime64 || N/A |
163+
| int/Integer | Time || N/A |
164+
| long/Long | Time64 || N/A |
165+
| byte/Byte | Enum8 || Serialize.writeInt8 |
166+
| int/Integer | Enum16 || Serialize.writeInt16 |
167+
| String | JSON || N/A |
168+
| Array<Type> | Array<Type> || N/A |
169+
| Map<Type,Type> | Map<Type,Type> || N/A |
170+
| Tuple<Type,..> | Map<T1,T2,..> || N/A |
171+
| Map<Type,Type> | Map<Type,Type> || N/A |
172+
| Object | Variant || N/A |
172173

173174
* For date operation need to provide ZoneId.
174175

flink-connector-clickhouse-1.17/src/test/java/org/apache/flink/connector/clickhouse/sink/ClickHouseSinkTests.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ void SimplePOJODataTest() throws Exception {
206206
"integerObject Int32," +
207207
"longPrimitive Int64," +
208208
"longObject Int64," +
209+
"bigInteger128 Int128," +
210+
"bigInteger256 Int256," +
209211
"floatPrimitive Float," +
210212
"floatObject Float," +
211213
"doublePrimitive Double," +
@@ -467,6 +469,8 @@ void SimplePOJODataTooManyPartsTest() throws Exception {
467469
"integerObject Int32," +
468470
"longPrimitive Int64," +
469471
"longObject Int64," +
472+
"bigInteger128 Int128," +
473+
"bigInteger256 Int256," +
470474
"floatPrimitive Float," +
471475
"floatObject Float," +
472476
"doublePrimitive Double," +

flink-connector-clickhouse-1.17/src/test/java/org/apache/flink/connector/clickhouse/sink/convertor/SimplePOJOConvertor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ public void instrument(OutputStream out, SimplePOJO input) throws IOException {
2323
Serialize.writeInt64(out, input.getLongPrimitive(), false, false, ClickHouseDataType.Int64, false, "longPrimitive");
2424
Serialize.writeInt64(out, input.getLongObject(), false, false, ClickHouseDataType.Int64, false, "longObject");
2525

26+
Serialize.writeInt128(out, input.getBigInteger128(), false, false, ClickHouseDataType.Int128, false, "bigInteger128");
27+
Serialize.writeInt256(out, input.getBigInteger256(), false, false, ClickHouseDataType.Int256, false, "bigInteger256");
28+
2629
Serialize.writeFloat32(out, input.getFloatPrimitive(), false, false, ClickHouseDataType.Float32, false, "floatPrimitive");
2730
Serialize.writeFloat32(out, input.getFloatObject(), false, false, ClickHouseDataType.Float32, false, "floatObject");
2831

flink-connector-clickhouse-1.17/src/test/java/org/apache/flink/connector/clickhouse/sink/pojo/SimplePOJO.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.apache.flink.connector.clickhouse.sink.pojo;
22

3+
import java.math.BigInteger;
4+
35
public class SimplePOJO {
46

57
private byte bytePrimitive;
@@ -25,6 +27,9 @@ public class SimplePOJO {
2527

2628
private String str;
2729

30+
private BigInteger bigInteger128;
31+
private BigInteger bigInteger256;
32+
2833
public SimplePOJO(int index) {
2934
this.bytePrimitive = Byte.MIN_VALUE;
3035
this.byteObject = Byte.MAX_VALUE;
@@ -48,6 +53,9 @@ public SimplePOJO(int index) {
4853
this.booleanObject = Boolean.FALSE;
4954

5055
this.str = "str" + longPrimitive;
56+
57+
this.bigInteger128 = BigInteger.valueOf(longPrimitive);
58+
this.bigInteger256 = BigInteger.valueOf(longPrimitive);
5159
}
5260

5361
public byte getBytePrimitive() {
@@ -103,4 +111,8 @@ public Double getDoubleObject() {
103111
public Boolean getBooleanObject() { return booleanObject; }
104112

105113
public String getStr() { return str; }
114+
115+
public BigInteger getBigInteger128() { return bigInteger128; }
116+
117+
public BigInteger getBigInteger256() { return bigInteger256; }
106118
}

flink-connector-clickhouse-base/src/main/java/com/clickhouse/utils/Serialize.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.io.IOException;
1111
import java.io.OutputStream;
1212
import java.lang.reflect.Method;
13+
import java.math.BigInteger;
1314
import java.time.LocalDate;
1415
import java.time.ZoneId;
1516
import java.time.ZonedDateTime;
@@ -168,6 +169,20 @@ public static void writeInt64(OutputStream out, Long value, boolean defaultsSupp
168169
}
169170
}
170171

172+
// Int128
173+
public static void writeInt128(OutputStream out, BigInteger value, boolean defaultsSupport, boolean isNullable, ClickHouseDataType dataType, boolean hasDefault, String column) throws IOException {
174+
if (writeValuePreamble(out, defaultsSupport, isNullable, dataType, hasDefault, column, value)) {
175+
BinaryStreamUtils.writeInt128(out, SerializerUtils.convertToBigInteger(value));
176+
}
177+
}
178+
179+
// Int256
180+
public static void writeInt256(OutputStream out, BigInteger value, boolean defaultsSupport, boolean isNullable, ClickHouseDataType dataType, boolean hasDefault, String column) throws IOException {
181+
if (writeValuePreamble(out, defaultsSupport, isNullable, dataType, hasDefault, column, value)) {
182+
BinaryStreamUtils.writeInt256(out, SerializerUtils.convertToBigInteger(value));
183+
}
184+
}
185+
171186
// Float32
172187
public static void writeFloat32(OutputStream out, Float value, boolean defaultsSupport, boolean isNullable, ClickHouseDataType dataType, boolean hasDefault, String column) throws IOException {
173188
if (writeValuePreamble(out, defaultsSupport, isNullable, dataType, hasDefault, column, value)) {

0 commit comments

Comments
 (0)