[optimizer] Properly skip query history who did not compile
@@ -305,10 +305,12 @@ def _convert_queries(queries_data):
for query_data in queries_data:
try:
- original_query_id = '%s:%s' % struct.unpack(b"QQ", base64.decodestring(query_data['snippets'][0]['result']['handle']['guid']))
- execution_time = query_data['snippets'][0]['result']['executionTime'] * 100
+ snippet = query_data['snippets'][0]
+ if 'guid' in snippet['result']['handle']: # Not failed query
+ original_query_id = '%s:%s' % struct.unpack(b"QQ", base64.decodestring(snippet['result']['handle']['guid']))
+ execution_time = snippet['result']['executionTime'] * 100 if snippet['status'] in ('available', 'expired') else -1
statement = ' '.join([line for line in _get_statement(query_data).strip().splitlines() if not line.strip().startswith('--')])
- queries.append((original_query_id, execution_time, statement, query_data['snippets'][0].get('database', 'default').strip()))
+ queries.append((original_query_id, execution_time, statement, snippet.get('database', 'default').strip()))
except Exception, e:
LOG.warning('Skipping upload of %s: %s' % (query_data['uuid'], e))
