> For the complete documentation index, see [llms.txt](https://docs.snowddl.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.snowddl.com/basic/yaml-configs/masking-policy.md).

# MASKING POLICY

Config path: `/<database>/<schema>/masking_policy/<name>.yaml`

Example:

```yaml
arguments:
  name: VARCHAR(255)

returns: VARCHAR(255)

body: |-
  REPLACE(name, 'A', '*')

references:
  - object_type: TABLE
    object_name: test_table_1
    columns: [name]
```

## Schema

* <mark style="background-color:red;">**arguments**</mark> (dict)
  * *{key}* (ident) - argument name
  * *{value}* (str) - argument data type
* <mark style="background-color:red;">**returns**</mark> (str) - return data type
* <mark style="background-color:red;">**body**</mark> (str) - policy SQL expression
* **exempt\_other\_policies** (bool)
* ~~**references**~~ (dict)
  * **object\_type** (str) - reference object type (e.g. `TABLE`, `VIEW`)
  * **object\_name** (ident) - reference object name
  * **columns** (list)
    * *{items}* (ident) - reference column names
* **comment** (str)&#x20;

## Usage notes

1. Management of masking policies requires active warehouse due to unavoidable [POLICY\_REFERENCES](https://docs.snowflake.com/en/sql-reference/functions/policy_references.html) table function calls.
2. If **arguments** or **returns** of policy was changed, all references will be dropped, policy will be re-created from scratch, and all references will be restored. Also, when other objects are being re-created, such objects will initially lack policy references.\
   \
   Business users might be able to access objects without protection of policy in such case. There is no way to avoid it due to fundamental lack of transaction support for DDL queries in Snowflake.\
   \
   You may consider having weekly "safe maintenance" time slots to apply DDL when business users won't be able to access Snowflake account.
3. Parameter `references` is deprecated since `0.33.0`. Use policy reference parameters directly in [TABLE](/basic/yaml-configs/table.md) or [VIEW](/basic/yaml-configs/view.md) configs instead.

## Links

* [CREATE MASKING POLICY](https://docs.snowflake.com/en/sql-reference/sql/create-masking-policy.html)
* [SHOW MASKING POLICIES](https://docs.snowflake.com/en/sql-reference/sql/show-masking-policies.html)
* [DESC MASKING POLICY](https://docs.snowflake.com/en/sql-reference/sql/desc-masking-policy.html)
* [Parser & JSON Schema (GitHub)](https://github.com/littleK0i/SnowDDL/blob/master/snowddl/parser/masking_policy.py)
