diff --git a/ingester-protocol/pom.xml b/ingester-protocol/pom.xml index 47d3789..76b8418 100644 --- a/ingester-protocol/pom.xml +++ b/ingester-protocol/pom.xml @@ -27,7 +27,7 @@ ingester-protocol - 0.7.0 + 0.9.0 diff --git a/ingester-protocol/src/main/java/io/greptime/models/DataType.java b/ingester-protocol/src/main/java/io/greptime/models/DataType.java index 5c2b711..76041b8 100644 --- a/ingester-protocol/src/main/java/io/greptime/models/DataType.java +++ b/ingester-protocol/src/main/java/io/greptime/models/DataType.java @@ -50,6 +50,7 @@ public enum DataType { IntervalDayTime, IntervalMonthDayNano, Decimal128, + Json, ; public boolean isTimestamp() { @@ -115,6 +116,8 @@ public Common.ColumnDataType toProtoValue() { return Common.ColumnDataType.INTERVAL_MONTH_DAY_NANO; case Decimal128: return Common.ColumnDataType.DECIMAL128; + case Json: + return Common.ColumnDataType.JSON; default: return null; } diff --git a/ingester-protocol/src/main/java/io/greptime/models/RowHelper.java b/ingester-protocol/src/main/java/io/greptime/models/RowHelper.java index e00bb6e..ee7f512 100644 --- a/ingester-protocol/src/main/java/io/greptime/models/RowHelper.java +++ b/ingester-protocol/src/main/java/io/greptime/models/RowHelper.java @@ -74,6 +74,7 @@ public static void addValue( valueBuilder.setBinaryValue(UnsafeByteOperations.unsafeWrap((byte[]) value)); break; case STRING: + case JSON: valueBuilder.setStringValue((String) value); break; case DATE: diff --git a/ingester-protocol/src/test/java/io/greptime/WriteClientTest.java b/ingester-protocol/src/test/java/io/greptime/WriteClientTest.java index d4b4271..e1b4960 100644 --- a/ingester-protocol/src/test/java/io/greptime/WriteClientTest.java +++ b/ingester-protocol/src/test/java/io/greptime/WriteClientTest.java @@ -96,14 +96,15 @@ public void testWriteSuccess() throws ExecutionException, InterruptedException { .addField("field24", DataType.IntervalDayTime) .addField("field25", DataType.IntervalMonthDayNano) .addField("field26", DataType.Decimal128) + .addField("field27", DataType.Json) .build(); Table table = Table.from(schema); long ts = System.currentTimeMillis(); // spotless:off - Object[] row1 = new Object[]{"tag1", ts, 1, 2, 3, 4L, 5, 6, 7, 8L, 0.9F, 0.10D, true, new byte[0], 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23, 24L, new IntervalMonthDayNano(1, 2, 3), BigDecimal.valueOf(123.456)}; - Object[] row2 = new Object[]{"tag2", ts, 1, 2, 3, 4L, 5, 6, 7, 8L, 0.9F, 0.10D, true, new byte[0], 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23, 24L, new IntervalMonthDayNano(4, 5, 6), BigDecimal.valueOf(123.456)}; - Object[] row3 = new Object[]{"tag3", ts, 1, 2, 3, 4L, 5, 6, 7, 8L, 0.9F, 0.10D, true, new byte[0], 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23, 24L, new IntervalMonthDayNano(7, 8, 9), BigDecimal.valueOf(123.456)}; + Object[] row1 = new Object[]{"tag1", ts, 1, 2, 3, 4L, 5, 6, 7, 8L, 0.9F, 0.10D, true, new byte[0], 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23, 24L, new IntervalMonthDayNano(1, 2, 3), BigDecimal.valueOf(123.456), "{\"a\": 1}"}; + Object[] row2 = new Object[]{"tag2", ts, 1, 2, 3, 4L, 5, 6, 7, 8L, 0.9F, 0.10D, true, new byte[0], 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23, 24L, new IntervalMonthDayNano(4, 5, 6), BigDecimal.valueOf(123.456), "{\"b\": 2}"}; + Object[] row3 = new Object[]{"tag3", ts, 1, 2, 3, 4L, 5, 6, 7, 8L, 0.9F, 0.10D, true, new byte[0], 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23, 24L, new IntervalMonthDayNano(7, 8, 9), BigDecimal.valueOf(123.456), "{\"c\": 3}"}; // spotless:on table.addRow(row1);