Ejemplo n.º 1
0
def _get_db(user, source_type=None):
  if source_type is None:
    cluster_config = get_cluster_config(user)
    if FORCE_HS2_METADATA.get() and cluster_config['app_config'].get('editor') and 'hive' in cluster_config['app_config'].get('editor')['interpreter_names']:
      source_type = 'hive'
    else:
      source_type = cluster_config['default_sql_interpreter']

  query_server = get_query_server_config(name=source_type if source_type != 'hive' else 'beeswax')
  return dbms.get(user, query_server)
Ejemplo n.º 2
0
def autocomplete(request, database=None, table=None, column=None, nested=None):
  app_name = None if FORCE_HS2_METADATA.get() else get_app_name(request)

  do_as = request.user
  if (request.user.is_superuser or request.user.has_hue_permission(action="impersonate", app="security")) and 'doas' in request.GET:
    do_as = User.objects.get(username=request.GET.get('doas'))

  db = _get_db(user=do_as, source_type=app_name)

  response = _autocomplete(db, database, table, column, nested)
  return JsonResponse(response)
Ejemplo n.º 3
0
Archivo: views.py Proyecto: mapr/hue
def _get_db(user, source_type=None, cluster=None):
  if source_type is None:
    cluster_config = get_cluster_config(user)
    if FORCE_HS2_METADATA.get() and cluster_config['app_config'].get('editor') and 'hive' in cluster_config['app_config'].get('editor')['interpreter_names']:
      source_type = 'hive'
    else:
      source_type = cluster_config['default_sql_interpreter']

  name = source_type if source_type != 'hive' else 'beeswax'

  query_server = get_query_server_config(name=name, cluster=cluster)
  return dbms.get(user, query_server)
Ejemplo n.º 4
0
Archivo: api.py Proyecto: cloudera/hue
def autocomplete(request, database=None, table=None, column=None, nested=None):
  cluster = request.POST.get('cluster')
  app_name = None if FORCE_HS2_METADATA.get() else get_app_name(request)

  do_as = request.user
  if (is_admin(request.user) or request.user.has_hue_permission(action="impersonate", app="security")) and 'doas' in request.GET:
    do_as = User.objects.get(username=request.GET.get('doas'))

  db = _get_db(user=do_as, source_type=app_name, cluster=cluster)

  response = _autocomplete(db, database, table, column, nested, cluster=cluster)
  return JsonResponse(response)