use of org.apache.flink.table.types.DataType in project flink by apache.
the class KinesisDynamicTableSinkFactoryTest method testGoodTableSinkCopyForPartitionedTable.
@Test
public void testGoodTableSinkCopyForPartitionedTable() {
ResolvedSchema sinkSchema = defaultSinkSchema();
DataType physicalDataType = sinkSchema.toPhysicalRowDataType();
Map<String, String> sinkOptions = defaultTableOptions().build();
List<String> sinkPartitionKeys = Arrays.asList("name", "curr_id");
// Construct actual DynamicTableSink using FactoryUtil
KinesisDynamicSink actualSink = (KinesisDynamicSink) createTableSink(sinkSchema, sinkPartitionKeys, sinkOptions);
// Construct expected DynamicTableSink using factory under test
KinesisDynamicSink expectedSink = (KinesisDynamicSink) new KinesisDynamicSink.KinesisDynamicTableSinkBuilder().setConsumedDataType(physicalDataType).setStream(STREAM_NAME).setKinesisClientProperties(defaultProducerProperties()).setEncodingFormat(new TestFormatFactory.EncodingFormatMock(",")).setPartitioner(new RowDataFieldsKinesisPartitionKeyGenerator((RowType) physicalDataType.getLogicalType(), sinkPartitionKeys)).build();
Assertions.assertThat(actualSink).isEqualTo(expectedSink.copy());
Assertions.assertThat(expectedSink).isNotSameAs(expectedSink.copy());
}
use of org.apache.flink.table.types.DataType in project flink by apache.
the class KinesisDynamicTableSinkFactoryTest method testGoodTableSinkForPartitionedTable.
@Test
public void testGoodTableSinkForPartitionedTable() {
ResolvedSchema sinkSchema = defaultSinkSchema();
DataType physicalDataType = sinkSchema.toPhysicalRowDataType();
Map<String, String> sinkOptions = defaultTableOptions().build();
List<String> sinkPartitionKeys = Arrays.asList("name", "curr_id");
// Construct actual DynamicTableSink using FactoryUtil
KinesisDynamicSink actualSink = (KinesisDynamicSink) createTableSink(sinkSchema, sinkPartitionKeys, sinkOptions);
// Construct expected DynamicTableSink using factory under test
KinesisDynamicSink expectedSink = (KinesisDynamicSink) new KinesisDynamicSink.KinesisDynamicTableSinkBuilder().setConsumedDataType(physicalDataType).setStream(STREAM_NAME).setKinesisClientProperties(defaultProducerProperties()).setEncodingFormat(new TestFormatFactory.EncodingFormatMock(",")).setPartitioner(new RowDataFieldsKinesisPartitionKeyGenerator((RowType) physicalDataType.getLogicalType(), sinkPartitionKeys)).build();
// verify that the constructed DynamicTableSink is as expected
Assertions.assertThat(actualSink).isEqualTo(expectedSink);
// verify the produced sink
DynamicTableSink.SinkRuntimeProvider sinkFunctionProvider = actualSink.getSinkRuntimeProvider(new SinkRuntimeProviderContext(false));
Sink<RowData> sinkFunction = ((SinkV2Provider) sinkFunctionProvider).createSink();
Assertions.assertThat(sinkFunction).isInstanceOf(KinesisDataStreamsSink.class);
}
use of org.apache.flink.table.types.DataType in project flink by apache.
the class HBaseTableSchema method setRowKey.
/**
* Sets row key information in the table schema.
*
* @param rowKeyName the row key field name
* @param clazz the data type of the row key
*/
public void setRowKey(String rowKeyName, Class<?> clazz) {
Preconditions.checkNotNull(clazz, "row key class type");
DataType type = TypeConversions.fromLegacyInfoToDataType(TypeExtractor.getForClass(clazz));
setRowKey(rowKeyName, type);
}
use of org.apache.flink.table.types.DataType in project flink by apache.
the class HBaseTableSchema method getQualifierDataTypes.
public DataType[] getQualifierDataTypes(String family) {
Map<String, DataType> qualifierMap = familyMap.get(family);
if (qualifierMap == null) {
throw new IllegalArgumentException("Family " + family + " does not exist in schema.");
}
DataType[] dataTypes = new DataType[qualifierMap.size()];
int i = 0;
for (DataType dataType : qualifierMap.values()) {
dataTypes[i] = dataType;
i++;
}
return dataTypes;
}
use of org.apache.flink.table.types.DataType in project flink by apache.
the class HBaseSerdeTest method createHBaseSerde.
private HBaseSerde createHBaseSerde() {
DataType dataType = ROW(FIELD(ROW_KEY, INT()), FIELD(FAMILY1, ROW(FIELD(F1COL1, INT()))), FIELD(FAMILY2, ROW(FIELD(F2COL1, STRING()), FIELD(F2COL2, BIGINT()))), FIELD(FAMILY3, ROW(FIELD(F3COL1, DOUBLE()), FIELD(F3COL2, DataTypes.BOOLEAN()), FIELD(F3COL3, STRING()))));
HBaseTableSchema hbaseSchema = HBaseTableSchema.fromDataType(dataType);
return new HBaseSerde(hbaseSchema, "null");
}
Aggregations