simple-ddl-parser

Simple DDL Parser to parse SQL (HQL, TSQL, AWS Redshift, BigQuery, Snowflake and other dialects) ddl files to json/python dict with full information about columns: types, defaults, primary keys, etc. & table properties, types, domains, etc.

MIT License

Downloads
1.5M
Stars
166
Committers
6

Bot releases are visible (Hide)

simple-ddl-parser - 1.5.0 fix uniques in case of indexes / unique case for several columns Latest Release

Published by xnuinside 5 months ago

Fixes

  1. Now, unique set up to column only if it was only one column in unique constraint/index. Issue - https://github.com/xnuinside/simple-ddl-parser/issues/255
  2. Fixed issue when UNIQUE KEY was identified as primary key - https://github.com/xnuinside/simple-ddl-parser/issues/253
simple-ddl-parser - v1.4.0 ⭕ Oracle new output keywords - is_global & temp

Published by xnuinside 5 months ago

Fixes

🔍 BigQuery:

  1. Indexes without schema causes issues in BigQuery dialect - fixed.

Improvements

⭕ Oracle:

  1. Added new output keywords in table definition - temp & is_global. Added support for create global temporary table - https://github.com/xnuinside/simple-ddl-parser/issues/182
simple-ddl-parser - 1.3.0 🐘 PostgreSQL WITH TIME ZONE & 🔍 BigQuery PARTITION BY Improvements

Published by xnuinside 5 months ago

Fixes

🐘 PostgreSQL:

  1. Timezone was moved out from type definition to keyword 'with_time_zone' it can be True (if with time zone) or False (if without)

🔍 BigQuery:

  1. Previously Range in RANGE_BUCKETS was parsed as a columns, now this behaviour is changed and
    range placed in own keyword - 'range' (can be array or str).
    Also for all ``*_TRUNC PARTITIONS` like DATETIME_TRUNC, TIMESTAMP_TRUNC, etc, second argument moved to arg 'trunc_by'

Improvements

🐘 PostgreSQL:

  1. Added support for PostgreSQL with / without time zone - https://github.com/xnuinside/simple-ddl-parser/issues/250

🔍 BigQuery:

  1. Added support for GENERATE_ARRAY in RANGE_BUCKETS https://github.com/xnuinside/simple-ddl-parser/issues/183
simple-ddl-parser - 1.2.1 MySQL 🐬 & ⭕ Oracle & 🐘 PostgreSQL updates

Published by xnuinside 5 months ago

Fixes

🐬 MySQL:

  1. Fixed issue relative to auto_increment that caused empty output if auto_increment defined in table properties -
    https://github.com/xnuinside/simple-ddl-parser/issues/206

Improvements

🐬 MySQL:

  1. auto_increment added as property to mysql output

⭕ Oracle:

  1. Added support for constraint name in column definition - https://github.com/xnuinside/simple-ddl-parser/issues/203
  2. Added support for GENERATED (ALWAYS | (BY DEFAULT [ON NULL])) AS IDENTITY in column definition

🐘 PostgreSQL:

  1. Added support for CAST statement in column GENERATE ALWAYS expression - https://github.com/xnuinside/simple-ddl-parser/issues/198
simple-ddl-parser - v1.1.0: 🐬 & ❄ Improvements

Published by xnuinside 6 months ago

Improvements

🐬 MySQL:

  1. Added support for INDEX statement inside table definition
  2. Added support for MySQL INVISIBLE/VISIBLE statement - https://github.com/xnuinside/simple-ddl-parser/issues/243

❄ Snowflake:

  1. Added support for cluster by statement before columns definition - https://github.com/xnuinside/simple-ddl-parser/issues/234
simple-ddl-parser - 1.0.4 Few Fixes & New statements release

Published by xnuinside 7 months ago

🐈

Improvements

  1. Support functions with schema prefix in DEFAULT and CHECK statements. https://github.com/xnuinside/simple-ddl-parser/issues/240

Fixes

  1. Fix for REFERENCES NOT NULL - https://github.com/xnuinside/simple-ddl-parser/issues/239
  2. Fix for snowflake stage name location format bug fix - https://github.com/xnuinside/simple-ddl-parser/pull/241
simple-ddl-parser - v1.0.3 Fixed bug with `CREATE OR REPLACE SCHEMA` & some more

Published by xnuinside 9 months ago

v1.0.3

Improvements

  1. Fixed bug with CREATE OR REPLACE SCHEMA.
  2. Added support of create empty tables without columns CREATE TABLE tablename (); (valid syntax in SQL)

Snowflake

  1. Fixed bug with snowflake stage_ fileformat option value equal a single string as FIELD_OPTIONALLY_ENCLOSED_BY = '\"', FIELD_DELIMITER = '|'
  2. improve snowflake fileformat key equals value into dict. type.
simple-ddl-parser - v1.0.2 Snowflake, MySQL, and other small improvements release

Published by xnuinside 9 months ago

Improvements

  1. Fixed bug with places first table property value in 'authorization' key. Now it is used real property name.
  2. Fixed typo on Databricks dialect
  3. improved equals symbols support within COMMENT statement.
  4. turn regexp into functions

MySQL Improvements

  1. UNSIGNED property after int parsed validly now

Snowflake

  1. Snowflake TAG now available on SCHEMA definitions.
simple-ddl-parser - v1.0.1 `normalize_names=True` improvements

Published by xnuinside 9 months ago

v1.0.1

Minor Fixes

  1. When using normalize_names=True do not remove [] from types like decimal(21)[].
  2. When using normalize_names=True ensure that "complex"."type" style names convert to complex.type.
simple-ddl-parser - 1.0.0 Major release with output updates

Published by xnuinside 10 months ago

v1.0.0
In output structure was done important changes that can in theory breaks code.

Important changes

  1. Important change:

all custom table properties that are defined after column definition in 'CREATE TABLE' statement and relative to only one dialect (only for SparkSQL, or HQL,etc), for example, like here:
https://github.com/xnuinside/simple-ddl-parser/blob/main/tests/dialects/test_snowflake.py#L767 or https://github.com/xnuinside/simple-ddl-parser/blob/main/tests/dialects/test_spark_sql.py#L133 will be saved now in property table_properties as dict.
Previously they was placed on same level of table output as columns, alter, etc. Now, they grouped and moved to key table_properties.

  1. Formatting parser result now represented by 2 classes - Output & TableData, that makes it more strict and readable.

And more.

Full Changelog of version 1.0.0: https://github.com/xnuinside/simple-ddl-parser/blob/main/CHANGELOG.txt#L1

simple-ddl-parser - v0.32.0 ALTER DROP, ADD, MODIFY, RENAME, etc statements support

Published by xnuinside 10 months ago

v0.32.0

Improvements

  1. Added support for several ALTER statements (ADD, DROP, RENAME, etc) - https://github.com/xnuinside/simple-ddl-parser/issues/215
    In 'alter' output added several keys:
    1. 'dropped_columns' - to store information about columns that was in table, but after dropped by alter
    2. 'renamed_columns' - to store information about columns that was renamed
    3. 'modified_columns' - to track alter column changes for defaults, datetype, etc. Argument stores previous columns states.

Fixes

  1. Include source column names in FOREIGN KEY references. Fix for: https://github.com/xnuinside/simple-ddl-parser/issues/196
  2. ALTER statement now will be parsed correctly if names & schemas written differently in create table statement and alter.
    For example, if in create table you use quotes like "schema_name"."table_name", but in alter was schema_name.table_name - previously it didn't work, but now parser understand that it is the same table.
simple-ddl-parser - v0.31.3 - Snowflake Statements & other Improvements

Published by xnuinside 10 months ago

v0.31.3

Improvements

Snowflake update:

  1. Added support for Snowflake Virtual Column definition in External Column AS () statement - https://github.com/xnuinside/simple-ddl-parser/issues/218
  2. enforce support for Snowflake _FILE_FORMAT options in External Column ddl statement - https://github.com/xnuinside/simple-ddl-parser/issues/221

Others

  1. Support for KEY statement in CREATE TABLE statements. KEY statements will now create INDEX entries in the DDL parser.

Big-big thanks for contribution goes to https://github.com/dmaresma and https://github.com/cfhowes

simple-ddl-parser - Snowflake improvements

Published by xnuinside 10 months ago

v0.31.2

Improvements

Snowflake update:

  1. Added support for Snowflake AUTOINCREMENT | IDENTITY column definitions with optional parameter ORDER|NOORDER statement - https://github.com/xnuinside/simple-ddl-parser/issues/213

Common

  1. Added param 'encoding' to parse_from_file function - https://github.com/xnuinside/simple-ddl-parser/issues/142.
    Default encoding is utf-8.

Thanks to https://github.com/dmaresma for contributions.

simple-ddl-parser - 0.31.1 - Snowflake Improvements

Published by xnuinside 12 months ago

Improvements

Snowflake updates:

  1. Support multiple tag definitions in a single WITH TAG statement.
  2. Added support for Snowflake double single quotes - https://github.com/xnuinside/simple-ddl-parser/issues/208
simple-ddl-parser - Python 3.11 support & SNOWFLAKE Improvements

Published by xnuinside about 1 year ago

v0.31.0

Fixes:

  1. Move inline flag in regexp (issue with python 3.11) - https://github.com/xnuinside/simple-ddl-parser/pull/200
    Fix for: https://github.com/xnuinside/simple-ddl-parser/issues/199

Improvements:

  1. Added Snowflake Table DDL support of WITH MASKING POLICY column definition - https://github.com/xnuinside/simple-ddl-parser/issues/201
simple-ddl-parser - v0.30.0 - IDENTITY as Column property & more

Published by xnuinside over 1 year ago

Fixes:

  1. IDENTITY now parsed normally as a separate column property. Issue: https://github.com/xnuinside/simple-ddl-parser/issues/184

New Features:

  1. IN TABLESPACE IBM DB2 statement now is parsed into 'tablespace' key. Issue: https://github.com/xnuinside/simple-ddl-parser/issues/194.
    INDEX IN also parsed to 'index_in' key.
    Added support for ORGANIZE BY statement

  2. Added support for PostgreSQL INHERITS statement. Issue: https://github.com/xnuinside/simple-ddl-parser/issues/191

simple-ddl-parser - v0.29.0 Added support for non-numeric column type parameters

Published by xnuinside almost 2 years ago

v0.29.0

Fixes

  1. AUTOINCREMENT statement now parsed validly same way as AUTO_INCREMENT and showed up in output as 'autoincrement' property of the column
    Fix for: https://github.com/xnuinside/simple-ddl-parser/issues/170
  2. Fix issue ' TypeError argument of type 'NoneType' is not iterable' on some foreigen keys https://github.com/xnuinside/simple-ddl-parser/issues/148

New Features

  1. Support for non-numeric column type parameters https://github.com/xnuinside/simple-ddl-parser/issues/171
    It shows in column attribute 'type_parameters'.
simple-ddl-parser - v 0.28.1 fix multiline comments parsing & skip INSERT ROWS from SQL

Published by xnuinside almost 2 years ago

v0.28.1

Imporvements:

  1. Lines started with INSERT INTO statement now successfully ignored by parser (so you can keep them in ddl - they will be just skiped)

Fixes:

  1. Important fix for multiline comments
simple-ddl-parser - 0.28.0 - AUTO_INCREMENT & floats & other bug fixes

Published by xnuinside almost 2 years ago

v0.28.0

Important Changes (Pay attention):

  1. Because of parsing now AUTO_INCREMENT as a separate property of column previous output changed.
    Previously it was parsed as a part of type like: 'INT AUTO_INCREMENT'.
    Now type will be only 'INT', but in column property you will see 'autoincrement': True.

Amazing innovations:

  1. It's is weird to write in Changelog, but only in version 0.28.0 I recognise that floats that not supported by parser & it was fixed.
    Thanks for the sample in the issue: https://github.com/xnuinside/simple-ddl-parser/issues/163

Improvements:

MariaDB:

  1. Added support for MariaDB AUTO_INCREMENT (from ddl here - https://github.com/xnuinside/simple-ddl-parser/issues/144)
    If column is Auto Incremented - it indicated as 'autoincrement': True in column definition

Common:

  1. Added parsing for multiline comments in DDL with /* */ syntax.
  2. Comments from DDL now all placed in 'comments' keyword if you use group_by_type= arg in parser.
  3. Added argument 'parser_settings={}' (dict type) in method parse_from_file() - this way you can pass any arguments that you want to DDLParser (& that supported by it)
    So, if you want to set log_level=logging.WARNING for parser - just use it as:
    parse_from_file('path_to_file', parser_settings={'log_level': logging.WARNING}). For issue: https://github.com/xnuinside/simple-ddl-parser/issues/160
simple-ddl-parser - v0.27.0 - Fixes & improvements

Published by xnuinside about 2 years ago

v0.27.0

Fixes:

  1. Fixed parsing CHECKS with IN statement - https://github.com/xnuinside/simple-ddl-parser/issues/150
  2. @# symbols added to ID token - (partialy) https://github.com/xnuinside/simple-ddl-parser/issues/146

Improvements:

  1. Added support for '*' in size column (ORACLE dialect) - https://github.com/xnuinside/simple-ddl-parser/issues/151
  2. Added arg 'debug' to parser, works same way as 'silent' - to get more clear error output.

New features:

  1. Added support for ORACLE 'ORGANIZATION INDEX'
  2. Added support for SparkSQL Partition by with procedure call - https://github.com/xnuinside/simple-ddl-parser/issues/154
  3. Added support for DEFAULT CHARSET statement MySQL - https://github.com/xnuinside/simple-ddl-parser/issues/153