Skip to content

Commit

Permalink
[FLINK-33117][table][docs] Fix scala example in udfs page (#23439)
Browse files Browse the repository at this point in the history
Co-authored-by: ‘cuiyanxiang’ <‘[email protected]’>
  • Loading branch information
2 people authored and Alexander Fedulov committed Dec 20, 2024
1 parent 5c9c45c commit 2eda53a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions docs/content.zh/docs/dev/table/functions/udfs.md
Original file line number Diff line number Diff line change
Expand Up @@ -410,19 +410,19 @@ class OverloadedFunction extends ScalarFunction {

// 定义 decimal 的精度和小数位
@DataTypeHint("DECIMAL(12, 3)")
def eval(double a, double b): BigDecimal = {
java.lang.BigDecimal.valueOf(a + b)
def eval(a: Double, b: Double): BigDecimal = {
BigDecimal(a + b)
}

// 定义嵌套数据类型
@DataTypeHint("ROW<s STRING, t TIMESTAMP_LTZ(3)>")
def eval(Int i): Row = {
Row.of(java.lang.String.valueOf(i), java.time.Instant.ofEpochSecond(i))
def eval(i: Int): Row = {
Row.of(i.toString, java.time.Instant.ofEpochSecond(i))
}

// 允许任意类型的符入,并输出定制序列化后的值
@DataTypeHint(value = "RAW", bridgedTo = classOf[java.nio.ByteBuffer])
def eval(@DataTypeHint(inputGroup = InputGroup.ANY) Object o): java.nio.ByteBuffer = {
def eval(@DataTypeHint(inputGroup = InputGroup.ANY) o: Any): java.nio.ByteBuffer = {
MyUtils.serializeToByteBuffer(o)
}
}
Expand Down
10 changes: 5 additions & 5 deletions docs/content/docs/dev/table/functions/udfs.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,19 +415,19 @@ class OverloadedFunction extends ScalarFunction {

// define the precision and scale of a decimal
@DataTypeHint("DECIMAL(12, 3)")
def eval(double a, double b): BigDecimal = {
java.lang.BigDecimal.valueOf(a + b)
def eval(a: Double, b: Double): BigDecimal = {
BigDecimal(a + b)
}

// define a nested data type
@DataTypeHint("ROW<s STRING, t TIMESTAMP_LTZ(3)>")
def eval(Int i): Row = {
Row.of(java.lang.String.valueOf(i), java.time.Instant.ofEpochSecond(i))
def eval(i: Int): Row = {
Row.of(i.toString, java.time.Instant.ofEpochSecond(i))
}

// allow wildcard input and customly serialized output
@DataTypeHint(value = "RAW", bridgedTo = classOf[java.nio.ByteBuffer])
def eval(@DataTypeHint(inputGroup = InputGroup.ANY) Object o): java.nio.ByteBuffer = {
def eval(@DataTypeHint(inputGroup = InputGroup.ANY) o: Any): java.nio.ByteBuffer = {
MyUtils.serializeToByteBuffer(o)
}
}
Expand Down

0 comments on commit 2eda53a

Please sign in to comment.