shinichi-takii / ddlparse

DDL parase and Convert to BigQuery JSON schema and DDL statements
https://pypi.org/project/ddlparse/
BSD 3-Clause "New" or "Revised" License
87 stars 29 forks source link

Add support Oracle Length Semantics for Character Datatypes #16

Closed ck-fm0211 closed 6 years ago

ck-fm0211 commented 6 years ago

Problem

DDLの文字列カラムの定義に指定するサイズを文字数指定にした場合に、正しく終了しない。 ex.) 10カラムあるはずが、文字数指定したカラムまでしか出力されない

Example

$ cat test1.py
from ddlparse import DdlParse

sample_ddl = """
CREATE TABLE SAMPLE_TABLE
(    COL1 NUMBER(20,0) NOT NULL ENABLE,
     COL2 VARCHAR2(45 CHAR) NOT NULL ENABLE,
     COL3 VARCHAR2(45 CHAR) NOT NULL ENABLE,
     COL4 NUMBER(20,0) NOT NULL ENABLE,
     COL5 NUMBER(20,0) NOT NULL ENABLE,
     COL6 NUMBER(20,0) NOT NULL ENABLE,
     COL7 NUMBER(20,0) NOT NULL ENABLE,
     COL8 NUMBER(20,0) NOT NULL ENABLE,
     COL9 NUMBER(20,0) NOT NULL ENABLE,
     COL10 NUMBER(20,0) NOT NULL ENABLE
)
"""

table = DdlParse().parse(sample_ddl)
parser = DdlParse(sample_ddl)
table = parser.parse()

print(table.to_bigquery_fields())

result

$ python test1.py
[{"name": "COL1", "type": "INTEGER", "mode": "REQUIRED"},{"name": "COL2", "type": "STRING", "mode": "NULLABLE"}]

Environment

$ pip freeze | grep ddlparse
ddlparse==1.1.2
shinichi-takii commented 6 years ago

Reference

Oracle Database Documen > Data Type > Length Semantics for Character Datatypes https://docs.oracle.com/cd/B28359_01/server.111/b28318/datatype.htm#CNCPT1824