Test utilities for Apache Flink's Table API and SQL ecosystem enabling robust testing of table operations and data transformations.
—
Comprehensive assertions for Flink's DataType and LogicalType system with validation of type properties, conversions, and hierarchies. These assertions enable thorough testing of Flink's rich type system including complex nested types.
Assertions for Flink's DataType objects that combine logical types with conversion class information.
public class DataTypeAssert extends AbstractAssert<DataTypeAssert, DataType> {
public DataTypeAssert(DataType dataType);
// Type navigation
public LogicalTypeAssert asLogicalType();
public ClassAssert getConversionClass();
public ListAssert<DataType> getChildren();
// Type validation
public DataTypeAssert hasConversionClass(Class<?> clazz);
public DataTypeAssert hasLogicalType(LogicalType logicalType);
public DataTypeAssert isNullable();
public DataTypeAssert isNotNullable();
}import static org.apache.flink.table.test.TableAssertions.assertThat;
import static org.apache.flink.table.test.DataTypeConditions.*;
import org.apache.flink.table.types.DataType;
import org.apache.flink.table.api.DataTypes;
// Basic type validation
DataType stringType = DataTypes.STRING();
assertThat(stringType)
.isNullable()
.hasConversionClass(String.class);
// Complex type validation
DataType rowType = DataTypes.ROW(
DataTypes.FIELD("id", DataTypes.INT()),
DataTypes.FIELD("name", DataTypes.STRING())
);
assertThat(rowType)
.isNullable()
.getChildren()
.hasSize(2);
// Using conditions
assertThat(stringType)
.is(NULLABLE)
.is(not(INTERNAL));
// Logical type navigation
assertThat(stringType)
.asLogicalType()
.isNullable()
.supportsInputConversion(String.class);Assertions for Flink's LogicalType objects that define the structure and semantics of data types.
public class LogicalTypeAssert extends AbstractAssert<LogicalTypeAssert, LogicalType> {
public LogicalTypeAssert(LogicalType logicalType);
// Nullability
public LogicalTypeAssert isNullable();
public LogicalTypeAssert isNotNullable();
// Type hierarchy
public ListAssert<LogicalType> getChildren();
public LogicalTypeAssert hasExactlyChildren(LogicalType... children);
// String representations
public LogicalTypeAssert hasSerializableString(String serializableString);
public LogicalTypeAssert hasNoSerializableString();
public LogicalTypeAssert hasSummaryString(String summaryString);
// Conversion support
public LogicalTypeAssert supportsInputConversion(Class<?> clazz);
public LogicalTypeAssert doesNotSupportInputConversion(Class<?> clazz);
public LogicalTypeAssert supportsOutputConversion(Class<?> clazz);
public LogicalTypeAssert doesNotSupportOutputConversion(Class<?> clazz);
// Serialization
public LogicalTypeAssert isJavaSerializable();
// Decimal type specific
public LogicalTypeAssert isDecimalType();
public LogicalTypeAssert hasPrecision(int precision);
public LogicalTypeAssert hasScale(int scale);
public LogicalTypeAssert hasPrecisionAndScale(int precision, int scale);
}import org.apache.flink.table.types.logical.*;
// Basic logical type validation
LogicalType intType = new IntType();
assertThat(intType)
.isNullable()
.supportsInputConversion(Integer.class)
.supportsOutputConversion(Integer.class)
.isJavaSerializable();
// Complex type validation
LogicalType rowType = RowType.of(
new IntType(false), // non-nullable int
new VarCharType(255) // varchar(255)
);
assertThat(rowType)
.isNullable()
.getChildren()
.hasSize(2);
assertThat(rowType)
.hasExactlyChildren(
new IntType(false),
new VarCharType(255)
);
// Decimal type validation
LogicalType decimalType = new DecimalType(10, 2);
assertThat(decimalType)
.isDecimalType()
.hasPrecision(10)
.hasScale(2)
.hasPrecisionAndScale(10, 2);
// Conversion validation
assertThat(new VarCharType())
.supportsInputConversion(String.class)
.supportsInputConversion(byte[].class)
.doesNotSupportInputConversion(Integer.class);
// String representation validation
assertThat(new IntType())
.hasSummaryString("INT")
.hasSerializableString("INT");Pre-defined conditions for common type property tests that can be used with AssertJ's condition assertions.
public class DataTypeConditions {
public static final Condition<DataType> NULLABLE;
public static final Condition<DataType> INTERNAL;
}public class LogicalTypeConditions {
public static final Condition<LogicalType> NULLABLE;
}import static org.apache.flink.table.test.DataTypeConditions.*;
import static org.apache.flink.table.test.LogicalTypeConditions.*;
import static org.assertj.core.api.Assertions.not;
DataType nullableString = DataTypes.STRING();
DataType nonNullableInt = DataTypes.INT().notNull();
// Using DataType conditions
assertThat(nullableString).is(NULLABLE);
assertThat(nonNullableInt).is(not(NULLABLE));
assertThat(nullableString).is(not(INTERNAL));
// Using LogicalType conditions
assertThat(nullableString.getLogicalType()).is(NULLABLE);
assertThat(nonNullableInt.getLogicalType()).is(not(NULLABLE));
// Combining with other assertions
assertThat(Arrays.asList(nullableString, nonNullableInt))
.hasSize(2)
.allSatisfy(type -> assertThat(type).hasConversionClass(Object.class))
.anySatisfy(type -> assertThat(type).is(NULLABLE));// Test deeply nested types
DataType complexType = DataTypes.ROW(
DataTypes.FIELD("users", DataTypes.ARRAY(
DataTypes.ROW(
DataTypes.FIELD("id", DataTypes.BIGINT()),
DataTypes.FIELD("profile", DataTypes.MAP(
DataTypes.STRING(),
DataTypes.STRING()
))
)
))
);
assertThat(complexType)
.isNullable()
.getChildren()
.hasSize(1)
.first()
.asInstanceOf(InstanceOfAssertFactories.type(DataType.class))
.satisfies(arrayType -> {
assertThat(arrayType.getLogicalType())
.isInstanceOf(ArrayType.class);
assertThat(arrayType.getChildren())
.hasSize(1)
.first()
.asInstanceOf(InstanceOfAssertFactories.type(DataType.class))
.satisfies(elementType -> {
assertThat(elementType.getChildren()).hasSize(2);
});
});// Test type compatibility
LogicalType sourceType = new VarCharType(100);
LogicalType targetType = new VarCharType(200);
// Both should support string conversion
assertThat(sourceType)
.supportsInputConversion(String.class)
.supportsOutputConversion(String.class);
assertThat(targetType)
.supportsInputConversion(String.class)
.supportsOutputConversion(String.class);
// Test serialization compatibility
assertThat(sourceType)
.isJavaSerializable();Install with Tessl CLI
npx tessl i tessl/maven-org-apache-flink--flink-table-test-utils