zstan commented on code in PR #1323:
URL: https://github.com/apache/ignite-3/pull/1323#discussion_r1021128880
##########
modules/table/src/test/java/org/apache/ignite/internal/table/MutableRowTupleAdapterTest.java:
##########
@@ -543,6 +546,102 @@ public void testKeyValueSerialization() throws Exception {
assertEquals(val1, val2);
}
+ @Test
+ void testTemporalValuesPrecisionConstraint() throws Exception {
+ SchemaDescriptor schemaDescriptor = new SchemaDescriptor(1,
+ new Column[]{new Column("key", NativeTypes.INT32, false)},
+ new Column[]{
+ new Column("time", NativeTypes.time(2), true),
+ new Column("datetime", NativeTypes.datetime(2), true),
+ new Column("timestamp", NativeTypes.timestamp(2), true)
+ }
+ );
+
+ Tuple tuple = Tuple.create().set("key", 1)
+ .set("time", LocalTime.of(1, 2, 3, 456_700_000))
+ .set("datetime", LocalDateTime.of(2022, 1, 2, 3, 4, 5,
678_900_000))
+ .set("timestamp", Instant.ofEpochSecond(123, 456_700_000));
+ Tuple expected = Tuple.create().set("key", 1)
+ .set("time", LocalTime.of(1, 2, 3, 450_000_000))
+ .set("datetime", LocalDateTime.of(2022, 1, 2, 3, 4, 5,
670_000_000))
+ .set("timestamp", Instant.ofEpochSecond(123, 450_000_000));
+
+ TupleMarshaller marshaller = new TupleMarshallerImpl(new
DummySchemaManagerImpl(schemaDescriptor));
+
+ Row row = new Row(schemaDescriptor, new
ByteBufferRow(marshaller.marshal(tuple).bytes()));
+
+ Tuple tuple1 = deserializeTuple(serializeTuple(TableRow.tuple(row)));
+
+ assertEquals(expected, tuple1);
+ }
+
+ @Test
+ void testVarlenValuesLengthConstraints() throws Exception {
+ SchemaDescriptor schemaDescriptor = new SchemaDescriptor(1,
+ new Column[]{new Column("key", NativeTypes.INT32, false)},
+ new Column[]{
+ new Column("string", NativeTypes.stringOf(5), true),
+ new Column("bytes", NativeTypes.blobOf(5), true),
+ }
+ );
+
+ TupleMarshaller marshaller = new TupleMarshallerImpl(new
DummySchemaManagerImpl(schemaDescriptor));
+
+ Tuple tuple1 = Tuple.create().set("key", 1)
+ .set("string", "abcef")
+ .set("bytes", new byte[]{1, 2, 3, 4, 5, 6, 7, 8});
+ Tuple tuple2 = Tuple.create().set("key", 1)
+ .set("string", "abcefghi")
+ .set("bytes", new byte[]{1, 2, 3, 4, 5});
+
+ assertThrowsWithCause(() -> marshaller.marshal(tuple1).bytes(),
InvalidTypeException.class, "Column's type mismatch");
+ assertThrowsWithCause(() -> marshaller.marshal(tuple2).bytes(),
InvalidTypeException.class, "Column's type mismatch");
+
+ Tuple expected = Tuple.create().set("key", 1)
+ .set("string", "abc")
+ .set("bytes", new byte[]{1, 2, 3});
+
+ Row row = new Row(schemaDescriptor, new
ByteBufferRow(marshaller.marshal(expected).bytes()));
+
+ assertEquals(expected,
deserializeTuple(serializeTuple(TableRow.tuple(row))));
+ }
+
+ @Test
+ void testDecimalPrecisionConstraint() throws Exception {
Review Comment:
Exception never will be thrown from here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]