The data masking policy that is used to specify data masking
rule.
This message has oneof_ fields (mutually exclusive fields).
For each oneof, at most one member field can be set at the same time.
Setting any member of the oneof automatically clears all other
members.
str
The name of the BigQuery routine that contains the custom
masking routine, in the format of
projects/{project_number}/datasets/{dataset_id}/routines/{routine_id}.
This field is a member of oneof_ masking_expression.
- STRING: ""
- BYTES: b''
- INTEGER: 0
- FLOAT: 0.0
- NUMERIC: 0
- BOOLEAN: FALSE
- TIMESTAMP: 1970-01-01 00:00:00 UTC
- DATE: 1970-01-01
- TIME: 00:00:00
- DATETIME: 1970-01-01T00:00:00
- GEOGRAPHY: POINT(0 0)
- BIGNUMERIC: 0
- ARRAY: []
- STRUCT: NOT_APPLICABLE
- JSON: NULL
LAST_FOUR_CHARACTERS (9):
Masking expression shows the last four characters of text.
The masking behavior is as follows:
- If text length > 4 characters: Replace text with XXXXX,
append last four characters of original text.
- If text length <= 4 characters: Apply SHA-256 hash.
FIRST_FOUR_CHARACTERS (10):
Masking expression shows the first four characters of text.
The masking behavior is as follows:
- If text length > 4 characters: Replace text with XXXXX,
prepend first four characters of original text.
- If text length <= 4 characters: Apply SHA-256 hash.
EMAIL_MASK (12):
Masking expression for email addresses. The masking behavior
is as follows:
- Syntax-valid email address: Replace username with XXXXX.
For example, cloudysanfrancisco@gmail.com becomes
XXXXX@gmail.com.
- Syntax-invalid email address: Apply SHA-256 hash.
For more information, see `Email
mask <https://cloud.google.com/bigquery/docs/column-data-masking-intro#masking_options>`__.
DATE_YEAR_MASK (13):
Masking expression to only show the year of `Date`,
`DateTime` and `TimeStamp`. For example, with the year
2076:
- DATE : 2076-01-01
- DATETIME : 2076-01-01T00:00:00
- TIMESTAMP : 2076-01-01 00:00:00 UTC
Truncation occurs according to the UTC time zone. To change
this, adjust the default time zone using the `time_zone`
system variable. For more information, see the System
variables reference.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Class DataMaskingPolicy (0.6.16)\n\nVersion latestkeyboard_arrow_down\n\n- [0.6.16 (latest)](/python/docs/reference/bigquerydatapolicy/latest/google.cloud.bigquery_datapolicies_v1.types.DataMaskingPolicy)\n- [0.6.15](/python/docs/reference/bigquerydatapolicy/0.6.15/google.cloud.bigquery_datapolicies_v1.types.DataMaskingPolicy)\n- [0.5.3](/python/docs/reference/bigquerydatapolicy/0.5.3/google.cloud.bigquery_datapolicies_v1.types.DataMaskingPolicy)\n- [0.4.0](/python/docs/reference/bigquerydatapolicy/0.4.0/google.cloud.bigquery_datapolicies_v1.types.DataMaskingPolicy)\n- [0.3.2](/python/docs/reference/bigquerydatapolicy/0.3.2/google.cloud.bigquery_datapolicies_v1.types.DataMaskingPolicy)\n- [0.2.0](/python/docs/reference/bigquerydatapolicy/0.2.0/google.cloud.bigquery_datapolicies_v1.types.DataMaskingPolicy)\n- [0.1.1](/python/docs/reference/bigquerydatapolicy/0.1.1/google.cloud.bigquery_datapolicies_v1.types.DataMaskingPolicy) \n\n DataMaskingPolicy(mapping=None, *, ignore_unknown_fields=False, **kwargs)\n\nThe data masking policy that is used to specify data masking\nrule.\n\nThis message has `oneof`_ fields (mutually exclusive fields).\nFor each oneof, at most one member field can be set at the same time.\nSetting any member of the oneof automatically clears all other\nmembers.\n\n.. _oneof: \u003chttps://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields\u003e\n\nClasses\n-------\n\n### PredefinedExpression\n\n PredefinedExpression(value)\n\nThe available masking rules. Learn more here:\n\u003chttps://cloud.google.com/bigquery/docs/column-data-masking-intro#masking_options\u003e. \n\n - STRING: \"\"\n - BYTES: b''\n - INTEGER: 0\n - FLOAT: 0.0\n - NUMERIC: 0\n - BOOLEAN: FALSE\n - TIMESTAMP: 1970-01-01 00:00:00 UTC\n - DATE: 1970-01-01\n - TIME: 00:00:00\n - DATETIME: 1970-01-01T00:00:00\n - GEOGRAPHY: POINT(0 0)\n - BIGNUMERIC: 0\n - ARRAY: []\n - STRUCT: NOT_APPLICABLE\n - JSON: NULL\n LAST_FOUR_CHARACTERS (9):\n Masking expression shows the last four characters of text.\n The masking behavior is as follows:\n\n - If text length \u003e 4 characters: Replace text with XXXXX,\n append last four characters of original text.\n - If text length \u003c= 4 characters: Apply SHA-256 hash.\n FIRST_FOUR_CHARACTERS (10):\n Masking expression shows the first four characters of text.\n The masking behavior is as follows:\n\n - If text length \u003e 4 characters: Replace text with XXXXX,\n prepend first four characters of original text.\n - If text length \u003c= 4 characters: Apply SHA-256 hash.\n EMAIL_MASK (12):\n Masking expression for email addresses. The masking behavior\n is as follows:\n\n - Syntax-valid email address: Replace username with XXXXX.\n For example, cloudysanfrancisco@gmail.com becomes\n XXXXX@gmail.com.\n - Syntax-invalid email address: Apply SHA-256 hash.\n\n For more information, see `Email\n mask \u003chttps://cloud.google.com/bigquery/docs/column-data-masking-intro#masking_options\u003e`__.\n DATE_YEAR_MASK (13):\n Masking expression to only show the year of `Date`,\n `DateTime` and `TimeStamp`. For example, with the year\n 2076:\n\n - DATE : 2076-01-01\n - DATETIME : 2076-01-01T00:00:00\n - TIMESTAMP : 2076-01-01 00:00:00 UTC\n\n Truncation occurs according to the UTC time zone. To change\n this, adjust the default time zone using the `time_zone`\n system variable. For more information, see the System\n variables reference."]]