Skip to content

Commit

Permalink
use schema form field in upload csv (apache#5303)
Browse files Browse the repository at this point in the history
(cherry picked from commit 28ba5a9)
  • Loading branch information
timifasubaa committed Sep 19, 2018
1 parent fa6f188 commit 467c043
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions superset/db_engine_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -910,17 +910,26 @@ def get_column_names(filepath):
return next(unicodecsv.reader(f, encoding='utf-8-sig'))

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)

bucket_path = app.config['CSV_TO_HIVE_UPLOAD_S3_BUCKET']
filename = form.csv_file.data.filename
bucket_path = config['CSV_TO_HIVE_UPLOAD_S3_BUCKET']

if not bucket_path:
logging.info('No upload bucket specified')
Expand Down

0 comments on commit 467c043

Please sign in to comment.