Skip to content

Commit

Permalink
Merge pull request grpc#10108 from ctiller/foo
Browse files Browse the repository at this point in the history
Sanitize before bigquery upload
  • Loading branch information
ctiller authored Mar 11, 2017
2 parents 56cea8f + bbfb25b commit 1672b7e
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions tools/profiling/microbenchmarks/bm2bq.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@
('framing_bytes_per_iteration', 'float'),
]

SANITIZE = {
'integer': int,
'float': float,
'boolean': bool,
'string': str,
'timestamp': str,
}

if sys.argv[1] == '--schema':
print ',\n'.join('%s:%s' % (k, t.upper()) for k, t in columns)
sys.exit(0)
Expand All @@ -89,7 +97,10 @@
writer = csv.DictWriter(sys.stdout, [c for c,t in columns])

for row in bm_json.expand_json(js, js2):
if 'label' in row:
del row['label']
del row['cpp_name']
writer.writerow(row)
sane_row = {}
for name, sql_type in columns:
if name in row:
if row[name] == '': continue
sane_row[name] = SANITIZE[sql_type](row[name])
writer.writerow(sane_row)

0 comments on commit 1672b7e

Please sign in to comment.