docs: def infer_table_schema(sparql_results_json):
      """Infer Table Schema from SPARQL results JSON
  
      SPARQL JSON Results Spec:
      https://www.w3.org/TR/2013/REC-sparql11-results-json-20130321
  
      :param sparql_results_json: SPARQL JSON results of a query
      :returns: A schema descriptor for the inferred schema
      :rtype: dict (json)
      """
      if ('results' in sparql_results_json and
              'bindings' in sparql_results_json['results'] and
              len(sparql_results_json['results']['bindings']) > 0):
  
          # SQL results include metadata, SPARQL results don't
          result_metadata = sparql_results_json.get('metadata', [])
          metadata_names = [item['name'] for item in result_metadata]
          result_vars = sparql_results_json['head']['vars']
  
          _verify_unique_names(result_vars, metadata_names)
  
          # SQL results require var name mapping, SPARQL results vars don't
          result_vars_mapping = dict(zip(
              result_vars, (metadata_names
                            if metadata_names != []
                            else result_vars)))
  
          homogeneous_types = _get_types_from_sample(
              result_vars, sparql_results_json)
  
          fields = []
          if homogeneous_types is None:
              for result_var in result_vars:
                  fields.append({
                      'name': result_vars_mapping.get(result_var),
                      'type': 'string'
                  })
          else:
              for index, var in enumerate(result_vars):
                  field = {
                      'name': result_vars_mapping.get(var),
                      'type': infer_table_schema_type_from_rdf_term(
                          homogeneous_types[var].get('type'),
                          homogeneous_types[var].get('datatype')
                      )}
  
                  if 'datatype' in homogeneous_types.get(var):
                      field['rdfType'] = homogeneous_types[var].get('datatype')
  
                  term_metadata = (result_metadata[index]
                                   if result_metadata != [] else {})
                  if 'description' in term_metadata:
                      field['description'] = term_metadata['description']
  
                  fields.append(field)
  
          return _sanitize_schema({'fields': fields})
      elif 'boolean' in sparql_results_json:
          # ASK query results
          return {'fields': [{'name': 'boolean', 'type': 'boolean'}]}
      else:
          warn('Unable to infer table schema from empty query results')
          return None