Skip to content

Commit 3aad72c

Browse files
committed
reformat schematicdb code
1 parent a31f438 commit 3aad72c

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

schematic/store/synapse.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,14 +1412,20 @@ def make_synapse_table(self,
14121412
elif manipulation == 'replace':
14131413
# remove rows
14141414
self.syn.delete(existing_results)
1415-
1416-
# wait for row deletion to finish on synapse
1415+
# wait for row deletion to finish on synapse before getting empty table
14171416
sleep(1)
14181417

1419-
table_schema_by_cname = self._get_table_schema_by_cname(column_type_dictionary)
1418+
# removes all current columns
1419+
current_table = self.syn.get(existingTableId)
1420+
current_columns = self.syn.getTableColumns(current_table)
1421+
for col in current_columns:
1422+
current_table.removeColumn(col)
14201423

14211424
if not table_name:
14221425
table_name = datasetName + 'table'
1426+
1427+
# Process columns according to manifest entries
1428+
table_schema_by_cname = self._get_table_schema_by_cname(column_type_dictionary)
14231429
datasetParentProject = self.getDatasetProject(dataset_id)
14241430
if specify_schema:
14251431
if column_type_dictionary == {}:
@@ -1445,6 +1451,16 @@ def make_synapse_table(self,
14451451

14461452
#TODO add warning that the given col was not found and it's max size is set to 100
14471453
cols.append(Column(name=col, columnType='STRING', maximumSize=100))
1454+
1455+
# adds new columns to schema
1456+
for col in cols:
1457+
current_table.addColumn(col)
1458+
self.syn.store(current_table, isRestricted = restrict)
1459+
1460+
# wait for synapse store to finish
1461+
sleep(1)
1462+
1463+
# build schema and table from columns and store with necessary restrictions
14481464
schema = Schema(name=table_name, columns=cols, parent=datasetParentProject)
14491465
schema.id = existingTableId
14501466
table = Table(schema, table_to_load, etag = existing_results.etag)

0 commit comments

Comments
 (0)