瀏覽代碼

HUE-8840 [catalog] Fix import to non hive tables

jdesjean 6 年之前
父節點
當前提交
3911e37ea2

+ 1 - 1
apps/metastore/src/metastore/static/metastore/js/metastore.model.js

@@ -986,7 +986,7 @@ var MetastoreTable = (function () {
   MetastoreTable.prototype.showImportData = function () {
     var self = this;
     $("#import-data-modal").empty().html('<div class="modal-header"><button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span></button><h2 class="modal-title"></h2></div><div class="modal-body"><i class="fa fa-spinner fa-spin fa-2x muted"></i></div>').modal("show");
-    $.get('/metastore/table/' + self.catalogEntry.path.join('/') + '/load', function (data) {
+    $.get('/metastore/table/' + self.catalogEntry.path.join('/') + '/load?source_type=' + self.catalogEntry.getSourceType(), function (data) {
       $("#import-data-modal").html(data['data']);
     }).fail(function (xhr) {
       $(document).trigger("error", xhr.responseText);

+ 1 - 0
apps/metastore/src/metastore/templates/popups/load_data.mako

@@ -27,6 +27,7 @@ from django.utils.translation import ugettext as _
     </div>
     <div class="modal-body">
         <input id="load_data_is_embeddable" type="hidden" name="is_embeddable" value="false">
+        <input id="load_data_source_type" type="hidden" name="source_type" value="${ source_type }">
         <input type="hidden" name="start_time" value=""/>
 
         <div class="control-group">

+ 5 - 4
apps/metastore/src/metastore/views.py

@@ -97,7 +97,7 @@ def databases(request):
 
 @check_has_write_access_permission
 def drop_database(request):
-  source_type = request.POST.get('source_type', 'hive')
+  source_type = request.POST.get('source_type', request.GET.get('source_type', 'hive'))
   cluster = json.loads(request.POST.get('cluster', '{}'))
 
   db = _get_db(user=request.user, source_type=source_type, cluster=cluster)
@@ -297,7 +297,7 @@ def get_table_metadata(request, database, table):
 def describe_table(request, database, table):
   app_name = get_app_name(request)
   cluster = json.loads(request.POST.get('cluster', '{}'))
-  source_type = request.POST.get('source_type')
+  source_type = request.POST.get('source_type', request.GET.get('source_type', 'hive'))
   db = _get_db(user=request.user, source_type=source_type, cluster=cluster)
 
   try:
@@ -431,7 +431,7 @@ def alter_column(request, database, table):
 
 @check_has_write_access_permission
 def drop_table(request, database):
-  source_type = request.POST.get('source_type', 'hive')
+  source_type = request.POST.get('source_type', request.GET.get('source_type', 'hive'))
   cluster = json.loads(request.POST.get('cluster', '{}'))
 
   db = _get_db(user=request.user, source_type=source_type, cluster=cluster)
@@ -493,7 +493,7 @@ def read_table(request, database, table):
 def load_table(request, database, table):
   response = {'status': -1, 'data': 'None'}
 
-  source_type = request.POST.get('source_type', 'hive')
+  source_type = request.POST.get('source_type', request.GET.get('source_type', 'hive'))
   cluster = json.loads(request.POST.get('cluster', '{}'))
 
   db = _get_db(user=request.user, source_type=source_type, cluster=cluster)
@@ -545,6 +545,7 @@ def load_table(request, database, table):
     popup = render('popups/load_data.mako', request, {
            'table': table,
            'load_form': load_form,
+           'source_type': source_type,
            'database': database,
            'app_name': 'beeswax'
        }, force_template=True).content

+ 1 - 1
desktop/core/src/desktop/js/ko/components/contextPopover/dataCatalogContext.js

@@ -199,7 +199,7 @@ class DataCatalogContext {
       '/metastore/table' +
         (self.catalogEntry().isTableOrView() ? '/' : 's/') +
         self.catalogEntry().path.join('/') +
-        '?source=' +
+        '?source_type=' +
         self.catalogEntry().getSourceType() +
         '&namespace=' +
         self.catalogEntry().namespace.id