use of org.apache.flink.table.sinks.CsvTableSink in project flink by apache.
the class TpcdsTestProgram method main.
public static void main(String[] args) throws Exception {
ParameterTool params = ParameterTool.fromArgs(args);
String sourceTablePath = params.getRequired("sourceTablePath");
String queryPath = params.getRequired("queryPath");
String sinkTablePath = params.getRequired("sinkTablePath");
Boolean useTableStats = params.getBoolean("useTableStats");
TableEnvironment tableEnvironment = prepareTableEnv(sourceTablePath, useTableStats);
// execute TPC-DS queries
for (String queryId : TPCDS_QUERIES) {
System.out.println("[INFO]Run TPC-DS query " + queryId + " ...");
String queryName = QUERY_PREFIX + queryId + QUERY_SUFFIX;
String queryFilePath = queryPath + FILE_SEPARATOR + queryName;
String queryString = loadFile2String(queryFilePath);
Table resultTable = tableEnvironment.sqlQuery(queryString);
// register sink table
String sinkTableName = QUERY_PREFIX + queryId + "_sinkTable";
((TableEnvironmentInternal) tableEnvironment).registerTableSinkInternal(sinkTableName, new CsvTableSink(sinkTablePath + FILE_SEPARATOR + queryId + RESULT_SUFFIX, COL_DELIMITER, 1, FileSystem.WriteMode.OVERWRITE, resultTable.getSchema().getFieldNames(), resultTable.getSchema().getFieldDataTypes()));
TableResult tableResult = resultTable.executeInsert(sinkTableName);
// wait job finish
tableResult.getJobClient().get().getJobExecutionResult().get();
System.out.println("[INFO]Run TPC-DS query " + queryId + " success.");
}
}
use of org.apache.flink.table.sinks.CsvTableSink in project flink by apache.
the class BatchSQLTestProgram method main.
public static void main(String[] args) throws Exception {
ParameterTool params = ParameterTool.fromArgs(args);
String outputPath = params.getRequired("outputPath");
String sqlStatement = params.getRequired("sqlStatement");
TableEnvironment tEnv = TableEnvironment.create(EnvironmentSettings.inBatchMode());
((TableEnvironmentInternal) tEnv).registerTableSourceInternal("table1", new GeneratorTableSource(10, 100, 60, 0));
((TableEnvironmentInternal) tEnv).registerTableSourceInternal("table2", new GeneratorTableSource(5, 0.2f, 60, 5));
((TableEnvironmentInternal) tEnv).registerTableSinkInternal("sinkTable", new CsvTableSink(outputPath).configure(new String[] { "f0", "f1" }, new TypeInformation[] { Types.INT, Types.SQL_TIMESTAMP }));
TableResult result = tEnv.executeSql(sqlStatement);
// wait job finish
result.getJobClient().get().getJobExecutionResult().get();
}
use of org.apache.flink.table.sinks.CsvTableSink in project flink by apache.
the class CsvTableSinkFactoryTest method testAppendTableSinkFactory.
@Test
public void testAppendTableSinkFactory() {
DescriptorProperties descriptor = createDescriptor(testingSchema);
descriptor.putString("update-mode", "append");
TableSink sink = createTableSink(descriptor);
assertTrue(sink instanceof CsvTableSink);
assertEquals(testingSchema.toRowDataType(), sink.getConsumedDataType());
}
use of org.apache.flink.table.sinks.CsvTableSink in project flink by apache.
the class CsvTableSinkFactoryTest method testBatchTableSinkFactory.
@Test
public void testBatchTableSinkFactory() {
DescriptorProperties descriptor = createDescriptor(testingSchema);
TableSink sink = createTableSink(descriptor);
assertTrue(sink instanceof CsvTableSink);
assertEquals(testingSchema.toRowDataType(), sink.getConsumedDataType());
}
Aggregations