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 exotism support #234

Closed
dmaresma opened this issue Jan 19, 2024 · 3 comments
Closed

Snowflake exotism support #234

dmaresma opened this issue Jan 19, 2024 · 3 comments
Assignees

Comments

@dmaresma
Copy link
Contributor

Hi,
there is CREATE TABLE statement in Snowflake, created by Matillion where the cluster by property precedes the table column definition, I have no idea where to start the change.
here the acceptance test :

def test_table_inverse_clusterby_and_column_def():
ddl = """CREATE TABLE ${database_name}.MySchemaName."MyTableName" cluster by ("DocProv") (ID NUMBER(38,0) NOT NULL, "DocProv" VARCHAR(2));"""

result = DDLParser(ddl, normalize_names=True, debug=True).run(output_mode="snowflake")
expected = [{'table_name': 'MyTableName',
             'schema': 'MySchemaName',
             'primary_key': [],
             'columns': [{
                          'name': 'ID',
                          'size' : (38,0),
                          'type': 'NUMBER', 
                          'references': None, 
                          'unique': False, 
                          'nullable': False, 
                          'default': None, 
                          'check': None,
                          },
                          {
                          'name': 'DocProv',
                          'size' : 2,
                          'type': 'VARCHAR', 
                          'references': None, 
                          'unique': False, 
                          'nullable': True, 
                          'default': None, 
                          'check': None,
                          }], 
             'alter': {}, 
             'checks': [], 
             'index': [], 
             'partitioned_by': [],
             'cluster_by' : ['DocProv'],
             'tablespace': None,
             'external' : False,
             'primary_key_enforced' : None,
             'table_properties': {'project': '${database_name}'},
             'clone' : None
}]

assert result == expected
@xnuinside
Copy link
Owner

@dmaresma you need to add case where cluster by statement can be before columns defenitions. There is main 'table' expression https://github.com/xnuinside/simple-ddl-parser/blob/main/simple_ddl_parser/dialects/sql.py#L1016 it is expect that after table_name should be LP and defcolumn (column description), so you should add here cluster_by statement as a possible variant like table_name cluster_by (or how this statement should be named)

@xnuinside
Copy link
Owner

I can add it on weekends

@xnuinside xnuinside self-assigned this Apr 21, 2024
@xnuinside
Copy link
Owner

I released in version 1.1.0. Have no idea why I'm writing about weekends, when I didn't have any time(
Tests added in PR: https://github.com/xnuinside/simple-ddl-parser/pull/246/files. If will be needed anything - open new 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