Преглед изворни кода

HUE-4672 [metastore] Gracefully fail if the input file is invalid for an external table

spaztic1215 пре 9 година
родитељ
комит
f3090ca
1 измењених фајлова са 9 додато и 6 уклоњено
  1. 9 6
      apps/beeswax/src/beeswax/create_table.py

+ 9 - 6
apps/beeswax/src/beeswax/create_table.py

@@ -174,12 +174,15 @@ def import_wizard(request, database='default'):
       # Go to step 2: We've just picked the file. Preview it.
       #
       if do_s2_auto_delim:
-        if load_data == 'IMPORT':
-          if not request.fs.isfile(path):
-            raise PopupException(_('Path location must refer to a file if "Import Data" is selected.'))
-        elif load_data == 'EXTERNAL':
-          if not request.fs.isdir(path):
-            raise PopupException(_('Path location must refer to a directory if "Create External Table" is selected.'))
+        try:
+          if load_data == 'IMPORT':
+            if not request.fs.isfile(path):
+              raise PopupException(_('Path location must refer to a file if "Import Data" is selected.'))
+          elif load_data == 'EXTERNAL':
+            if not request.fs.isdir(path):
+              raise PopupException(_('Path location must refer to a directory if "Create External Table" is selected.'))
+        except IOError, e:
+          raise PopupException(_('Path location "%s" is invalid: %s') % (path, e))
 
         delim_is_auto = True
         fields_list, n_cols, s2_delim_form = _delim_preview(request.fs, s1_file_form, encoding, [reader.TYPE for reader in FILE_READERS], DELIMITERS)