Skip to content

Snowflake support { AUTOINCREMENT | IDENTITY } with [ { ORDER | NOORDER } ] optional parameter #213

Closed
@dmaresma

Description

@dmaresma

Describe the bug
Adding support Snowflake CREATE TABLE { AUTOINCREMENT | IDENTITY } column definition with explicit Order or NoOrder optional parameters

https://docs.snowflake.com/en/sql-reference/sql/create-table
To Reproduce
run the following tests
`
def test_autoincrement_order():
# test for https://github.com/xnuinside/simple-ddl-parser/issues/20x
ddl = """CREATE TABLE table (surrogatekey_SK NUMBER(38,0) NOT NULL autoincrement start 1 increment 1 ORDER COMMENT 'Record Identification Number Ordered')"""
result = DDLParser(ddl).run(group_by_type=True)
expected = {
"ddl_properties": [],
"domains": [],
"schemas": [],
"sequences": [],
"tables": [
{
"alter": {},
"checks": [],
"columns": [
{
"check": None,
"comment": "Record Identification Number Ordered",
"default": None,
"name": "surrogatekey_SK",
"nullable": True,
"references": None,
"size": None,
"type": "int",
"unique": False,
"autoincrement":True,
"start" : 1,
"increment": 1
}
],
"index": [],
"partitioned_by": [],
"primary_key": [],
"schema": None,
"table_name": "table",
"tablespace": None,
}
],
"types": [],
}
assert result == expected

def test_autoincrement_noorder():
# test for https://github.com/xnuinside/simple-ddl-parser/issues/20x
ddl = """CREATE TABLE table (surrogatekey_SK NUMBER(38,0) NOT NULL autoincrement start 1 increment 1 NOORDER COMMENT 'Record Identification Number NoOrdered')"""
result = DDLParser(ddl).run(group_by_type=True)
expected = {
"ddl_properties": [],
"domains": [],
"schemas": [],
"sequences": [],
"tables": [
{
"alter": {},
"checks": [],
"columns": [
{
"check": None,
"comment": "Record Identification Number NoOrdered",
"default": None,
"name": "surrogatekey_SK",
"nullable": True,
"references": None,
"size": None,
"type": "int",
"unique": False,
"autoincrement":True,
"start" : 1,
"increment": None
}
],
"index": [],
"partitioned_by": [],
"primary_key": [],
"schema": None,
"table_name": "table",
"tablespace": None,
}
],
"types": [],
}
assert result == expected`

Expected behavior
no regression, keep autoincrement: true , increment:none in case of NOORDER and 1 in case of ORDER

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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