Skip to content

Commit

Permalink
Merge pull request #4 from madlandev/bug/create_schema_as_array_of_di…
Browse files Browse the repository at this point in the history
…ctionaries

create schema in a new structure of array of dictionaries
  • Loading branch information
Ben authored Apr 12, 2018
2 parents 913790a + 57a3878 commit a657725
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions operators/mysql_to_s3_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,15 @@ def execute(self, context):
def get_schema(self, hook, table):
logging.info('Initiating schema retrieval.')
results = list(hook.get_schema(table))
output_dict = {}
output_array = []
for i in results:
new = []
new_dict = {}
for n in i:
if n == 'COLUMN_NAME':
new.insert(0, i[n])
else:
new.insert(1, i[n])
new = [i for i in new if i.islower()]
if len(new) == 2:
new_dict[new[0]] = new[1]
output_dict.update(new_dict)
self.s3_upload(str(output_dict), schema=True)
new_dict['name']=i['COLUMN_NAME']
new_dict['type']=i['COLUMN_TYPE']

if len(new_dict) == 2:
output_array.append(new_dict)
self.s3_upload(json.dumps(output_array), schema=True)

def get_records(self, hook):
logging.info('Initiating record retrieval.')
Expand Down

0 comments on commit a657725

Please sign in to comment.