org.apache.flink.table.factories.TableSinkFactory Java Examples

The following examples show how to use org.apache.flink.table.factories.TableSinkFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HiveTableFactory.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public TableSink createTableSink(TableSinkFactory.Context context) {
	CatalogTable table = checkNotNull(context.getTable());
	Preconditions.checkArgument(table instanceof CatalogTableImpl);

	boolean isGeneric = Boolean.parseBoolean(table.getProperties().get(CatalogConfig.IS_GENERIC));

	if (!isGeneric) {
		return new HiveTableSink(
				context.getConfiguration().get(
						HiveOptions.TABLE_EXEC_HIVE_FALLBACK_MAPRED_WRITER),
				context.isBounded(),
				new JobConf(hiveConf),
				context.getObjectIdentifier(),
				table);
	} else {
		return TableFactoryUtil.findAndCreateTableSink(context);
	}
}
 
Example #2
Source File: DatahubTableFactoryTest.java    From alibaba-flink-connectors with Apache License 2.0 5 votes vote down vote up
@Test
public void testRequiredProperties() {
	Map<String, String> properties = getBasicProperties();

	final TableSink<?> actual = TableFactoryService.find(TableSinkFactory.class, properties)
			.createTableSink(properties);

	assertTrue(actual instanceof DatahubTableSink);
}
 
Example #3
Source File: DatahubTableFactoryTest.java    From alibaba-flink-connectors with Apache License 2.0 5 votes vote down vote up
@Test
public void testSupportedProperties() {
	Map<String, String> properties = getBasicProperties();

	properties.put(CONNECTOR_BATCH_SIZE, "1");
	properties.put(CONNECTOR_BUFFER_SIZE, "1");
	properties.put(CONNECTOR_RETRY_TIMEOUT_IN_MILLS, "3");
	properties.put(CONNECTOR_MAX_RETRY_TIMES, "10");
	properties.put(CONNECTOR_BATCH_WRITE_TIMEOUT_IN_MILLS, "5");

	final TableSink<?> actual = TableFactoryService.find(TableSinkFactory.class, properties)
			.createTableSink(properties);

	assertTrue(actual instanceof DatahubTableSink);
}
 
Example #4
Source File: FileSystemTableFactory.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public TableSink<RowData> createTableSink(TableSinkFactory.Context context) {
	Configuration conf = new Configuration();
	context.getTable().getOptions().forEach(conf::setString);

	return new FileSystemTableSink(
			context.getObjectIdentifier(),
			context.isBounded(),
			context.getTable().getSchema(),
			getPath(conf),
			context.getTable().getPartitionKeys(),
			conf.get(PARTITION_DEFAULT_NAME),
			context.getTable().getOptions());
}
 
Example #5
Source File: TestTableSinkFactoryBase.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public StreamTableSink<Row> createTableSink(TableSinkFactory.Context context) {
	return new TestTableSink(
			context.getTable().getSchema(),
			context.getTable().getProperties().get(testProperty));
}