Skip to content

Commit

Permalink
Feedback addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
twalthr committed Nov 26, 2024
1 parent 05f28b4 commit 87ba251
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 46 deletions.
24 changes: 16 additions & 8 deletions docs/content.zh/docs/dev/table/functions/udfs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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 {

Expand All @@ -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 {

Expand Down
33 changes: 19 additions & 14 deletions docs/content.zh/docs/dev/table/procedures.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 >}}
Expand All @@ -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 >}}
Expand All @@ -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 {

Expand All @@ -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)
)
Expand Down
24 changes: 16 additions & 8 deletions docs/content/docs/dev/table/functions/udfs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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 {

Expand All @@ -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 {

Expand Down
35 changes: 20 additions & 15 deletions docs/content/docs/dev/table/procedures.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 >}}
Expand All @@ -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 >}}
Expand All @@ -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 {

Expand All @@ -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)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down

0 comments on commit 87ba251

Please sign in to comment.