@Romain
Here are the details-
SQL Gateway configs
#===================================================================
Gateway server properties
#===================================================================
server:
//The address that the gateway binds itself.
//bind-address: 127.0.0.1
//The address that should be used by clients to connect to the gateway.
address: flink-jobmanager
//The port that the client connects to.
port: 8083
//The jvm args for SQL gateway process,
// like -Xmx2018m -Xms1024m -XX:+UseConcMarkSweepGC -XX:+PrintGCDetails -XX:+PrintGCDateStamps …
jvm_args: “-Xmx2018m -Xms1024m”
UDF TableFunction
import org.apache.flink.table.annotation.DataTypeHint;
import org.apache.flink.table.annotation.FunctionHint;
import org.apache.flink.table.api.*;
import org.apache.flink.table.functions.TableFunction;
import org.apache.flink.types.Row;
@FunctionHint(output = @DataTypeHint(“ROW<word STRING, length INT>”))
public class SplitFunction extends TableFunction {
public void eval(String str) {
for (String s : str.split(" ")) {
// use collect(...) to emit a row
collect(Row.of(s, s.length()));
}
}
}
This is the query I run in HUE
SELECT * FROM LATERAL TABLE(splitfunction(‘hello world’)) AS T(word, length);
The same UDF function works fine in Flink SQL CLI and returns this-
But when I run that in Hue, I see this error instead-
500 Server Error: Internal Server Error for url: http://flink-jobmanager:8083/v1/sessions/b30ada21db368b06bb5f8f63893aff0d/statements {“errors”:[“Internal server error.”,"<Exception on server side:\ncom.ververica.flink.table.gateway.utils.SqlExecutionException: Invalid SQL statement.\n\tat
org.apache.flink.shaded.netty4.io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:918)\n\tat org.apache.flink.shaded.netty4.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)\n\tat java.base/java.lang.Thread.run(Unknown Source)\n
Caused by: org.apache.flink.table.api.ValidationException: SQL validation failed. From line 1, column 64 to line 1, column 75: List of column aliases must have same degree as table; table has 1 columns (‘f0’), whereas alias list has 2 columns\n\tat
org.apache.flink.table.planner.calcite.FlinkPlannerImpl.org$apache$flink$table$planner$calcite$FlinkPlannerImpl$$validate(FlinkPlannerImpl.scala:146)\n\tat
org.apache.flink.table.planner.calcite.FlinkPlannerImpl.org$apache$flink$table$planner$calcite$FlinkPlannerImpl$$validate(FlinkPlannerImpl.scala:141)\n\t… 54 more\n
Caused by: org.apache.calcite.sql.validate.SqlValidatorException: List of column aliases must have same degree as table; table has 1 columns (‘f0’), whereas alias list has 2 columns\n\tat
java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)\n\tat java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)\n\tat java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)\n\tat java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)\n\tat org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:457)\n\tat org.apache.calcite.runtime.Resources$ExInst.ex(Resources.java:550)\n\t… 69 more\n\nEnd of exception on server side>"]}
Please let me know what could be wrong?