Skip to content

Commit 6ce145b

Browse files
CuiYanxiang‘cuiyanxiang’
authored andcommitted
[FLINK-33117][table][docs] Fix scala example in udfs page (#23439)
Co-authored-by: ‘cuiyanxiang’ <‘[email protected]’>
1 parent d61126a commit 6ce145b

File tree

2 files changed

+10
-10
lines changed
  • docs
    • content/docs/dev/table/functions
    • content.zh/docs/dev/table/functions

2 files changed

+10
-10
lines changed

docs/content.zh/docs/dev/table/functions/udfs.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -410,19 +410,19 @@ class OverloadedFunction extends ScalarFunction {
410410

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

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

423423
// 允许任意类型的符入,并输出定制序列化后的值
424424
@DataTypeHint(value = "RAW", bridgedTo = classOf[java.nio.ByteBuffer])
425-
def eval(@DataTypeHint(inputGroup = InputGroup.ANY) Object o): java.nio.ByteBuffer = {
425+
def eval(@DataTypeHint(inputGroup = InputGroup.ANY) o: Any): java.nio.ByteBuffer = {
426426
MyUtils.serializeToByteBuffer(o)
427427
}
428428
}

docs/content/docs/dev/table/functions/udfs.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -415,19 +415,19 @@ class OverloadedFunction extends ScalarFunction {
415415

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

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

428428
// allow wildcard input and customly serialized output
429429
@DataTypeHint(value = "RAW", bridgedTo = classOf[java.nio.ByteBuffer])
430-
def eval(@DataTypeHint(inputGroup = InputGroup.ANY) Object o): java.nio.ByteBuffer = {
430+
def eval(@DataTypeHint(inputGroup = InputGroup.ANY) o: Any): java.nio.ByteBuffer = {
431431
MyUtils.serializeToByteBuffer(o)
432432
}
433433
}

0 commit comments

Comments
 (0)