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 support { AUTOINCREMENT | IDENTITY } with [ { ORDER | NOORDER } ] optional parameter #213

Closed
dmaresma opened this issue Dec 14, 2023 · 1 comment

Comments

@dmaresma
Copy link
Contributor

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

@xnuinside
Copy link
Owner

@dmaresma thanks one more time for your PR, I released 0.31.2 with your changes

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