Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix Snowflake FILE_FORMAT options #221

Copy link
Copy link
@dmaresma

Description

@dmaresma
Issue body actions

Support the Stage and File format options of snowflake for external table ddl statement following the snowflake requirements
https://docs.snowflake.com/en/sql-reference/sql/create-file-format


def test_virtual_column_table():
    ddl = """
    create or replace table if not exists TABLE_DATA_SRC.EXT_PAYLOAD_MANIFEST_WEB (
       id bigint,
       derived bigint as (id * 10)
       )
    location = @ADL_Azure_Storage_Account_Container_Name/
    auto_refresh = false
    file_format = (TYPE=JSON NULL_IF=('field') DATE_FORMAT=AUTO TRIM_SPACE=TRUE)
    stage_file_format = (TYPE=JSON NULL_IF=())
    ;
    """
    result_ext_table = DDLParser(ddl, normalize_names=True, debug=True).run(
        output_mode="snowflake"
    )

    expected_ext_table = [
        {
            "alter": {},
            "checks": [],
            "clone": None,
            "columns": [
                {
                    "name": "id",
                    "type": "bigint",
                    "size": None,
                    "references": None,
                    "unique": False,
                    "nullable": True,
                    "default": None,
                    "check": None,
                },
                {
                    "name": "derived",
                    "type": "bigint",
                    "size": None,
                    "references": None,
                    "unique": False,
                    "nullable": True,
                    "default": None,
                    "check": None,
                    "generated" : {"as" : "id * 10" }
                }
            ],
            "index": [],
            "partitioned_by" : [],
            "primary_key": [],
            "primary_key_enforced": None,
            "auto_refresh" : False,
            "schema": "TABLE_DATA_SRC",
            "table_name": "EXT_PAYLOAD_MANIFEST_WEB",
            "tablespace": None,
            "replace" : True,
            "if_not_exists": True,
            "location" : "@ADL_Azure_Storage_Account_Container_Name/",
            "file_format": ['TYPE=JSON', "NULL_IF=('field')",'DATE_FORMAT=AUTO','TRIM_SPACE=TRUE'],
            'stage_file_format': ['TYPE=JSON','NULL_IF=()']
            }
    ]

    assert result_ext_table == expected_ext_table

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.