-
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
feat(explore): Frontend implementation of dataset creation from infobox #19855
feat(explore): Frontend implementation of dataset creation from infobox #19855
Conversation
/testenv up |
@lyndsiWilliams Container image not yet published for this PR. Please try again when build is complete. |
@lyndsiWilliams Ephemeral environment creation failed. Please check the Actions logs for details. |
/testenv up |
@lyndsiWilliams Ephemeral environment spinning up at http://54.68.5.95:8080. Credentials are |
Codecov Report
@@ Coverage Diff @@
## master #19855 +/- ##
==========================================
- Coverage 66.65% 66.61% -0.05%
==========================================
Files 1729 1733 +4
Lines 64910 64953 +43
Branches 6842 6858 +16
==========================================
Hits 43268 43268
- Misses 19893 19929 +36
- Partials 1749 1756 +7
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Thanks @lyndsiWilliams ! Two things:
|
|
/testenv up |
@lyndsiWilliams Ephemeral environment spinning up at http://50.112.74.36:8080. Credentials are |
Closing and reopening to reset ephemeral environment. |
Ephemeral environment shutdown and build artifacts deleted. |
/testenv up |
@lyndsiWilliams Ephemeral environment spinning up at http://52.88.44.27:8080. Credentials are |
@jess-dillard @yousoph Thanks for the feedback! I implemented the changes in |
@lyndsiWilliams Looks good to me (assuming the width issue is on the ephemeral – your screenshot looks good). |
DatasetOwner, | ||
DatasetOptionAutocomplete, | ||
updateDataset, | ||
} from 'src/SqlLab/components/ResultSet'; |
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.
we should centralize this in a types file now instead of pulling it from ResultSet
Can you move this to superset/superset-frontend/src/SqlLab/types.ts
and import from there
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.
Can do! Done in this commit
@@ -190,6 +217,35 @@ export default function DataSourcePanel({ | |||
[_columns], | |||
); | |||
|
|||
const placeholderSlDataset = { | |||
sl_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.
why are we using arrays as placeholders here?
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 wasn't sure what these properties were going to be but thought I needed to pass in something as a placeholder until the back end is implemented. Turns out I don't need it, so I removed it in this commit
. Thanks for this catch!
@@ -65,6 +65,11 @@ export interface DatasourceMeta { | |||
granularity_sqla?: string; | |||
datasource_name: string | null; | |||
description: string | null; | |||
sl_dataset?: { | |||
sl_table?: any; |
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.
can we cast these to values we actually want them to be
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.
Do you know what the types for these will be? I was going to figure that out once the backend came through and change it then.
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.
@eschutho shouldn't the model look like this since sl_dataset it's own entity
sl_datasource?: {
sl_dataset: any;
sl_table?: any;
query?: any;
saved_query?: any;
};
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 think these values would actually be string options or enum of 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.
So it will look like this?
sl_datasource?: {
sl_dataset: string;
sl_table?: string;
query?: string;
saved_query?: string;
};
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.
On a query, for example, the data structure will look like datasource.query
but there won't be a query on a table, so we should define them separately.
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.
Is the schema for these types anywhere so I can describe them properly?
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 we can just start with Query: superset-frontend/src/SqlLab/types.ts
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.
looks like there's an interface for savedquery here: superset-frontend/src/views/CRUD/welcome/SavedQueries.tsx but don't be confused.. it's named query :)
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.
bring this into the component:
type ExploreDatasource =
Dataset |
Query
Rename DatasourceMeta
to Dataset
}; | ||
|
||
// eslint-disable-next-line no-param-reassign | ||
datasource.sl_dataset = placeholderSlDataset; |
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 think the value that you're looking for is datasource.type
which will come from the api.
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 was the hard coded placeholder that I discussed with you the other day in Slack, but I ended up removing it in this commit
because the example still works. Should I keep it as is or hard code a placeholder again?
datasource.sl_dataset = placeholderSlDataset; | ||
|
||
const getDefaultDatasetName = () => | ||
`${datasource?.sl_dataset?.query.tab} ${moment().format( |
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.
can you just reference the datasource directly? datasource?.query.tab
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's currently no query
on DatasourceMeta, should I add it?
dbId, | ||
datasetToOverwrite.datasetId, | ||
sql, | ||
// TODO: lyndsiWilliams - Define d |
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.
what is this todo for?
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 defined d as any
because I'm not sure what it will be, I wanted to remind myself to define that once data is properly flowing through it and I can figure out what it is.
@@ -287,6 +344,175 @@ export default function DataSourcePanel({ | |||
[lists.columns, showAllColumns], | |||
); | |||
|
|||
const handleOverwriteDataset = async () => { |
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.
can most of this functionality re saving/overwriting the dataset be moved into the dataset modal instead?
newState.savedMetrics = state.datasource.metrics || []; | ||
} | ||
newState.savedMetrics = (datasource as Dataset).metrics || []; | ||
} else newState.options = datasource?.columns; |
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.
@lyndsiWilliams I think we're going to need lines 47-52 applied to query columns as well. Just the filter we can skip.
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.
Done in this commit
😁
columns: datasource?.columns[0]?.hasOwnProperty('filterable') | ||
? (datasource as Dataset)?.columns.filter(c => c.filterable) | ||
: datasource?.columns || [], | ||
savedMetrics: datasource?.hasOwnProperty('metrics') |
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.
do you think we can dry up these three?
datasource?.hasOwnProperty('metrics')
? (datasource as Dataset)?.metrics || []
: DEFAULT_METRICS,
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.
Done in this commit
😁
newState.options = Object.fromEntries( | ||
(options as QueryColumn[])?.map(option => [option.name, option]), | ||
); | ||
newState.options = datasource?.columns; |
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.
@lyndsiWilliams do you think you can dry up lines 45-60 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.
actually, looks like we'll have to wait for the column name property to be the same first. 👍
columns: datasource ? datasource.columns : [], | ||
savedMetrics: datasource ? datasource.metrics : [], | ||
columns: datasource?.columns || [], | ||
savedMetrics: savedMetricsTypeCheck(datasource), |
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.
nice
import { Dataset } from '../types'; | ||
import { DEFAULT_METRICS } from '..'; | ||
|
||
export const savedMetricsTypeCheck = ( |
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.
to be more specific, I would say that this function is either fetching/defining or creating metrics. The type checking is just a side effect, if you wanted to rename this to something that explains what it does a little more succinctly.
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.
Good idea! I changed it to defineSavedMetrics
in this commit
.
return true; | ||
}; | ||
|
||
const datasourceTypeCheck = |
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 would maybe name this something that sounds like a boolean like isValidDatasourceType
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.
Also a good idea! I changed the naming in this commit
.
} | ||
|
||
const temporalColumns = | ||
(datasource as QueryResponse)?.columns.filter(c => c.is_dttm) ?? []; |
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 is the one where let's show all the columns but put the is_dttm ones at the top, since users can't turn on/ off the is_dttm property.
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.
Ohhh yes that's right. I added a sort for this in this commit
.
} | ||
newState.options = options; | ||
} | ||
} else newState.options = datasource?.columns; |
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.
we should still do lines 141 and 142 if this is a query.
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.
Oh good catch, thank you! Fixed in this commit
.
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.
Looks good.. I just left one small suggestion. 🎉
Ephemeral environment shutdown and build artifacts deleted. |
SUMMARY
This is the front end implementation of dataset creation from an infobox in a chart.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
BEFORE:
AFTER:
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION