From 76495cdc348353ba171272167417bf437fd0c64b Mon Sep 17 00:00:00 2001 From: timifasubaa <30888507+timifasubaa@users.noreply.github.com> Date: Fri, 6 Jul 2018 09:46:53 -0700 Subject: [PATCH] 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 0dc6f9b60301f..0f10d82a9d41f 100644 --- a/superset/db_engine_specs.py +++ b/superset/db_engine_specs.py @@ -1012,16 +1012,25 @@ def convert_to_hive_type(col_type): 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: