@query_error_handler
  def execute(self, notebook, snippet):
    from search.conf import SOLR_URL

    api = NativeSolrApi(SOLR_URL.get(), self.user.username)

    collection = self.options.get('collection') or snippet.get('database')
    if not collection or collection == 'default':
      collection = api.collections2()[0]

    response = api.sql(collection, snippet['statement'])

    info = response['result-set']['docs'].pop(-1) # EOF, RESPONSE_TIME, EXCEPTION
    if info.get('EXCEPTION'):
      raise QueryError(info['EXCEPTION'])

    headers = []
    for row in response['result-set']['docs']:
      for col in row.keys():
        if col not in headers:
          headers.append(col)

    data = [[doc.get(col) for col in headers] for doc in response['result-set']['docs']]
    has_result_set = bool(data)

    return {
      'sync': True,
      'has_result_set': has_result_set,
      'modified_row_count': 0,
      'result': {
        'has_more': False,
        'data': data if has_result_set else [],
        'meta': [{
          'name': col,
          'type': '',
          'comment': ''
        } for col in headers] if has_result_set else [],
        'type': 'table'
      },
      'statement_id': 0,
      'has_more_statements': False,
      'statements_count': 1
    }
dataset/ETHPy150Open cloudera/hue/desktop/libs/notebook/src/notebook/connectors/solr.py/SolrApi.execute/original