diff --git a/docs/content.zh/docs/dev/table/functions/udfs.md b/docs/content.zh/docs/dev/table/functions/udfs.md index ff8d98d823002..d103cd917305a 100644 --- a/docs/content.zh/docs/dev/table/functions/udfs.md +++ b/docs/content.zh/docs/dev/table/functions/udfs.md @@ -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") - 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) } } diff --git a/docs/content/docs/dev/table/functions/udfs.md b/docs/content/docs/dev/table/functions/udfs.md index 3c6c28582da27..109328a8edd7a 100644 --- a/docs/content/docs/dev/table/functions/udfs.md +++ b/docs/content/docs/dev/table/functions/udfs.md @@ -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") - 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) } }