Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_bq_ddl(test_case):
# Get test data
data = TEST_DATA_DDL[test_case]
# Parse ddl
table = DdlParse().parse(data["source_ddl"])
# Check generate BigQuery DDL statements of DdlParseTable
assert table.to_bigquery_ddl() == textwrap.dedent(data["bq_ddl"][DdlParse.NAME_CASE.original])
assert table.to_bigquery_ddl(DdlParse.NAME_CASE.original) == textwrap.dedent(data["bq_ddl"][DdlParse.NAME_CASE.original])
assert table.to_bigquery_ddl(DdlParse.NAME_CASE.lower) == textwrap.dedent(data["bq_ddl"][DdlParse.NAME_CASE.lower])
assert table.to_bigquery_ddl(DdlParse.NAME_CASE.upper) == textwrap.dedent(data["bq_ddl"][DdlParse.NAME_CASE.upper])
Col_05 DATETIME NOT NULL,
Col_06 BOOL
)""",
DdlParse.NAME_CASE.lower:
"""\
#standardSQL
CREATE TABLE `project.dataset.test_table`
(
col_01 STRING NOT NULL,
col_02 STRING NOT NULL,
col_03 INT64,
col_04 FLOAT64,
col_05 DATETIME NOT NULL,
col_06 BOOL
)""",
DdlParse.NAME_CASE.upper:
"""\
#standardSQL
CREATE TABLE `project.dataset.TEST_TABLE`
(
COL_01 STRING NOT NULL,
COL_02 STRING NOT NULL,
COL_03 INT64,
COL_04 FLOAT64,
COL_05 DATETIME NOT NULL,
COL_06 BOOL
)""",
},
},
"datatype_postgres": {
"source_ddl":
"""