use of org.apache.flink.table.api.TableConfig in project flink by apache.
the class HBaseConnectorITCase method testTableSourceFieldOrder.
@Test
public void testTableSourceFieldOrder() throws Exception {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(4);
BatchTableEnvironment tableEnv = TableEnvironment.getTableEnvironment(env, new TableConfig());
HBaseTableSource hbaseTable = new HBaseTableSource(getConf(), TEST_TABLE);
// shuffle order of column registration
hbaseTable.addColumn(FAMILY2, F2COL1, String.class);
hbaseTable.addColumn(FAMILY3, F3COL1, Double.class);
hbaseTable.addColumn(FAMILY1, F1COL1, Integer.class);
hbaseTable.addColumn(FAMILY2, F2COL2, Long.class);
hbaseTable.addColumn(FAMILY3, F3COL2, Boolean.class);
hbaseTable.addColumn(FAMILY3, F3COL3, String.class);
tableEnv.registerTableSource("hTable", hbaseTable);
Table result = tableEnv.sql("SELECT * FROM hTable AS h");
DataSet<Row> resultSet = tableEnv.toDataSet(result, Row.class);
List<Row> results = resultSet.collect();
String expected = "Hello-1,100,1.01,false,Welt-1,10\n" + "Hello-2,200,2.02,true,Welt-2,20\n" + "Hello-3,300,3.03,false,Welt-3,30\n" + "null,400,4.04,true,Welt-4,40\n" + "Hello-5,500,5.05,false,Welt-5,50\n" + "Hello-6,600,6.06,true,Welt-6,60\n" + "Hello-7,700,7.07,false,Welt-7,70\n" + "null,800,8.08,true,Welt-8,80\n";
TestBaseUtils.compareResultAsText(results, expected);
}
use of org.apache.flink.table.api.TableConfig in project flink by apache.
the class BatchArrowPythonGroupWindowAggregateFunctionOperatorTest method getTestOperator.
@Override
public AbstractArrowPythonAggregateFunctionOperator getTestOperator(Configuration config, PythonFunctionInfo[] pandasAggregateFunctions, RowType inputRowType, RowType outputRowType, int[] groupingSet, int[] udafInputOffsets) {
RowType udfInputType = (RowType) Projection.of(udafInputOffsets).project(inputRowType);
RowType udfOutputType = (RowType) Projection.range(groupingSet.length, outputRowType.getFieldCount() - 2).project(outputRowType);
// SlidingWindow(10000L, 5000L)
return new PassThroughBatchArrowPythonGroupWindowAggregateFunctionOperator(config, pandasAggregateFunctions, inputRowType, udfInputType, udfOutputType, 3, 100000, 10000L, 5000L, new int[] { 0, 1 }, ProjectionCodeGenerator.generateProjection(CodeGeneratorContext.apply(new TableConfig()), "UdafInputProjection", inputRowType, udfInputType, udafInputOffsets), ProjectionCodeGenerator.generateProjection(CodeGeneratorContext.apply(new TableConfig()), "GroupKey", inputRowType, (RowType) Projection.of(groupingSet).project(inputRowType), groupingSet), ProjectionCodeGenerator.generateProjection(CodeGeneratorContext.apply(new TableConfig()), "GroupSet", inputRowType, (RowType) Projection.of(groupingSet).project(inputRowType), groupingSet));
}
use of org.apache.flink.table.api.TableConfig in project flink by apache.
the class StreamArrowPythonProcTimeBoundedRangeOperatorTest method getTestOperator.
@Override
public AbstractArrowPythonAggregateFunctionOperator getTestOperator(Configuration config, PythonFunctionInfo[] pandasAggregateFunctions, RowType inputType, RowType outputType, int[] groupingSet, int[] udafInputOffsets) {
RowType udfInputType = (RowType) Projection.of(udafInputOffsets).project(inputType);
RowType udfOutputType = (RowType) Projection.range(inputType.getFieldCount(), outputType.getFieldCount()).project(outputType);
return new PassThroughStreamArrowPythonProcTimeBoundedRangeOperator(config, pandasAggregateFunctions, inputType, udfInputType, udfOutputType, -1, 100L, ProjectionCodeGenerator.generateProjection(CodeGeneratorContext.apply(new TableConfig()), "UdafInputProjection", inputType, udfInputType, udafInputOffsets));
}
use of org.apache.flink.table.api.TableConfig in project flink by apache.
the class StreamArrowPythonProcTimeBoundedRowsOperatorTest method getTestOperator.
@Override
public AbstractArrowPythonAggregateFunctionOperator getTestOperator(Configuration config, PythonFunctionInfo[] pandasAggregateFunctions, RowType inputType, RowType outputType, int[] groupingSet, int[] udafInputOffsets) {
RowType udfInputType = (RowType) Projection.of(udafInputOffsets).project(inputType);
RowType udfOutputType = (RowType) Projection.range(inputType.getFieldCount(), outputType.getFieldCount()).project(outputType);
return new PassThroughStreamArrowPythonProcTimeBoundedRowsOperator(config, pandasAggregateFunctions, inputType, udfInputType, udfOutputType, 3, 1, ProjectionCodeGenerator.generateProjection(CodeGeneratorContext.apply(new TableConfig()), "UdafInputProjection", inputType, udfInputType, udafInputOffsets));
}
use of org.apache.flink.table.api.TableConfig in project flink by apache.
the class PassThroughPythonStreamGroupWindowAggregateOperator method createProjection.
private Projection<RowData, BinaryRowData> createProjection(String name, int[] fields) {
final RowType forwardedFieldType = new RowType(Arrays.stream(fields).mapToObj(i -> inputType.getFields().get(i)).collect(Collectors.toList()));
final GeneratedProjection generatedProjection = ProjectionCodeGenerator.generateProjection(CodeGeneratorContext.apply(new TableConfig()), name, inputType, forwardedFieldType, fields);
// noinspection unchecked
return generatedProjection.newInstance(Thread.currentThread().getContextClassLoader());
}
Aggregations