-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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: Visualize SqlLab.Query model data in Explore 📈 #20281
Conversation
012e881
to
fb58c99
Compare
> columns are loading into page
fb58c99
to
632ce21
Compare
4cb2626
to
c8caf51
Compare
@@ -29,6 +29,7 @@ export default class DatasourceKey { | |||
this.id = parseInt(idStr, 10); | |||
this.type = | |||
typeStr === 'table' ? DatasourceType.Table : DatasourceType.Druid; | |||
this.type = typeStr === 'query' ? DatasourceType.Query : this.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.
make this into a switch statement
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.
you can remove DatasourceType.Druid
c8caf51
to
7d6fd62
Compare
…ype is Query [41493] Initial commit to add ability for the a Query Preview Modal to be available when the data source type is Query and not Dataset Converted ModalTrigger to a functional TypeScript component
> allow for all records to be displayed > fix select with all columns queries > filters are now working
@@ -244,7 +244,13 @@ class DatasourceControl extends React.PureComponent { | |||
return ( | |||
<Styles data-test="datasource-control" className="DatasourceControl"> | |||
<div className="data-container"> | |||
<Icons.DatasetPhysical className="dataset-svg" /> | |||
{/* todo(hughhh): move this into a function */} | |||
{datasource.type === DatasourceType.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.
Is this supposed to be an if and then statement?
@@ -80,6 +80,11 @@ def create( | |||
|
|||
# pylint: disable=no-self-use | |||
def _convert_to_model(self, datasource: DatasourceDict) -> BaseDatasource: | |||
return ConnectorRegistry.get_datasource( | |||
str(datasource["type"]), int(datasource["id"]), db.session | |||
from superset.dao.datasource.dao import DatasourceDAO |
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 there a benefit to importing this in the function versus globally
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 are currently getting circuliar dependency issues if we don't wrap the imports in the functions, we have another ticket addressing how to fix this.
superset/models/sql_lab.py
Outdated
return self.extra.get("columns", []) | ||
def columns(self) -> List[ResultSetColumnType]: | ||
# todo(hughhh): move this logic into a base class | ||
from superset.utils.core import GenericDataType |
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 why import this here?
…hart-power-query
7d6fd62
to
e076f13
Compare
…pes from DatasourceTypes options
…/query-preview-modal-for-chart-source-query
/testenv up |
f58c753
to
15d530c
Compare
…hart-power-query
7a70c8d
to
2a57a4f
Compare
2a57a4f
to
555d26b
Compare
const { useLegacyApi } = metaDataRegistry.get(vizType); | ||
const vizTypeNeedsDataset = useLegacyApi && datasource.type !== 'dataset'; | ||
|
||
// added boolean column to below show boolean so that the errors aren't overlapping |
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.
liking all the comments!
@zhaoyongjie I have fixes out for these 2 bugs |
@@ -152,11 +153,6 @@ def run(self) -> Optional[Dict[str, Any]]: | |||
except (SupersetException, SQLAlchemyError): | |||
dataset_data = dummy_dataset_data | |||
|
|||
if dataset: |
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.
@hughhhh DatasourceEditor
uses it, without it you would get the Owners is invalid
error every time you try to edit a datasource in explore and you would also see undefined undefined
as owner when loading its info, so before putting it back I'd like to ask if there was any particular reason why we removed it?
|
||
computed_column["column_name"] = col.get("name") | ||
computed_column["groupby"] = True | ||
columns.append(computed_column) |
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 it would it be easier here in the long run to return a column class? columns.append(Column(computed_column))
. Then you wouldn't have to worry about type checking every time you reference the property from a dataset vs a query.
@@ -167,8 +173,54 @@ def sql_tables(self) -> List[Table]: | |||
return list(ParsedQuery(self.sql).tables) | |||
|
|||
@property | |||
def columns(self) -> List[Table]: | |||
return self.extra.get("columns", []) | |||
def columns(self) -> List[ResultSetColumnType]: |
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 there a situation where you think we may need a setter on this property?
|
||
@property | ||
def cache_timeout(self) -> int: | ||
return 0 |
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.
the viz class checks if this is None
and if not, it will look at the database. Should we set this to None
instead?
SUMMARY
Explore view now can accept
datasource_type = 'query
, which representssql_lab.Query
model. Now users will be able to easily chart data from queries being executed in SQL LabScreen.Recording.2022-06-10.at.5.39.41.PM.mov
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
Create Chart
Query
with the SQL icon***OR
select id from query
id
from results returned{ephemeral-url}/superset/explore/query/{id}
ADDITIONAL INFORMATION