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 supports to BigQuery `NUMERIC` data type #46

Closed shinichi-takii closed 4 years ago

shinichi-takii commented 4 years ago

Requirements

Data-type Conditions

BigQuery Data Type Source Data Type Precision Scale Database Exapmle Source Data Type
INT64 (NUMERIC|NUMBER|DECIMAL) < 19 = 0 - NUMERIC(18)
FLOAT64 (NUMERIC|NUMBER|DECIMAL) < 19 > 0 - NUMERIC(18, 1)
NUMERIC (NUMERIC|NUMBER|DECIMAL) >= 19 - - NUMERIC(19)
NUMERIC (NUMERIC|NUMBER|DECIMAL) * - - NUMBER(*, 0)
INT64 (NUMERIC|NUMBER|DECIMAL) None - default DECIMAL
NUMERIC (NUMERIC|NUMBER|DECIMAL) None - DdlParse.DATABASE.oracle
DdlParse.DATABASE.postgresql
NUMBER
NUMERIC

Example

DDL example:

CREATE TABLE Sample_Table (
  Col_01_NUMERIC_18_0 NUMERIC(18) COMMENT 'BQ type: INT64',
  Col_02_NUMERIC_18_1 NUMERIC(18, 1) COMMENT 'BQ type: FLOAT64',
  Col_03_NUMERIC_19 NUMERIC(19) COMMENT 'BQ type: NUMERIC',
  Col_04_NUMERIC_ASTERISK NUMBER(*, 0) COMMENT 'BQ type: NUMERIC',
  Col_05_NUMERIC DECIMAL COMMENT 'BQ type: Ora/Postgres - NUMERIC / Other - INT64'
);

Related issues

45 Oracle NUMBER(*,0) format causes column parsing to stop