use of org.apache.flink.table.types.logical.RowType 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.types.logical.RowType 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.types.logical.RowType 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());
}
use of org.apache.flink.table.types.logical.RowType in project flink by apache.
the class PythonTypeUtilsTest method testLogicalTypeToProto.
@Test
public void testLogicalTypeToProto() {
List<RowType.RowField> rowFields = new ArrayList<>();
rowFields.add(new RowType.RowField("f1", new BigIntType()));
RowType rowType = new RowType(rowFields);
FlinkFnApi.Schema.FieldType protoType = rowType.accept(new PythonTypeUtils.LogicalTypeToProtoTypeConverter());
FlinkFnApi.Schema schema = protoType.getRowSchema();
assertEquals(1, schema.getFieldsCount());
assertEquals("f1", schema.getFields(0).getName());
assertEquals(FlinkFnApi.Schema.TypeName.BIGINT, schema.getFields(0).getType().getTypeName());
}
use of org.apache.flink.table.types.logical.RowType in project flink by apache.
the class JdbcDynamicTableSource method getScanRuntimeProvider.
@Override
public ScanRuntimeProvider getScanRuntimeProvider(ScanContext runtimeProviderContext) {
final JdbcRowDataInputFormat.Builder builder = JdbcRowDataInputFormat.builder().setDrivername(options.getDriverName()).setDBUrl(options.getDbURL()).setUsername(options.getUsername().orElse(null)).setPassword(options.getPassword().orElse(null)).setAutoCommit(readOptions.getAutoCommit());
if (readOptions.getFetchSize() != 0) {
builder.setFetchSize(readOptions.getFetchSize());
}
final JdbcDialect dialect = options.getDialect();
String query = dialect.getSelectFromStatement(options.getTableName(), DataType.getFieldNames(physicalRowDataType).toArray(new String[0]), new String[0]);
if (readOptions.getPartitionColumnName().isPresent()) {
long lowerBound = readOptions.getPartitionLowerBound().get();
long upperBound = readOptions.getPartitionUpperBound().get();
int numPartitions = readOptions.getNumPartitions().get();
builder.setParametersProvider(new JdbcNumericBetweenParametersProvider(lowerBound, upperBound).ofBatchNum(numPartitions));
query += " WHERE " + dialect.quoteIdentifier(readOptions.getPartitionColumnName().get()) + " BETWEEN ? AND ?";
}
if (limit >= 0) {
query = String.format("%s %s", query, dialect.getLimitClause(limit));
}
builder.setQuery(query);
final RowType rowType = (RowType) physicalRowDataType.getLogicalType();
builder.setRowConverter(dialect.getRowConverter(rowType));
builder.setRowDataTypeInfo(runtimeProviderContext.createTypeInformation(physicalRowDataType));
return InputFormatProvider.of(builder.build());
}
Aggregations