|
|
@@ -61,7 +61,10 @@ def check_has_write_access_permission(view_func):
|
|
|
"""
|
|
|
def decorate(request, *args, **kwargs):
|
|
|
if not has_write_access(request.user):
|
|
|
- raise PopupException(_('You are not allowed to modify the metastore.'), detail=_('You have must have metastore:write permissions'), error_code=301)
|
|
|
+ raise PopupException(
|
|
|
+ _('You are not allowed to modify the metastore.'),
|
|
|
+ detail=_('You have must have metastore:write permissions'), error_code=301
|
|
|
+ )
|
|
|
|
|
|
return view_func(request, *args, **kwargs)
|
|
|
return wraps(view_func)(decorate)
|
|
|
@@ -111,7 +114,11 @@ def drop_database(request):
|
|
|
|
|
|
try:
|
|
|
if request.POST.get('is_embeddable'):
|
|
|
- design = SavedQuery.create_empty(app_name=source_type if source_type != 'hive' else 'beeswax', owner=request.user, data=hql_query('').dumps())
|
|
|
+ design = SavedQuery.create_empty(
|
|
|
+ app_name=source_type if source_type != 'hive' else 'beeswax',
|
|
|
+ owner=request.user,
|
|
|
+ data=hql_query('').dumps()
|
|
|
+ )
|
|
|
last_executed = json.loads(request.POST.get('start_time', '-1'))
|
|
|
cluster = json.loads(request.POST.get('cluster', '{}'))
|
|
|
namespace = json.loads(request.POST.get('namespace', '{}'))
|
|
|
@@ -132,7 +139,10 @@ def drop_database(request):
|
|
|
else:
|
|
|
design = SavedQuery.create_empty(app_name='beeswax', owner=request.user, data=hql_query('').dumps())
|
|
|
query_history = db.drop_databases(databases, design)
|
|
|
- url = reverse('beeswax:watch_query_history', kwargs={'query_history_id': query_history.id}) + '?on_success_url=' + reverse('metastore:databases')
|
|
|
+ url = reverse(
|
|
|
+ 'beeswax:watch_query_history',
|
|
|
+ kwargs={'query_history_id': query_history.id}
|
|
|
+ ) + '?on_success_url=' + reverse('metastore:databases')
|
|
|
return redirect(url)
|
|
|
except Exception as ex:
|
|
|
error_message, log = dbms.expand_exception(ex, db)
|
|
|
@@ -416,7 +426,15 @@ def alter_column(request, database, table):
|
|
|
comment = request.POST.get('comment', None)
|
|
|
partition_spec = request.POST.get('partition_spec', None)
|
|
|
|
|
|
- column_obj = db.alter_column(database, table, column, new_column_name, new_column_type, comment=comment, partition_spec=partition_spec)
|
|
|
+ column_obj = db.alter_column(
|
|
|
+ database,
|
|
|
+ table,
|
|
|
+ column,
|
|
|
+ new_column_name,
|
|
|
+ new_column_type,
|
|
|
+ comment=comment,
|
|
|
+ partition_spec=partition_spec
|
|
|
+ )
|
|
|
|
|
|
response['status'] = 0
|
|
|
response['data'] = {
|
|
|
@@ -468,7 +486,10 @@ def drop_table(request, database):
|
|
|
# Can't be simpler without an important refactoring
|
|
|
design = SavedQuery.create_empty(app_name='beeswax', owner=request.user, data=hql_query('').dumps())
|
|
|
query_history = db.drop_tables(database, tables_objects, design, skip_trash=skip_trash)
|
|
|
- url = reverse('beeswax:watch_query_history', kwargs={'query_history_id': query_history.id}) + '?on_success_url=' + reverse('metastore:show_tables', kwargs={'database': database})
|
|
|
+ url = reverse(
|
|
|
+ 'beeswax:watch_query_history',
|
|
|
+ kwargs={'query_history_id': query_history.id}
|
|
|
+ ) + '?on_success_url=' + reverse('metastore:show_tables', kwargs={'database': database})
|
|
|
return redirect(url)
|
|
|
except Exception as ex:
|
|
|
error_message, log = dbms.expand_exception(ex, db)
|
|
|
@@ -488,7 +509,10 @@ def read_table(request, database, table):
|
|
|
|
|
|
try:
|
|
|
query_history = db.select_star_from(database, table)
|
|
|
- url = reverse('beeswax:watch_query_history', kwargs={'query_history_id': query_history.id}) + '?on_success_url=&context=table:%s:%s' % (table.name, database)
|
|
|
+ url = reverse(
|
|
|
+ 'beeswax:watch_query_history',
|
|
|
+ kwargs={'query_history_id': query_history.id}
|
|
|
+ ) + '?on_success_url=&context=table:%s:%s' % (table.name, database)
|
|
|
return redirect(url)
|
|
|
except Exception as e:
|
|
|
raise PopupException(_('Cannot read table'), detail=e)
|
|
|
@@ -511,7 +535,11 @@ def load_table(request, database, table):
|
|
|
on_success_url = reverse('metastore:describe_table', kwargs={'database': database, 'table': table.name})
|
|
|
generate_ddl_only = request.POST.get('is_embeddable', 'false') == 'true'
|
|
|
try:
|
|
|
- design = SavedQuery.create_empty(app_name=source_type if source_type != 'hive' else 'beeswax', owner=request.user, data=hql_query('').dumps())
|
|
|
+ design = SavedQuery.create_empty(
|
|
|
+ app_name=source_type if source_type != 'hive' else 'beeswax',
|
|
|
+ owner=request.user,
|
|
|
+ data=hql_query('').dumps()
|
|
|
+ )
|
|
|
form_data = {
|
|
|
'path': load_form.cleaned_data['path'],
|
|
|
'overwrite': load_form.cleaned_data['overwrite'],
|
|
|
@@ -532,7 +560,10 @@ def load_table(request, database, table):
|
|
|
)
|
|
|
response = job.execute(request)
|
|
|
else:
|
|
|
- url = reverse('beeswax:watch_query_history', kwargs={'query_history_id': query_history.id}) + '?on_success_url=' + on_success_url
|
|
|
+ url = reverse(
|
|
|
+ 'beeswax:watch_query_history',
|
|
|
+ kwargs={'query_history_id': query_history.id}
|
|
|
+ ) + '?on_success_url=' + on_success_url
|
|
|
response['status'] = 0
|
|
|
response['data'] = url
|
|
|
response['query_history_id'] = query_history.id
|
|
|
@@ -600,7 +631,7 @@ def describe_partitions(request, database, table):
|
|
|
}, {
|
|
|
'name': table,
|
|
|
'url': reverse('metastore:describe_table', kwargs={'database': database, 'table': table})
|
|
|
- },{
|
|
|
+ }, {
|
|
|
'name': 'partitions',
|
|
|
'url': reverse('metastore:describe_partitions', kwargs={'database': database, 'table': table})
|
|
|
},
|
|
|
@@ -667,7 +698,10 @@ def read_partition(request, database, table, partition_spec):
|
|
|
try:
|
|
|
decoded_spec = urllib.parse.unquote(partition_spec)
|
|
|
query = db.get_partition(database, table, decoded_spec)
|
|
|
- url = reverse('beeswax:watch_query_history', kwargs={'query_history_id': query.id}) + '?on_success_url=&context=table:%s:%s' % (table, database)
|
|
|
+ url = reverse(
|
|
|
+ 'beeswax:watch_query_history',
|
|
|
+ kwargs={'query_history_id': query.id}
|
|
|
+ ) + '?on_success_url=&context=table:%s:%s' % (table, database)
|
|
|
return redirect(url)
|
|
|
except Exception as e:
|
|
|
raise PopupException(_('Cannot read partition'), detail=e.message)
|
|
|
@@ -722,7 +756,8 @@ def has_write_access(user):
|
|
|
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']:
|
|
|
+ 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']
|