Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
specify hve namespace for tables (apache#5268)
Browse files Browse the repository at this point in the history
(cherry picked from commit bd24f85)
  • Loading branch information
timifasubaa committed Sep 19, 2018
1 parent 901ea8a commit fa6f188
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions superset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ class CeleryConfig(object):
# contain all the external tables
CSV_TO_HIVE_UPLOAD_DIRECTORY = 'EXTERNAL_HIVE_TABLES/'

# The namespace within hive where the tables created from
# uploading CSVs will be stored.
UPLOADED_CSV_HIVE_NAMESPACE = None

# A dictionary of items that gets merged into the Jinja context for
# SQL Lab. The existing context gets updated with this dictionary,
# meaning values for existing keys get overwritten by the content of this
Expand Down
8 changes: 8 additions & 0 deletions superset/db_engine_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,14 @@ def get_column_names(filepath):
return next(unicodecsv.reader(f, encoding='utf-8-sig'))

table_name = form.name.data
if config.get('UPLOADED_CSV_HIVE_NAMESPACE'):
if '.' in table_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

bucket_path = app.config['CSV_TO_HIVE_UPLOAD_S3_BUCKET']
Expand Down

0 comments on commit fa6f188

Please sign in to comment.