Search in sources :

Example 11 with GenericArrayData

use of org.apache.flink.table.data.GenericArrayData in project flink by apache.

the class TableAssertionTest method testAssertRowDataWithConversion.

@Test
void testAssertRowDataWithConversion() {
    DataType dataType = ROW(FIELD("a", INT()), FIELD("b", STRING()), FIELD("c", ARRAY(BOOLEAN().notNull())));
    GenericRowData genericRowData = GenericRowData.of(10, StringData.fromString("my string"), new GenericArrayData(new boolean[] { true, false }));
    BinaryRowData binaryRowData = new RowDataSerializer((RowType) dataType.getLogicalType()).toBinaryRow(genericRowData);
    Row row = Row.of(10, "my string", new Boolean[] { true, false });
    // Test equality with RowData
    assertThat(binaryRowData).asGeneric(dataType).isEqualTo(genericRowData).isEqualTo(binaryRowData.copy());
    assertThatRows(binaryRowData).asGeneric(dataType).containsOnly(genericRowData).containsOnly(binaryRowData);
    // Test equality with Row
    assertThat(binaryRowData).asRow(dataType).isEqualTo(row);
    assertThatRows(binaryRowData).asRows(dataType).containsOnly(row);
}
Also used : GenericArrayData(org.apache.flink.table.data.GenericArrayData) BinaryRowData(org.apache.flink.table.data.binary.BinaryRowData) DataType(org.apache.flink.table.types.DataType) GenericRowData(org.apache.flink.table.data.GenericRowData) RowType(org.apache.flink.table.types.logical.RowType) Row(org.apache.flink.types.Row) RowDataSerializer(org.apache.flink.table.runtime.typeutils.RowDataSerializer) Test(org.junit.jupiter.api.Test)

Aggregations

GenericArrayData (org.apache.flink.table.data.GenericArrayData)11 GenericRowData (org.apache.flink.table.data.GenericRowData)7 StringData (org.apache.flink.table.data.StringData)6 ArrayType (org.apache.flink.table.types.logical.ArrayType)6 RowType (org.apache.flink.table.types.logical.RowType)6 LogicalType (org.apache.flink.table.types.logical.LogicalType)5 Array (java.lang.reflect.Array)4 RowData (org.apache.flink.table.data.RowData)4 LogicalTypeUtils (org.apache.flink.table.types.logical.utils.LogicalTypeUtils)4 Serializable (java.io.Serializable)3 LocalTime (java.time.LocalTime)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Internal (org.apache.flink.annotation.Internal)3 DecimalData (org.apache.flink.table.data.DecimalData)3 GenericMapData (org.apache.flink.table.data.GenericMapData)3 TimestampData (org.apache.flink.table.data.TimestampData)3 DecimalType (org.apache.flink.table.types.logical.DecimalType)3 IOException (java.io.IOException)2 BigDecimal (java.math.BigDecimal)2