-
Notifications
You must be signed in to change notification settings - Fork 14.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Import CSV #3643
Import CSV #3643
Conversation
Coverage decreased (-0.6%) to 69.514% when pulling 94fcd20fe7b5f38fd871db7dfcba45d9717f7303 on timifasubaa:import_csv into d7f8a7f on apache:master. |
How does this relate to #3533 ? |
Coverage decreased (-0.1%) to 69.967% when pulling 62df140ffd0e0cb5f9a42d74a6927aac50f51b2f on timifasubaa:import_csv into d7f8a7f on apache:master. |
8d392dc
to
eb0ad94
Compare
Coverage decreased (-0.06%) to 70.052% when pulling eb0ad94fa9c350910b3a5d12d9174f30ef286f0c on timifasubaa:import_csv into f871634 on apache:master. |
1 similar comment
Coverage decreased (-0.06%) to 70.052% when pulling eb0ad94fa9c350910b3a5d12d9174f30ef286f0c on timifasubaa:import_csv into f871634 on apache:master. |
eb0ad94
to
3ba69ff
Compare
Coverage increased (+0.2%) to 70.321% when pulling 3ba69ff7f4c2f7007391141627464fbfc186f630 on timifasubaa:import_csv into f871634 on apache:master. |
3ba69ff
to
b1a3df8
Compare
Coverage decreased (-0.06%) to 70.052% when pulling b1a3df8a9767927d8f7dce8f144368c399fd1e13 on timifasubaa:import_csv into f871634 on apache:master. |
1 similar comment
Coverage decreased (-0.06%) to 70.052% when pulling b1a3df8a9767927d8f7dce8f144368c399fd1e13 on timifasubaa:import_csv into f871634 on apache:master. |
Build doesn't pass... |
The "Not a valid choice" error is coming up for postgres and mysql dbs (the 2 failing toxenvs). Still can't reproduce the error. |
b1a3df8
to
5a36884
Compare
Coverage increased (+0.2%) to 70.584% when pulling 5a36884387df52e006852ca1ffb1959cadb2eb93 on timifasubaa:import_csv into bad6938 on apache:master. |
2 similar comments
Coverage increased (+0.2%) to 70.584% when pulling 5a36884387df52e006852ca1ffb1959cadb2eb93 on timifasubaa:import_csv into bad6938 on apache:master. |
Coverage increased (+0.2%) to 70.584% when pulling 5a36884387df52e006852ca1ffb1959cadb2eb93 on timifasubaa:import_csv into bad6938 on apache:master. |
c85b508
to
11f1238
Compare
Coverage increased (+0.06%) to 70.444% when pulling c85b50856ab1fb2a1dc5f9576f598a2ba1945f4c on timifasubaa:import_csv into bad6938 on apache:master. |
Coverage increased (+0.06%) to 70.444% when pulling 11f12389d5ad0c36bfcad196069427dcf890d3c0 on timifasubaa:import_csv into bad6938 on apache:master. |
11f1238
to
8b68fb0
Compare
Coverage increased (+0.2%) to 70.584% when pulling 8b68fb01f74381285c6c98ab6c4e19a66147cfed on timifasubaa:import_csv into bad6938 on apache:master. |
8b68fb0
to
ac960c6
Compare
@mistercrunch resolved! |
8b07fa0
to
91a0e1d
Compare
Coverage increased (+0.2%) to 70.584% when pulling 91a0e1d1c37ca9d267110c4579d3926cfcedd874 on timifasubaa:import_csv into bad6938 on apache:master. |
1 similar comment
Coverage increased (+0.2%) to 70.584% when pulling 91a0e1d1c37ca9d267110c4579d3926cfcedd874 on timifasubaa:import_csv into bad6938 on apache:master. |
6c05226
to
abdca6f
Compare
@mistercrunch All merge conflicts have been resolved and the build passes again. Can we have this PR reviewed soon and then I can make a follow up PR that adds permissions. |
superset/db_engine_specs.py
Outdated
|
||
@staticmethod | ||
def create_table_from_csv(form, table): | ||
def allowed_file(filename): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit. Rename allowed_file
to _allowed_file`.
superset/db_engine_specs.py
Outdated
logging.info(form.con.data) | ||
engine = create_engine(form.con.data) | ||
engine.execute(sql) | ||
return (True, '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems more Pythonic to return a scalar and raise an exception in the case of the failure.
superset/views/core.py
Outdated
form.if_exists.data = 'append' | ||
all_datasources = db.session.query( | ||
models.Database.sqlalchemy_uri, | ||
models.Database.database_name)\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit. I don't think the \
is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I removed it, I got unexpected indent.
superset/views/core.py
Outdated
form.con.choices += all_datasources | ||
|
||
def form_post(self, form): | ||
def upload_file(csv_file): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit. Rename upload_file
to _upload_file
.
@@ -786,6 +788,46 @@ def test_viz_get_fillna_for_columns(self): | |||
{'name': ' NULL', 'sum__num': 0}, | |||
) | |||
|
|||
def test_import_csv(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding unit tests!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:)
@@ -68,12 +68,12 @@ commands = | |||
[testenv:py27-mysql] | |||
basepython = python2.7 | |||
setenv = | |||
SUPERSET__SQLALCHEMY_DATABASE_URI = mysql://mysqluser:mysqluserpassword@localhost/superset?charset=utf8 | |||
SUPERSET__SQLALCHEMY_DATABASE_URI = mysql://root@localhost/superset?charset=utf8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we changing the user/password for the test databases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It didn't work with the previous credentials. Insufficient privileges for adding a table if I recall correctly.
d6fe866
to
4de9028
Compare
4de9028
to
f854b10
Compare
LGTM |
dumb question... is there an obvious way to see what version this PR became available? |
@TryHarder01 Search for the PR number #3643 in the CHANGELOG. |
@frankhsu no results when I search the change log. Not a huge deal, I was just curious how to track PRs into versions. |
A release is coming soon :) |
* add upload csv button to sources dropdown * upload csv to non-hive datasources * upload csv to hive datasource * update FAQ page * add tests * fix linting errors and merge conflicts * Update .travis.yml * Update tox.ini
* add upload csv button to sources dropdown * upload csv to non-hive datasources * upload csv to hive datasource * update FAQ page * add tests * fix linting errors and merge conflicts * Update .travis.yml * Update tox.ini
This PR allows users to import CSV files to superset. It extends the work that had already been done in #2381 and also adds the new functionality of uploading to a hive datasource.