Skip to content

Commit c6879d7

Browse files
melange396rzats
authored andcommitted
better data types
1 parent c16ed98 commit c6879d7

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

src/ddl/covid_hosp_schema_io.py

+25-3
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,34 @@ class CovidHospSomething:
2323

2424
YAML_FILENAME = 'covid_hosp_schemadefs.yaml'
2525

26-
TYPE_MAPPING = {
26+
PYTHON_TYPE_MAPPING = {
2727
'int': int,
2828
'float': float,
2929
'str': str,
3030
'fixedstr', str,
31+
'bool': int, # UNCOMMENT: Utils.parse_bool,
3132
'intdate': int, # UNCOMMENT: Utils.int_from_date,
32-
'point': str, # UNCOMMENT: Utils.limited_geocode,
33+
'geocode': str, # UNCOMMENT: Utils.limited_geocode,
34+
}
35+
36+
SQL_TYPE_MAPPING = {
37+
'int': 'INT',
38+
'float': 'DOUBLE',
39+
'str': 'VARCHAR',
40+
'fixedstr': 'CHAR',
41+
'bool': 'TINYINT(1)',
42+
'intdate': 'INT(11)',
43+
'geocode': 'VARCHAR(32)',
44+
}
45+
46+
SOURCE_METADATA_TYPE_MAPPING = {
47+
'int': 'number',
48+
'float': 'number',
49+
'str': 'text',
50+
'fixedstr': 'text',
51+
'bool': 'checkbox/text',
52+
'intdate': 'calendar_date',
53+
'geocode': 'point',
3354
}
3455

3556
MYSQL_COL_NAME_PATTERN = re.compile(r'^[a-zA-Z0-9_]{3,64}$')
@@ -74,7 +95,7 @@ def columns(self, ds_name):
7495
else:
7596
dtype = dtype_cplx
7697
col_width = None
77-
yield {'name': name, 'sql_name': sql_name, 'dtype': dtype, 'col_width:' col_width, 'marshaller': CovidHospSomething.TYPE_MAPPING[dtype]}
98+
yield {'name': name, 'sql_name': sql_name, 'dtype': dtype, 'col_width:' col_width, 'marshaller': CovidHospSomething.PYTHON_TYPE_MAPPING[dtype]}
7899

79100

80101
def add_column(self, ds_name, col_name, dtype, sql_name=None, col_width=None):
@@ -135,6 +156,7 @@ def write_new_definitions(self):
135156
# write migration file for new columns
136157
with open(migration_file, 'w') as f:
137158
# TODO
159+
# NOTE: we dont have column differences here, this cant stay here without that
138160
f.write("\n")
139161

140162
# move files into proper locations

0 commit comments

Comments
 (0)