[fix](function) Change digital_masking function arg type to BIGINT (#7888)

Change digital_masking function arg type to BIGINT to fix the wrong result.
This commit is contained in:
qiye
2022-01-25 22:28:05 +08:00
committed by GitHub
parent a6831535e9
commit 461b352d3e
8 changed files with 8 additions and 8 deletions

View File

@ -36,7 +36,7 @@ digital_masking(digital_number)
Alias function, the original function is `concat(left(id,3),'****',right(id,4))`.
Desensitizes the input `digital_number` and returns the result after masking desensitization.
Desensitizes the input `digital_number` and returns the result after masking desensitization. `digital_number` is `BIGINT` data type.
## example

View File

@ -131,7 +131,7 @@ If the `function_name` contains the database name, the custom function will be c
```
-- create a custom functional alias function
CREATE ALIAS FUNCTION id_masking(INT) WITH PARAMETER(id)
CREATE ALIAS FUNCTION id_masking(BIGINT) WITH PARAMETER(id)
AS CONCAT(LEFT(id, 3), '****', RIGHT(id, 4));
-- create a custom cast alias function

View File

@ -60,7 +60,7 @@ Intermediate Type: NULL
Intermediate Type: NULL
Properties: {"object_file":"http://host:port/libudasample.so","finalize_fn":"_ZN9doris_udf13CountFinalizeEPNS_15FunctionContextERKNS_9BigIntValE","init_fn":"_ZN9doris_udf9CountInitEPNS_15FunctionContextEPNS_9BigIntValE","merge_fn":"_ZN9doris_udf10CountMergeEPNS_15FunctionContextERKNS_9BigIntValEPS2_","md5":"37d185f80f95569e2676da3d5b5b9d2f","update_fn":"_ZN9doris_udf11CountUpdateEPNS_15FunctionContextERKNS_6IntValEPNS_9BigIntValE"}
*************************** 3. row ***************************
Signature: id_masking(INT)
Signature: id_masking(BIGINT)
Return Type: VARCHAR
Function Type: Alias
Intermediate Type: NULL

View File

@ -36,7 +36,7 @@ digital_masking(digital_number)
别名函数,原始函数为 `concat(left(id,3),'****',right(id,4))`
将输入的 `digital_number` 进行脱敏处理,返回遮盖脱敏后的结果。
将输入的 `digital_number` 进行脱敏处理,返回遮盖脱敏后的结果。`digital_number``BIGINT` 数据类型。
## example

View File

@ -132,7 +132,7 @@ CREATE [AGGREGATE] [ALIAS] FUNCTION function_name
```
-- 创建自定义功能别名函数
CREATE ALIAS FUNCTION id_masking(INT) WITH PARAMETER(id)
CREATE ALIAS FUNCTION id_masking(BIGINT) WITH PARAMETER(id)
AS CONCAT(LEFT(id, 3), '****', RIGHT(id, 4));
-- 创建自定义 CAST 别名函数

View File

@ -61,7 +61,7 @@ Intermediate Type: NULL
Intermediate Type: NULL
Properties: {"object_file":"http://host:port/libudasample.so","finalize_fn":"_ZN9doris_udf13CountFinalizeEPNS_15FunctionContextERKNS_9BigIntValE","init_fn":"_ZN9doris_udf9CountInitEPNS_15FunctionContextEPNS_9BigIntValE","merge_fn":"_ZN9doris_udf10CountMergeEPNS_15FunctionContextERKNS_9BigIntValEPS2_","md5":"37d185f80f95569e2676da3d5b5b9d2f","update_fn":"_ZN9doris_udf11CountUpdateEPNS_15FunctionContextERKNS_6IntValEPNS_9BigIntValE"}
*************************** 3. row ***************************
Signature: id_masking(INT)
Signature: id_masking(BIGINT)
Return Type: VARCHAR
Function Type: Alias
Intermediate Type: NULL

View File

@ -88,7 +88,7 @@ public class AliasFunction extends Function {
/**
* Please ensure that the condition checks in {@link #analyze} are satisfied
*/
functionSet.addBuiltin(createBuiltin(DIGITAL_MASKING, Lists.newArrayList(Type.INT), Type.VARCHAR,
functionSet.addBuiltin(createBuiltin(DIGITAL_MASKING, Lists.newArrayList(Type.BIGINT), Type.VARCHAR,
false, Lists.newArrayList("id"), getExpr(oriStmt), true));
} catch (AnalysisException e) {
LOG.error("Add builtin alias function error {}", e);

View File

@ -120,7 +120,7 @@ public class CreateFunctionTest {
Assert.assertTrue(constExprLists.get(0).get(0) instanceof FunctionCallExpr);
// create alias function
createFuncStr = "create alias function db1.id_masking(int) with parameter(id) as concat(left(id,3),'****',right(id,4));";
createFuncStr = "create alias function db1.id_masking(bigint) with parameter(id) as concat(left(id,3),'****',right(id,4));";
createFunctionStmt = (CreateFunctionStmt) UtFrameUtils.parseAndAnalyzeStmt(createFuncStr, ctx);
Catalog.getCurrentCatalog().createFunction(createFunctionStmt);