-
Notifications
You must be signed in to change notification settings - Fork 12.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
feat: Add additional information to datasets list API endpoint #9959
Conversation
Codecov Report
@@ Coverage Diff @@
## master #9959 +/- ##
==========================================
+ Coverage 71.34% 71.39% +0.05%
==========================================
Files 585 585
Lines 30889 30968 +79
Branches 3237 3261 +24
==========================================
+ Hits 22037 22110 +73
- Misses 8743 8749 +6
Partials 109 109
Continue to review full report at Codecov.
|
"default_endpoint", | ||
"explore_url", | ||
"kind", | ||
"metrics.id", |
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.
Required to join the metrics
to get a count. Same story with columns.id
and slices.id
I'm looking into a FAB change to make this less hacky and more performant.
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.
cc @dpgaspar does that result in round trips for each entry in the page? It seems like a bad idea. Is number of cols/metrics necessary here? Do we have a wireframe for context?
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 should not result in an N+1, given some recent work that Daniel has done. I'll update the ticket with a screenshot of the design.
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.
In general, adding a count of related records is a common problem for webapps and there are performant solutions. I can see us wanting to display similar information in other places, so I recommend we find a performant way forward with FAB.
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.
@willbarrett is preparing a PR on FAB to add the ability to define a custom SQLAlchemy query for the list endpoint, should be a great new feature
superset/connectors/base/models.py
Outdated
@@ -50,6 +50,9 @@ | |||
"series", | |||
] | |||
|
|||
DATASOURCE_TYPE_VIRTUAL = "virtual" |
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.
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.
Tried it out, and something is off with the backref joins from metric, columns and slices the results get truncated. I'll investigate it since your code seems correct
I'm hoping to leverage this change in FAB: dpgaspar/Flask-AppBuilder#1386 to improve this PR. |
@@ -51,6 +52,11 @@ | |||
] | |||
|
|||
|
|||
class DatasourceKind(Enum): |
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.
Most enums i've seen in python have been in SHOUT_CASE, should we be consistent here?
Also, I think if you have this extend str
as well, then instead of returning DatasourceKind.virtual.value
below you can return str(DatasourceKind.virtual)
. see https://github.com/apache/incubator-superset/blob/7f6dbf838e4e527e640a002ce20bf5da1abf4a98/superset/errors.py#L24
@@ -99,6 +105,17 @@ def slices(self) -> RelationshipProperty: | |||
), | |||
) | |||
|
|||
@property | |||
def kind(self) -> str: | |||
if self.sql: |
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.
maybe return DatasourceKind.virtual.value if self.sql else DatasourceKind.physical.value
?
@@ -23,6 +23,7 @@ | |||
import yaml | |||
from sqlalchemy.sql import func | |||
|
|||
import tests.test_app |
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.
should this be included here? I don't see any code that references it
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.
Without this inclusion the test file fails when run in isolation.
@@ -377,7 +402,7 @@ def get_column(self, column_name: Optional[str]) -> Optional["BaseColumn"]: | |||
|
|||
@staticmethod | |||
def get_fk_many_from_list( | |||
object_list: List[Any], fkmany: List[Column], fkmany_class: Type, key_attr: str, | |||
object_list: List[Any], fkmany: List[Column], fkmany_class: Type, key_attr: str |
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.
hmm, why'd we lose the trailing comma here? Are you on the right version of black?
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.
Let's avoid digging into styling changes that pass CI.
@@ -35,6 +35,7 @@ | |||
DateTime, | |||
desc, | |||
ForeignKey, | |||
func, |
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 somewhat perplexed why the imports have changed on this file as they don't seem to be used. Maybe this branch should be rebased against master
.
Closing this until the requried FAB change is incorporated. |
SUMMARY
Preset would like to add some more information to the new React-based Datasets list view. We're looking to add:
This PR adds the requested information to the API endpoint.
Changes are to support this UI
TEST PLAN
ADDITIONAL INFORMATION
Reviewers
@dpgaspar @nytai