Browse Source

HUE-7248 [adls] fix export to file

jdesjean 8 years ago
parent
commit
a66e51d

+ 0 - 2
desktop/libs/notebook/src/notebook/api.py

@@ -632,7 +632,6 @@ def export_result(request):
   api = get_api(request, snippet)
 
   if data_format == 'hdfs-file': # Blocking operation, like downloading
-    destination = request.fs.netnormpath(destination)
     if request.fs.isdir(destination):
       if notebook.get('name'):
         destination += '/%(name)s.csv' % notebook
@@ -673,7 +672,6 @@ def export_result(request):
       'allowed': True
     }
   elif data_format == 'hdfs-directory':
-    destination = request.fs.netnormpath(destination)
     if is_embedded:
       sql, success_url = api.export_large_data_to_hdfs(notebook, snippet, destination)
 

+ 1 - 1
desktop/libs/notebook/src/notebook/connectors/hiveserver2.py

@@ -525,7 +525,7 @@ ALTER TABLE `%(table)s` SET TBLPROPERTIES('EXTERNAL'='TRUE');
 DROP TABLE IF EXISTS `%(table)s`;
     ''' % {
       'table': _get_snippet_name(notebook, unique=True, table_format=True),
-      'location': destination,
+      'location': self.request.fs.netnormpath(destination),
       'hql': query.hql_query
     }
     success_url = '/filebrowser/view=%s' % destination

+ 18 - 1
desktop/libs/notebook/src/notebook/tests.py

@@ -24,7 +24,7 @@ from django.contrib.auth.models import User
 from django.core.urlresolvers import reverse
 
 from desktop.lib.django_test_util import make_logged_in_client
-from desktop.lib.test_utils import grant_access
+from desktop.lib.test_utils import grant_access, add_permission
 from desktop.models import Directory, Document, Document2
 from hadoop import cluster as originalCluster
 
@@ -306,6 +306,7 @@ class MockFs():
     self.logical_name = logical_name if logical_name else ''
     self.DEFAULT_USER = 'test'
     self.user = 'test'
+    self._filebrowser_action = ''
 
   def setuser(self, user):
     self.user = user
@@ -323,6 +324,9 @@ class MockFs():
   def isdir(self, path):
     return path == '/user/hue'
 
+  def filebrowser_action(self):
+    return self._filebrowser_action
+
 
 class TestNotebookApiMocked(object):
 
@@ -346,6 +350,7 @@ class TestNotebookApiMocked(object):
     grant_access("test", "default", "beeswax")
     grant_access("not_perm_user", "default", "notebook")
     grant_access("not_perm_user", "default", "beeswax")
+    add_permission('test', 'has_adls', permname='adls_access', appname='filebrowser')
 
   def tearDown(self):
     notebook.connectors.hiveserver2.HS2Api = notebook.connectors.hiveserver2.original_HS2Api
@@ -401,6 +406,18 @@ class TestNotebookApiMocked(object):
     assert_equal(0, data['status'], data)
     assert_equal('/user/hue/path.csv', data['watch_url']['destination'], data)
 
+    response = self.client.post(reverse('notebook:export_result'), {
+        'notebook': notebook_json,
+        'snippet': json.dumps(json.loads(notebook_json)['snippets'][0]),
+        'format': json.dumps('hdfs-file'),
+        'destination': json.dumps('adl:/user/hue/path.csv'),
+        'overwrite': json.dumps(False)
+    })
+
+    data = json.loads(response.content)
+    assert_equal(0, data['status'], data)
+    assert_equal('adl:/user/hue/path.csv', data['watch_url']['destination'], data)
+
 
 def test_get_interpreters_to_show():
   default_interpreters = OrderedDict((