qidaye opened a new issue #6260:
URL: https://github.com/apache/incubator-doris/issues/6260


   # Background
   
   Data has different needs for different levels and business scenarios, and 
some scenarios require data desensitization to achieve information security. In 
order to prevent data information leakage and avoid attacks such as 
eavesdropping and interception, the data going out from the database is 
required to be desensitized, so the desensitization function needs to be 
implemented inside the system.
   
   # Requirements
   For cell phone number, bank card number, ID card number, name, etc. need to 
be desensitized, to achieve a variety of desensitization functions, 
desensitization example 
   
   `13800000000` → `138****0000`
   
   # Design
   
   Implement a new function type, `AliasFunction`, of `Function`. 
   
   Capable of adapting to multiple scenarios and meeting the needs of multiple 
users, requiring only one development definition by the user's administrator 
based on the scenario.
   
   ## Syntax
   
   1. create alias function
   
   ```
   create alias function id_masking(int) with parameter(id) as 
concat(left(id,3),'****',right(id,4));
   ```
   
   2. view function
   
   ```sql
   mysql> show functions;
   +---------------+
   | Function Name |
   +---------------+
   | id_masking    |
   +---------------+
   1 row in set (0.00 sec)
   
   mysql> show full functions\G
   *************************** 1. row ***************************
           Signature: id_masking(INT)
         Return Type: VARCHAR
       Function Type: Alias
   Intermediate Type: NULL
          Properties: {"parameter":"id","origin_function":"concat(left(`id`, 
3), `****`, right(`id`, 4))"}
   1 row in set (0.00 sec)
   ```
   
   3. View the create statement
   
   ```sql
   mysql> show create function id_masking(int)\G
   *************************** 1. row ***************************
   Function Signature: id_masking(INT)
      Create Function: CREATE ALIAS FUNCTION id_masking(INT) WITH PARAMETER(id) 
AS concat(left(`id`, 3), '****', right(`id`, 4));
   1 row in set (0.00 sec)
   ```
   
   4. Use function
   
   ```sql
   mysql> select id_masking(13812345678);
   +-------------------------+
   | id_masking(13812345678) |
   +-------------------------+
   | 138****5678             |
   +-------------------------+
   1 row in set (0.01 sec)
   
   mysql> select id_masking(k1) from t3;
   +------------------+
   | id_masking(`k1`) |
   +------------------+
   | 100****7000      |
   | 123****5678      |
   +------------------+
   2 rows in set (0.01 sec)
   ```
   
   5. Builtin alias function 
   
   Add a builtin alias function `digital_masking(int)` = 
`concat(left(id,3),'****',right(id,4))`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to