Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snowflake Table DDL support of WITH MASKING POLICY column definition #201

Closed
dmaresma opened this issue Jul 27, 2023 · 2 comments
Closed
Assignees

Comments

@dmaresma
Copy link
Contributor

dmaresma commented Jul 27, 2023

Is your feature request related to a problem? Please describe.
I would like to improve the CREATE TABLE statement of Snowflake ddl to support the Column WITH MASKING POLICY.

Describe the solution you'd like
CREATE OR REPLACE TABLE schemaName.TableAddresses (
AddressID NUMBER(38,0) NOT NULL,
Address1 VARCHAR(100) WITH MASKING POLICY DBName.MASKING_POLICY_LIBRARY.MASK_STRING WITH TAG (DBName.MASKING_POLICY_LIBRARY.PROJECT_POLICY_MASK='mask_object')
);
Supported by DDLParser.run() functions

Describe alternatives you've considered
add MASKING POLICY and TAG members same as Comment, Nullable or Default properties

https://docs.snowflake.com/en/sql-reference/sql/create-table

@dmaresma
Copy link
Contributor Author

dmaresma commented Jul 27, 2023

here the test :
` ddl = """
create TABLE ASIN.EXCLUSION (
USER_COMMENT VARCHAR(100),
PROCESS_SQN NUMBER(10,0) NOT NULL,
ADDRESS1 VARCHAR(100) WITH MASKING POLICY DBName.MASKING_POLICY_LIBRARY.MASK_STRING WITH TAG (DBName.MASKING_POLICY_LIBRARY.PROJECT_POLICY_MASK='mask_object')
constraint PK_EXCLUSION primary key (ASIN)
) COMMENT ='ASINs to be excluded from the ASIN List File'
;
"""
result = DDLParser(ddl, normalize_names=True).run(output_mode="snowflake")

expected = [
    {
        "alter": {},
        "checks": [],
        "clone": None,
        "columns": [
            {
                "check": None,
                "default": None,
                "name": "USER_COMMENT",
                "nullable": True,
                "references": None,
                "size": 100,
                "type": "VARCHAR",
                "unique": False,
            },
            {
                "check": None,
                "default": None,
                "name": "PROCESS_SQN",
                "nullable": False,
                "references": None,
                "size": (10, 0),
                "type": "NUMBER",
                "unique": False,
            },
            {
                "check": None,
                "default": None,
                "name": "ADDRESS1",
                "nullable": False,
                "references": None,
                "size": 100,
                "type": "VARCHAR",
                "unique": False,
                "with_mask_policy": "DBName.MASKING_POLICY_LIBRARY.MASK_STRING",
                "with_tag" : "(DBName.MASKING_POLICY_LIBRARY.PROJECT_POLICY_MASK='mask_object')"
            },
        ],
        "constraints": {
            "primary_keys": [
                {"columns": ["ASIN"], "constraint_name": "PK_EXCLUSION"}
            ]
        },
        "comment": "'ASINs to be excluded from the ASIN List File'",
        "index": [],
        "partitioned_by": [],
        "primary_key": ["ASIN"],
        "primary_key_enforced": None,
        "schema": "ASIN",
        "table_name": "EXCLUSION",
        "tablespace": None,
    }
]
assert result == expected`

dmaresma added a commit to dmaresma/simple-ddl-parser that referenced this issue Aug 8, 2023
xnuinside added a commit that referenced this issue Aug 22, 2023
issue #201 snowflake table ddl improvement
@xnuinside
Copy link
Owner

changes was released in version 0.31.0, thanks for opening the PR & the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants