superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject [incubator-superset] branch master updated: use schema form field in upload csv (#5303)
Date Fri, 06 Jul 2018 16:46:57 GMT
This is an automated email from the ASF dual-hosted git repository.

timi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 28ba5a9  use schema form field in upload csv (#5303)
28ba5a9 is described below

commit 28ba5a9ddb20ff8129d288481d72c91c579b199e
Author: timifasubaa <30888507+timifasubaa@users.noreply.github.com>
AuthorDate: Fri Jul 6 09:46:53 2018 -0700

    use schema form field in upload csv (#5303)
---
 superset/db_engine_specs.py | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/superset/db_engine_specs.py b/superset/db_engine_specs.py
index 0dc6f9b..0f10d82 100644
--- a/superset/db_engine_specs.py
+++ b/superset/db_engine_specs.py
@@ -1012,16 +1012,25 @@ class HiveEngineSpec(PrestoEngineSpec):
             return tableschema_to_hive_types.get(col_type, 'STRING')
 
         table_name = form.name.data
+        schema_name = form.schema.data
+
         if config.get('UPLOADED_CSV_HIVE_NAMESPACE'):
-            if '.' in table_name:
+            if '.' in table_name or schema_name:
                 raise Exception(
                     "You can't specify a namespace. "
                     'All tables will be uploaded to the `{}` namespace'.format(
                         config.get('HIVE_NAMESPACE')))
             table_name = '{}.{}'.format(
                 config.get('UPLOADED_CSV_HIVE_NAMESPACE'), table_name)
-        filename = form.csv_file.data.filename
+        else:
+            if '.' in table_name and schema_name:
+                raise Exception(
+                    "You can't specify a namespace both in the name of the table "
+                    'and in the schema field. Please remove one')
+            if schema_name:
+                table_name = '{}.{}'.format(schema_name, table_name)
 
+        filename = form.csv_file.data.filename
         bucket_path = config['CSV_TO_HIVE_UPLOAD_S3_BUCKET']
 
         if not bucket_path:


Mime
View raw message