Search in sources :

Example 1 with PythonScalarFunction

use of org.apache.flink.table.planner.runtime.utils.JavaUserDefinedScalarFunctions.PythonScalarFunction in project flink by apache.

the class PythonScalarFunctionOperatorTestBase method testPythonScalarFunctionOperatorIsChainedByDefault.

@Test
public void testPythonScalarFunctionOperatorIsChainedByDefault() {
    StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
    env.setParallelism(1);
    StreamTableEnvironment tEnv = createTableEnvironment(env);
    tEnv.getConfig().getConfiguration().setString(TaskManagerOptions.TASK_OFF_HEAP_MEMORY.key(), "80mb");
    tEnv.registerFunction("pyFunc", new PythonScalarFunction("pyFunc"));
    DataStream<Tuple2<Integer, Integer>> ds = env.fromElements(new Tuple2<>(1, 2));
    Table t = tEnv.fromDataStream(ds, $("a"), $("b")).select(call("pyFunc", $("a"), $("b")));
    // force generating the physical plan for the given table
    tEnv.toAppendStream(t, BasicTypeInfo.INT_TYPE_INFO);
    JobGraph jobGraph = env.getStreamGraph().getJobGraph();
    List<JobVertex> vertices = jobGraph.getVerticesSortedTopologicallyFromSources();
    Assert.assertEquals(1, vertices.size());
}
Also used : JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) Table(org.apache.flink.table.api.Table) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) PythonScalarFunction(org.apache.flink.table.planner.runtime.utils.JavaUserDefinedScalarFunctions.PythonScalarFunction) Tuple2(org.apache.flink.api.java.tuple.Tuple2) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) StreamTableEnvironment(org.apache.flink.table.api.bridge.java.StreamTableEnvironment) Test(org.junit.Test)

Aggregations

Tuple2 (org.apache.flink.api.java.tuple.Tuple2)1 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)1 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)1 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)1 Table (org.apache.flink.table.api.Table)1 StreamTableEnvironment (org.apache.flink.table.api.bridge.java.StreamTableEnvironment)1 PythonScalarFunction (org.apache.flink.table.planner.runtime.utils.JavaUserDefinedScalarFunctions.PythonScalarFunction)1 Test (org.junit.Test)1