Search in sources :

Example 1 with PythonTypeUtils

use of org.apache.flink.table.runtime.typeutils.PythonTypeUtils in project flink by apache.

the class EmbeddedPythonScalarFunctionOperator method open.

@SuppressWarnings("unchecked")
@Override
public void open() throws Exception {
    isOneArg = udfInputOffsets.length == 1;
    isOneFieldResult = udfOutputType.getFieldCount() == 1;
    super.open();
    rowDataWrapper = new StreamRecordRowDataWrappingCollector(output);
    reuseResultRowData = new GenericRowData(udfOutputType.getFieldCount());
    RowType userDefinedFunctionInputType = new RowType(Arrays.stream(udfInputOffsets).mapToObj(i -> inputType.getFields().get(i)).collect(Collectors.toList()));
    userDefinedFunctionInputConverters = userDefinedFunctionInputType.getFields().stream().map(RowType.RowField::getType).map(PythonTypeUtils::toDataConverter).toArray(PythonTypeUtils.DataConverter[]::new);
    userDefinedFunctionInputArgs = new Object[udfInputOffsets.length];
    userDefinedFunctionOutputConverters = udfOutputType.getFields().stream().map(RowType.RowField::getType).map(PythonTypeUtils::toDataConverter).toArray(PythonTypeUtils.DataConverter[]::new);
    if (forwardedFieldGeneratedProjection != null) {
        forwardedFieldProjection = forwardedFieldGeneratedProjection.newInstance(Thread.currentThread().getContextClassLoader());
    }
}
Also used : StreamRecordRowDataWrappingCollector(org.apache.flink.table.runtime.operators.python.utils.StreamRecordRowDataWrappingCollector) GenericRowData(org.apache.flink.table.data.GenericRowData) RowType(org.apache.flink.table.types.logical.RowType) PythonTypeUtils(org.apache.flink.table.runtime.typeutils.PythonTypeUtils)

Aggregations

GenericRowData (org.apache.flink.table.data.GenericRowData)1 StreamRecordRowDataWrappingCollector (org.apache.flink.table.runtime.operators.python.utils.StreamRecordRowDataWrappingCollector)1 PythonTypeUtils (org.apache.flink.table.runtime.typeutils.PythonTypeUtils)1 RowType (org.apache.flink.table.types.logical.RowType)1