|
@@ -307,19 +307,25 @@ class SqlAlchemyApi(Api):
|
|
|
|
|
|
|
|
return response
|
|
return response
|
|
|
|
|
|
|
|
|
|
+
|
|
|
@query_error_handler
|
|
@query_error_handler
|
|
|
def progress(self, notebook, snippet, logs=''):
|
|
def progress(self, notebook, snippet, logs=''):
|
|
|
|
|
+ progress = 50
|
|
|
if self.options['url'].startswith('presto://'):
|
|
if self.options['url'].startswith('presto://'):
|
|
|
guid = snippet['result']['handle']['guid']
|
|
guid = snippet['result']['handle']['guid']
|
|
|
handle = CONNECTIONS.get(guid)
|
|
handle = CONNECTIONS.get(guid)
|
|
|
- if not handle:
|
|
|
|
|
- return 50
|
|
|
|
|
- stats = handle['result'].cursor.poll()
|
|
|
|
|
|
|
+ stats = None
|
|
|
|
|
+ try:
|
|
|
|
|
+ if handle:
|
|
|
|
|
+ stats = handle['result'].cursor.poll()
|
|
|
|
|
+ except AssertionError as e:
|
|
|
|
|
+ LOG.warn('Query probably not running anymore: %s' % e)
|
|
|
if not stats:
|
|
if not stats:
|
|
|
- return 100
|
|
|
|
|
|
|
+ progress = 100
|
|
|
stats = stats.get('stats', {})
|
|
stats = stats.get('stats', {})
|
|
|
return stats.get('completedSplits', 0) * 100 // stats.get('totalSplits', 1)
|
|
return stats.get('completedSplits', 0) * 100 // stats.get('totalSplits', 1)
|
|
|
- return 50
|
|
|
|
|
|
|
+ return progress
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@query_error_handler
|
|
@query_error_handler
|
|
|
def fetch_result(self, notebook, snippet, rows, start_over):
|
|
def fetch_result(self, notebook, snippet, rows, start_over):
|
|
@@ -340,6 +346,7 @@ class SqlAlchemyApi(Api):
|
|
|
'type': 'table'
|
|
'type': 'table'
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
def _assign_types(self, results, meta):
|
|
def _assign_types(self, results, meta):
|
|
|
result = results and results[0]
|
|
result = results and results[0]
|
|
|
if result:
|
|
if result:
|
|
@@ -357,6 +364,7 @@ class SqlAlchemyApi(Api):
|
|
|
else:
|
|
else:
|
|
|
meta[index]['type'] = 'STRING_TYPE'
|
|
meta[index]['type'] = 'STRING_TYPE'
|
|
|
|
|
|
|
|
|
|
+
|
|
|
@query_error_handler
|
|
@query_error_handler
|
|
|
def fetch_result_metadata(self):
|
|
def fetch_result_metadata(self):
|
|
|
pass
|
|
pass
|