From 87ba2514677dcc23a9e394a5203e2ea42e112d13 Mon Sep 17 00:00:00 2001 From: Timo Walther Date: Tue, 26 Nov 2024 07:04:51 +0100 Subject: [PATCH] Feedback addressed --- .../docs/dev/table/functions/udfs.md | 24 ++++++++----- docs/content.zh/docs/dev/table/procedures.md | 33 +++++++++-------- docs/content/docs/dev/table/functions/udfs.md | 24 ++++++++----- docs/content/docs/dev/table/procedures.md | 35 +++++++++++-------- .../TestProcedureCatalogFactory.java | 2 +- 5 files changed, 72 insertions(+), 46 deletions(-) diff --git a/docs/content.zh/docs/dev/table/functions/udfs.md b/docs/content.zh/docs/dev/table/functions/udfs.md index 44897502f1e32..ff8d98d823002 100644 --- a/docs/content.zh/docs/dev/table/functions/udfs.md +++ b/docs/content.zh/docs/dev/table/functions/udfs.md @@ -661,8 +661,10 @@ public static class NamedParameterClass extends ScalarFunction { // 使用 @ArgumentHint 注解指定参数的名称,参数类型,以及该参数是否是必需的参数 @FunctionHint( - argument = {@ArgumentHint(name = "param1", isOptional = false, type = @DataTypeHint("STRING")), - @ArgumentHint(name = "param2", isOptional = true, type = @DataTypeHint("INTEGER"))} + arguments = { + @ArgumentHint(name = "param1", isOptional = false, type = @DataTypeHint("STRING")), + @ArgumentHint(name = "param2", isOptional = true, type = @DataTypeHint("INTEGER")) + } ) public String eval(String s1, Integer s2) { return s1 + ", " + s2; @@ -679,8 +681,10 @@ class NamedParameterClass extends ScalarFunction { // 使用 @ArgumentHint 注解指定参数的名称,参数类型,以及是否是必需的参数 @FunctionHint( - argument = Array(new ArgumentHint(name = "param1", isOptional = false, `type` = new DataTypeHint("STRING")), - new ArgumentHint(name = "param2", isOptional = true, `type` = new DataTypeHint("INTEGER"))) + arguments = Array( + new ArgumentHint(name = "param1", isOptional = false, `type` = new DataTypeHint("STRING")), + new ArgumentHint(name = "param2", isOptional = true, `type` = new DataTypeHint("INTEGER")) + ) ) def eval(s1: String, s2: Int): String = { s1 + ", " + s2 @@ -700,8 +704,10 @@ import org.apache.flink.table.functions.ScalarFunction; // 使用 @ArgumentHint 注解指定参数的名称,参数类型,以及是否是必需的参数 @FunctionHint( - argument = {@ArgumentHint(name = "param1", isOptional = false, type = @DataTypeHint("STRING")), - @ArgumentHint(name = "param2", isOptional = true, type = @DataTypeHint("INTEGER"))} + arguments = { + @ArgumentHint(name = "param1", isOptional = false, type = @DataTypeHint("STRING")), + @ArgumentHint(name = "param2", isOptional = true, type = @DataTypeHint("INTEGER")) + } ) public static class NamedParameterClass extends ScalarFunction { @@ -718,8 +724,10 @@ import org.apache.flink.table.functions.ScalarFunction; // 使用 @ArgumentHint 注解指定参数的名称,参数类型,以及是否是必需的参数 @FunctionHint( - argument = Array(new ArgumentHint(name = "param1", isOptional = false, `type` = new DataTypeHint("STRING")), - new ArgumentHint(name = "param2", isOptional = true, `type` = new DataTypeHint("INTEGER"))) + arguments = Array( + new ArgumentHint(name = "param1", isOptional = false, `type` = new DataTypeHint("STRING")), + new ArgumentHint(name = "param2", isOptional = true, `type` = new DataTypeHint("INTEGER")) + ) ) class NamedParameterClass extends ScalarFunction { diff --git a/docs/content.zh/docs/dev/table/procedures.md b/docs/content.zh/docs/dev/table/procedures.md index d7efa89b31fe8..964a89af1ac28 100644 --- a/docs/content.zh/docs/dev/table/procedures.md +++ b/docs/content.zh/docs/dev/table/procedures.md @@ -397,13 +397,15 @@ import org.apache.flink.types.Row; public static class NamedParameterProcedure extends Procedure { - @ProcedureHint( - argument = {@ArgumentHint(name = "param1", type = @DataTypeHint("INTEGER"), isOptional = false), - @ArgumentHint(name = "param2", type = @DataTypeHint("INTEGER"), isOptional = true)} - ) - public @DataTypeHint("INT") Integer[] call(ProcedureContext context, Integer a, Integer b) { - return new Integer[] {a + (b == null ? 0 : b)}; - } + @ProcedureHint( + arguments = { + @ArgumentHint(name = "param1", type = @DataTypeHint("INTEGER"), isOptional = false), + @ArgumentHint(name = "param2", type = @DataTypeHint("INTEGER"), isOptional = true) + } + ) + public @DataTypeHint("INT") Integer[] call(ProcedureContext context, Integer a, Integer b) { + return new Integer[] {a + (b == null ? 0 : b)}; + } } ``` {{< /tab >}} @@ -418,15 +420,16 @@ import org.apache.flink.types.Row import scala.annotation.varargs class NamedParameterProcedure extends Procedure { + @ProcedureHint( - argument = Array( + arguments = Array( new ArgumentHint(name = "param1", `type` = new DataTypeHint("INTEGER"), isOptional = false), new ArgumentHint(name = "param2", `type` = new DataTypeHint("INTEGER"), isOptional = true) ) ) - def call(context: ProcedureContext, a: Integer, b: Integer): Array[Integer] = { - Array(a + (if (b == null) 0 else b)) - } + def call(context: ProcedureContext, a: Integer, b: Integer): Array[Integer] = { + Array(a + (if (b == null) 0 else b)) + } } ``` {{< /tab >}} @@ -444,8 +447,10 @@ import org.apache.flink.table.procedures.Procedure; import org.apache.flink.types.Row; @ProcedureHint( - argument = {@ArgumentHint(name = "param1", type = @DataTypeHint("INTEGER"), isOptional = false), - @ArgumentHint(name = "param2", type = @DataTypeHint("INTEGER"), isOptional = true)} + arguments = { + @ArgumentHint(name = "param1", type = @DataTypeHint("INTEGER"), isOptional = false), + @ArgumentHint(name = "param2", type = @DataTypeHint("INTEGER"), isOptional = true) + } ) public static class NamedParameterProcedure extends Procedure { @@ -466,7 +471,7 @@ import org.apache.flink.types.Row import scala.annotation.varargs @ProcedureHint( - argument = Array( + arguments = Array( new ArgumentHint(name = "param1", `type` = new DataTypeHint("INTEGER"), isOptional = false), new ArgumentHint(name = "param2", `type` = new DataTypeHint("INTEGER"), isOptional = true) ) diff --git a/docs/content/docs/dev/table/functions/udfs.md b/docs/content/docs/dev/table/functions/udfs.md index a4d244aa7db5b..3c6c28582da27 100644 --- a/docs/content/docs/dev/table/functions/udfs.md +++ b/docs/content/docs/dev/table/functions/udfs.md @@ -671,8 +671,10 @@ public static class NamedParameterClass extends ScalarFunction { // Use the @ArgumentHint annotation to specify the name, type, and whether a parameter is required. @FunctionHint( - argument = {@ArgumentHint(name = "param1", isOptional = false, type = @DataTypeHint("STRING")), - @ArgumentHint(name = "param2", isOptional = true, type = @DataTypeHint("INTEGER"))} + arguments = { + @ArgumentHint(name = "param1", isOptional = false, type = @DataTypeHint("STRING")), + @ArgumentHint(name = "param2", isOptional = true, type = @DataTypeHint("INTEGER")) + } ) public String eval(String s1, Integer s2) { return s1 + ", " + s2; @@ -689,8 +691,10 @@ class NamedParameterClass extends ScalarFunction { // Use the @ArgumentHint annotation to specify the name, type, and whether a parameter is required. @FunctionHint( - argument = Array(new ArgumentHint(name = "param1", isOptional = false, `type` = new DataTypeHint("STRING")), - new ArgumentHint(name = "param2", isOptional = true, `type` = new DataTypeHint("INTEGER"))) + arguments = Array( + new ArgumentHint(name = "param1", isOptional = false, `type` = new DataTypeHint("STRING")), + new ArgumentHint(name = "param2", isOptional = true, `type` = new DataTypeHint("INTEGER")) + ) ) def eval(s1: String, s2: Int): String = { s1 + ", " + s2 @@ -710,8 +714,10 @@ import org.apache.flink.table.functions.ScalarFunction; // Use the @ArgumentHint annotation to specify the name, type, and whether a parameter is required. @FunctionHint( - argument = {@ArgumentHint(name = "param1", isOptional = false, type = @DataTypeHint("STRING")), - @ArgumentHint(name = "param2", isOptional = true, type = @DataTypeHint("INTEGER"))} + arguments = { + @ArgumentHint(name = "param1", isOptional = false, type = @DataTypeHint("STRING")), + @ArgumentHint(name = "param2", isOptional = true, type = @DataTypeHint("INTEGER")) + } ) public static class NamedParameterClass extends ScalarFunction { @@ -728,8 +734,10 @@ import org.apache.flink.table.functions.ScalarFunction; // Use the @ArgumentHint annotation to specify the name, type, and whether a parameter is required. @FunctionHint( - argument = Array(new ArgumentHint(name = "param1", isOptional = false, `type` = new DataTypeHint("STRING")), - new ArgumentHint(name = "param2", isOptional = true, `type` = new DataTypeHint("INTEGER"))) + arguments = Array( + new ArgumentHint(name = "param1", isOptional = false, `type` = new DataTypeHint("STRING")), + new ArgumentHint(name = "param2", isOptional = true, `type` = new DataTypeHint("INTEGER")) + ) ) class NamedParameterClass extends ScalarFunction { diff --git a/docs/content/docs/dev/table/procedures.md b/docs/content/docs/dev/table/procedures.md index fbdbd469121f1..9515e89563f30 100644 --- a/docs/content/docs/dev/table/procedures.md +++ b/docs/content/docs/dev/table/procedures.md @@ -395,14 +395,16 @@ import org.apache.flink.table.procedures.Procedure; import org.apache.flink.types.Row; public static class NamedParameterProcedure extends Procedure { - - @ProcedureHint( - argument = {@ArgumentHint(name = "param1", type = @DataTypeHint("INTEGER"), isOptional = false), - @ArgumentHint(name = "param2", type = @DataTypeHint("INTEGER"), isOptional = true)} - ) - public @DataTypeHint("INT") Integer[] call(ProcedureContext context, Integer a, Integer b) { - return new Integer[] {a + (b == null ? 0 : b)}; - } + + @ProcedureHint( + arguments = { + @ArgumentHint(name = "param1", type = @DataTypeHint("INTEGER"), isOptional = false), + @ArgumentHint(name = "param2", type = @DataTypeHint("INTEGER"), isOptional = true) + } + ) + public @DataTypeHint("INT") Integer[] call(ProcedureContext context, Integer a, Integer b) { + return new Integer[] {a + (b == null ? 0 : b)}; + } } ``` {{< /tab >}} @@ -417,15 +419,16 @@ import org.apache.flink.types.Row import scala.annotation.varargs class NamedParameterProcedure extends Procedure { + @ProcedureHint( - argument = Array( + arguments = Array( new ArgumentHint(name = "param1", `type` = new DataTypeHint("INTEGER"), isOptional = false), new ArgumentHint(name = "param2", `type` = new DataTypeHint("INTEGER"), isOptional = true) ) ) - def call(context: ProcedureContext, a: Integer, b: Integer): Array[Integer] = { - Array(a + (if (b == null) 0 else b)) - } + def call(context: ProcedureContext, a: Integer, b: Integer): Array[Integer] = { + Array(a + (if (b == null) 0 else b)) + } } ``` {{< /tab >}} @@ -443,8 +446,10 @@ import org.apache.flink.table.procedures.Procedure; import org.apache.flink.types.Row; @ProcedureHint( - argument = {@ArgumentHint(name = "param1", type = @DataTypeHint("INTEGER"), isOptional = false), - @ArgumentHint(name = "param2", type = @DataTypeHint("INTEGER"), isOptional = true)} + arguments = { + @ArgumentHint(name = "param1", type = @DataTypeHint("INTEGER"), isOptional = false), + @ArgumentHint(name = "param2", type = @DataTypeHint("INTEGER"), isOptional = true) + } ) public static class NamedParameterProcedure extends Procedure { @@ -465,7 +470,7 @@ import org.apache.flink.types.Row import scala.annotation.varargs @ProcedureHint( - argument = Array( + arguments = Array( new ArgumentHint(name = "param1", `type` = new DataTypeHint("INTEGER"), isOptional = false), new ArgumentHint(name = "param2", `type` = new DataTypeHint("INTEGER"), isOptional = true) ) diff --git a/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/factories/TestProcedureCatalogFactory.java b/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/factories/TestProcedureCatalogFactory.java index cf8e4f46b0d14..2b8765bb5ba48 100644 --- a/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/factories/TestProcedureCatalogFactory.java +++ b/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/factories/TestProcedureCatalogFactory.java @@ -225,7 +225,7 @@ public static class NamedArgumentsProcedureWithOptionalArguments implements Proc @ProcedureHint( output = @DataTypeHint("STRING"), - argument = { + arguments = { @ArgumentHint(type = @DataTypeHint("STRING"), name = "c", isOptional = true), @ArgumentHint(type = @DataTypeHint("INT"), name = "d", isOptional = true) })