-
Notifications
You must be signed in to change notification settings - Fork 13.8k
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
fix: chart import error with virtual dataset #19782
fix: chart import error with virtual dataset #19782
Conversation
Codecov Report
@@ Coverage Diff @@
## master #19782 +/- ##
===========================================
- Coverage 66.55% 53.97% -12.59%
===========================================
Files 1692 1692
Lines 64802 64832 +30
Branches 6657 6657
===========================================
- Hits 43129 34990 -8139
- Misses 19973 28142 +8169
Partials 1700 1700
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Not sure why that logic was there in the first place.... @diegomedina248 or @zhaoyongjie do you see any risks here we're not aware of? |
"datasource_type": "view" | ||
if dataset.is_sqllab_view | ||
else "table", | ||
"datasource_type": "table", |
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.
I am not familiar with this part, but the datasource_type = view
seems the correct value here. Here is the schema defination for updating chart.
@betodealmeida could you take a look?
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.
but virtual dataset should have view
as a datasource_type?
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.
I'm also not familiar with this part, so I created a chart from a virtual dataset and it has datasource_type
set to table
. Looking at the source code it seems that "view" here means a database VIEW
, not a virtual dataset, and is only used by the DB engine spec to retrieve the list of views from a given database:
superset/superset/db_engine_specs/base.py
Lines 873 to 879 in 4a835a4
elif datasource_type == "view": | |
all_datasources += database.get_all_view_names_in_schema( | |
schema=schema, | |
force=True, | |
cache=database.table_cache_enabled, | |
cache_timeout=database.table_cache_timeout, | |
) |
So I think this should be table
, and we also need to fix this line:
"datasource_type": "view" if dataset.is_sqllab_view else "table", |
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.
This looks consistent with the current logic, even if it doesn't make sense to me. Can you also fix commands/importers/v1/examples.py
in this PR? Thanks!
"datasource_type": "view" | ||
if dataset.is_sqllab_view | ||
else "table", | ||
"datasource_type": "table", |
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.
I'm also not familiar with this part, so I created a chart from a virtual dataset and it has datasource_type
set to table
. Looking at the source code it seems that "view" here means a database VIEW
, not a virtual dataset, and is only used by the DB engine spec to retrieve the list of views from a given database:
superset/superset/db_engine_specs/base.py
Lines 873 to 879 in 4a835a4
elif datasource_type == "view": | |
all_datasources += database.get_all_view_names_in_schema( | |
schema=schema, | |
force=True, | |
cache=database.table_cache_enabled, | |
cache_timeout=database.table_cache_timeout, | |
) |
So I think this should be table
, and we also need to fix this line:
"datasource_type": "view" if dataset.is_sqllab_view else "table", |
* fix: chart import error with virtual dataset * remove unnecessary comment * resolve comment
* fix: chart import error with virtual dataset * remove unnecessary comment * resolve comment
SUMMARY
This issue was not related to importing/exporting over api.
This was happened through UI as well, and the reason was that we regards virtual dataset as sql lab view.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
BEFORE:
#13237
AFTER:
[DEV] Superset - 19 April 2022 - Watch Video
TESTING INSTRUCTIONS
Check: #13237
ADDITIONAL INFORMATION