Skip to content

Commit a657725

Browse files
author
Ben
authored
Merge pull request #4 from madlandev/bug/create_schema_as_array_of_dictionaries
create schema in a new structure of array of dictionaries
2 parents 913790a + 57a3878 commit a657725

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

operators/mysql_to_s3_operator.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,15 @@ def execute(self, context):
8585
def get_schema(self, hook, table):
8686
logging.info('Initiating schema retrieval.')
8787
results = list(hook.get_schema(table))
88-
output_dict = {}
88+
output_array = []
8989
for i in results:
90-
new = []
9190
new_dict = {}
92-
for n in i:
93-
if n == 'COLUMN_NAME':
94-
new.insert(0, i[n])
95-
else:
96-
new.insert(1, i[n])
97-
new = [i for i in new if i.islower()]
98-
if len(new) == 2:
99-
new_dict[new[0]] = new[1]
100-
output_dict.update(new_dict)
101-
self.s3_upload(str(output_dict), schema=True)
91+
new_dict['name']=i['COLUMN_NAME']
92+
new_dict['type']=i['COLUMN_TYPE']
93+
94+
if len(new_dict) == 2:
95+
output_array.append(new_dict)
96+
self.s3_upload(json.dumps(output_array), schema=True)
10297

10398
def get_records(self, hook):
10499
logging.info('Initiating record retrieval.')

0 commit comments

Comments
 (0)