CREATE PROJECTION POLICY

statementsupportedGovernance (policies, tags, data quality)Enterprise+

docs.snowflake.com ↗

Object: PROJECTION POLICY

Creates a new projection policy in the current/specified schema or replaces an existing projection policy. After creating a projection policy, apply the projection policy to a table column using an ALTER TABLE … ALTER COLUMN command or a view column using the ALTER VIEW command.

Syntax

supportedpartialnot supportednot scored

CREATE [ OR REPLACE ] PROJECTION POLICY [ IF NOT EXISTS ] <name>
  AS () RETURNS PROJECTION_CONSTRAINT -> <body>
  [ COMMENT = '<string_literal>' ]

Parameters

NameRequiredDescription
nameIdentifier for the projection policy; must be unique for your schema. The identifier value must start with an alphabetic character and cannot contain spaces or special characters unless the entire identifier string is enclosed in double quotes (e.g. "My object"). Identifiers enclosed in double quotes are also case-sensitive. For more details, see Identifier requirements.
bodySQL expression that determines whether to project a column. The expression can contain CASE and other logic statements, but must call the PROJECTION_CONSTRAINT function:Copy code PROJECTION_CONSTRAINT(ALLOW=>{TRUE|FALSE}, ENFORCEMENT=><enforcement_style>) ALLOW (boolean) - TRUE allows the column to be projected. FALSE prevents the column from being projected, with the behavior specified by ENFORCEMENT. FALSE affects only columns that appear in the final results table. ENFORCEMENT (string, optional) - If ALLOW=FALSE, specifies what should happen if a query includes a protected column. Supported values: FAIL - The query will fail if a protected column is included in the outermost query. NULLIFY - All rows in the protected column return the value NULL. Default: FAIL
COMMENT = 'string_literal'Adds a comment or overwrites an existing comment for the projection policy.

Usage notes

Access control requirements

A role used to execute this operation must have the following privileges at a minimum: Privilege | Object | Notes CREATE PROJECTION POLICY | Schema | Operating on an object in a schema requires at least one privilege on the parent database and at least one privilege on the parent schema. For instructions on creating a custom role with a specified set of privileges, see Creating custom roles. For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control. For additional details on projection policy DDL and privileges, see Privileges and commands.

See also