You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/07/06 16:25:21 UTC

[GitHub] [superset] hughhhh opened a new pull request, #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

hughhhh opened a new pull request, #20281:
URL: https://github.com/apache/superset/pull/20281

   <!---
   Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   
   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   Explore view now can accept `datasource_type = 'query`, which represents `sql_lab.Query` model. Now users will be able to easily chart data from queries being executed in SQL Lab
   
   https://user-images.githubusercontent.com/27827808/173101938-4c31864d-0c0b-4fb1-aa5a-6bfdb25123bc.mov
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   1. Go to Sqllab and run a query
   2. Click `Create Chart`
   3. Verify that Chart Source is `Query` with the SQL icon
   
   ***OR
   1. Go to Sqllab and run a query
   2. Then run a `select id from query`
   3. Take one valid `id` from results returned
   4. Enter the following string into the browser `{ephemeral-url}/superset/explore/query/{id}`
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   
   
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r904058768


##########
superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx:
##########
@@ -211,28 +219,30 @@ export const SaveDatasetModal: FunctionComponent<SaveDatasetModalProps> = ({
       return;
     }
 
-    const selectedColumns = query.results.selected_columns || [];
+    const selectedColumns =
+      query?.results?.selected_columns ?? query.columns ?? [];
 
     // The filters param is only used to test jinja templates.
     // Remove the special filters entry from the templateParams
     // before saving the dataset.
+    let templateParams;
     if (query.templateParams) {
       const p = JSON.parse(query.templateParams);
       /* eslint-disable-next-line no-underscore-dangle */
       if (p._filters) {
         /* eslint-disable-next-line no-underscore-dangle */
         delete p._filters;
         // eslint-disable-next-line no-param-reassign
-        query.templateParams = JSON.stringify(p);
+        templateParams = JSON.stringify(p);
       }
     }
 
     dispatch(
       createDatasource({
         schema: query.schema,
         sql: query.sql,
-        dbId: query.dbId,
-        templateParams: query.templateParams,
+        dbId: query?.dbId ?? query?.database?.id,

Review Comment:
   same here.. would 0 be a valid id?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r904092325


##########
superset/models/sql_lab.py:
##########
@@ -179,6 +232,53 @@ def raise_for_access(self) -> None:
 
         security_manager.raise_for_access(query=self)
 
+    @property
+    def db_engine_spec(self) -> Type["BaseEngineSpec"]:
+        return self.database.db_engine_spec
+
+    @property
+    def owners_data(self) -> List[Dict[str, Any]]:
+        return []
+
+    @property
+    def metrics(self) -> List[Any]:

Review Comment:
   are we removing or keeping this? I feel we should be cautious about not adding properties to the model that don't naturally work. Like we shouldn't shoe-horn this model into being something that it's not. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r904094797


##########
superset/utils/core.py:
##########
@@ -1648,21 +1648,35 @@ def extract_dataframe_dtypes(
         "date": GenericDataType.TEMPORAL,
     }
 
-    columns_by_name = (
-        {column.column_name: column for column in datasource.columns}
-        if datasource
-        else {}
-    )
+    # todo(hughhhh): can we make the column_object a Union
+    if datasource and datasource.type == "query":

Review Comment:
   Similar to a comment I left for @eric-briscoe above. I would use duck-typing here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
hughhhh commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r921591579


##########
superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx:
##########
@@ -148,10 +172,10 @@ export const SaveDatasetModal: FunctionComponent<SaveDatasetModalProps> = ({
   const handleOverwriteDataset = async () => {
     const [, key] = await Promise.all([
       updateDataset(
-        query.dbId,
+        datasource.dbId,
         datasetToOverwrite.datasetid,
-        query.sql,
-        query.results.selected_columns.map(
+        datasource.sql,

Review Comment:
   so add chaining here as well, be consistent whenever we change with in the same path.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] github-actions[bot] commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1154539706

   @yousoph Container image not yet published for this PR. Please try again when build is complete.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh commented on a diff in pull request #20281: Chart-power-query

Posted by GitBox <gi...@apache.org>.
hughhhh commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r892552364


##########
superset-frontend/packages/superset-ui-core/src/query/DatasourceKey.ts:
##########
@@ -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;

Review Comment:
   make this into a switch statement



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] github-actions[bot] commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1176404333

   @hughhhh Ephemeral environment spinning up at http://34.219.64.12:8080. Credentials are `admin`/`admin`. Please allow several minutes for bootstrapping and startup.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh closed pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
hughhhh closed pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ
URL: https://github.com/apache/superset/pull/20281


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
hughhhh commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r921594659


##########
superset-frontend/src/explore/components/controls/DatasourceControl/index.jsx:
##########
@@ -224,7 +263,7 @@ class DatasourceControl extends React.PureComponent {
       showSaveDatasetModal,
     } = this.state;
     const { datasource, onChange, theme } = this.props;
-    const isMissingDatasource = datasource.id == null;
+    const isMissingDatasource = datasource?.id == null;

Review Comment:
   `const isMissinDatasource = !!datasource.id` to make this truthy



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r929321108


##########
superset/models/sql_lab.py:
##########
@@ -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]:

Review Comment:
   is there a situation where you think we may need a setter on this property?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
hughhhh commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r902547147


##########
superset/common/query_context_factory.py:
##########
@@ -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

Review Comment:
   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.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
hughhhh commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1165557325

   /testenv up


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r918198880


##########
superset-frontend/src/explore/components/controls/DatasourceControl/index.jsx:
##########
@@ -122,24 +126,62 @@ const EDIT_DATASET = 'edit_dataset';
 const QUERY_PREVIEW = 'query_preview';
 const SAVE_AS_DATASET = 'save_as_dataset';
 
+// If the string is longer than this value's number characters we add
+// a tooltip for user can see the full name by hovering over the visually truncated string in UI
+const VISIBLE_TITLE_LENGTH = 25;
+
+// Assign icon for each DatasourceType.  If no icon assingment is found in the lookup, no icon will render
+export const datasourceIconLookup = {
+  [DatasourceType.Query]: (
+    <Icons.ConsoleSqlOutlined className="datasource-svg" />
+  ),
+  [DatasourceType.Table]: <Icons.DatasetPhysical className="datasource-svg" />,
+};
+
+// Render title for datasource with tooltip only if text is longer than VISIBLE_TITLE_LENGTH
+export const renderDatasourceTitle = (displayString, tooltip) =>
+  displayString.length > VISIBLE_TITLE_LENGTH ? (
+    // Add a tooltip only for long names that will be visually truncated
+    <Tooltip title={tooltip}>
+      <span className="title-select">{displayString}</span>
+    </Tooltip>
+  ) : (
+    <span title={tooltip} className="title-select">
+      {displayString}
+    </span>
+  );
+
+// Different data source types use different attributes for the display title
+export const getDatasourceTitle = datasource =>
+  datasource?.sql ?? datasource?.name ?? '';
+
+// When this is a Query with SQL, we wnt the SQL to be the tooltip
+export const getTooltip = datasource =>
+  datasource?.sql ?? datasource?.name ?? '';
+
 class DatasourceControl extends React.PureComponent {
   constructor(props) {
     super(props);
     this.state = {
       showEditDatasourceModal: false,
       showChangeDatasourceModal: false,
+      showSaveDatasetModal: false,
     };
-    this.onDatasourceSave = this.onDatasourceSave.bind(this);
-    this.toggleChangeDatasourceModal =
-      this.toggleChangeDatasourceModal.bind(this);
-    this.toggleEditDatasourceModal = this.toggleEditDatasourceModal.bind(this);
-    this.toggleShowDatasource = this.toggleShowDatasource.bind(this);
-    this.handleMenuItemClick = this.handleMenuItemClick.bind(this);
-    this.toggleSaveDatasetModal = this.toggleSaveDatasetModal.bind(this);
   }
 
-  onDatasourceSave(datasource) {
-    this.props.actions.changeDatasource(datasource);
+  getDatasourceAsSaveableDataset = source => {
+    const dataset = {
+      columns: source?.columns || [],
+      name: source?.datasource_name || source?.name || t('Untitled'),
+      dbId: source?.database.id,
+      sql: source?.sql || '',
+      schema: source?.schema,
+    };
+    return dataset;

Review Comment:
   nit, but is the const necessary? I think you can just return the object that you're defining. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r918195885


##########
superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx:
##########
@@ -180,6 +202,14 @@ export const SaveDatasetModal: FunctionComponent<SaveDatasetModalProps> = ({
     setShouldOverwriteDataset(false);
     setDatasetToOverwrite({});
     setDatasetName(getDefaultDatasetName());
+    /*
+    exploreChart({
+      ...EXPLORE_CHART_DEFAULT,
+      datasource: `${datasetToOverwrite.datasetId}__table`,
+      all_columns: datasource?.columns?.map?.((d: ISimpleColumn) => d.name),
+      selected_columns: datasource?.columns,
+    });

Review Comment:
   can we remove this commented out code?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
hughhhh commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r918141937


##########
superset/errors.py:
##########
@@ -90,6 +90,9 @@ class SupersetErrorType(str, Enum):
     INVALID_PAYLOAD_FORMAT_ERROR = "INVALID_PAYLOAD_FORMAT_ERROR"
     INVALID_PAYLOAD_SCHEMA_ERROR = "INVALID_PAYLOAD_SCHEMA_ERROR"
 
+    # Dataset/Datasource Errors
+    VIZ_TYPE_REQUIRES_DATASET_ERROR = "VIZ_TYPE_REQUIRES_DATASET_ERROR"

Review Comment:
   remove this



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] yousoph commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
yousoph commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1176818258

   /testenv up


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r917033859


##########
superset-frontend/packages/superset-ui-core/src/query/DatasourceKey.ts:
##########
@@ -29,6 +29,7 @@ export default class DatasourceKey {
     this.id = parseInt(idStr, 10);
     this.type =
       typeStr === 'table' ? DatasourceType.Table : DatasourceType.Druid;

Review Comment:
   is this druid reference still in master? cc @AAfghahi 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
hughhhh commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1155317576

   /testenv up


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r904095207


##########
superset/utils/core.py:
##########
@@ -1648,21 +1648,35 @@ def extract_dataframe_dtypes(
         "date": GenericDataType.TEMPORAL,
     }
 
-    columns_by_name = (
-        {column.column_name: column for column in datasource.columns}
-        if datasource
-        else {}
-    )
+    # todo(hughhhh): can we make the column_object a Union
+    if datasource and datasource.type == "query":
+        columns_by_name = {
+            column.get("column_name"): column for column in datasource.columns
+        }
+    else:
+        columns_by_name = (
+            {column.column_name: column for column in datasource.columns}
+            if datasource
+            else {}
+        )
+
     generic_types: List[GenericDataType] = []
     for column in df.columns:
         column_object = columns_by_name.get(column)
         series = df[column]
         inferred_type = infer_dtype(series)
-        generic_type = (
-            GenericDataType.TEMPORAL
-            if column_object and column_object.is_dttm
-            else inferred_type_map.get(inferred_type, GenericDataType.STRING)
-        )
+        if datasource and datasource.type == "query":  # type: ignore

Review Comment:
   same re: duck typing



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r904069923


##########
superset-frontend/src/explore/components/DatasourcePanel/index.tsx:
##########
@@ -429,24 +444,27 @@ export default function DataSourcePanel({
       columnSlice,
       inputValue,
       lists.columns.length,
-      lists.metrics.length,
+      lists?.metrics?.length,
       metricSlice,
       search,
       showAllColumns,
       showAllMetrics,
+      dataSourceIsQuery,
       shouldForceUpdate,
     ],
   );
 
   return (
     <DatasourceContainer>
-      <SaveDatasetModal
-        visible={showSaveDatasetModal}
-        onHide={() => setShowSaveDatasetModal(false)}
-        buttonTextOnSave={t('Save')}
-        buttonTextOnOverwrite={t('Overwrite')}
-        datasource={datasource}
-      />
+      {dataSourceIsQuery && (

Review Comment:
   this is a bit of a nit, but I would consider flipping this to be `if datasource is not a dataset, then show the modal to save dataset`, only because otherwise, there's business logic in the code.. why does a query show this modal, for example? It's just a little more clear perhaps to do it the opposite way. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r904087362


##########
superset-frontend/src/explore/components/controls/DatasourceControl/index.jsx:
##########
@@ -122,23 +125,59 @@ const EDIT_DATASET = 'edit_dataset';
 const QUERY_PREVIEW = 'query_preview';
 const SAVE_AS_DATASET = 'save_as_dataset';
 
+// If the string is longer than this value's number characters we add
+// a tooltip for user can see the full name by hovering over the visually truncated string in UI
+const VISIBLE_TITLE_LENGTH = 25;
+
+// Assign icon for each DatasourceType.  If no icon assingment is found in the lookup, no icon will render
+export const datasourceIconLookup = {
+  [DatasourceType.Query]: (
+    <Icons.ConsoleSqlOutlined className="datasource-svg" />
+  ),
+  [DatasourceType.Table]: <Icons.DatasetPhysical className="datasource-svg" />,
+};
+
+// Render title for datasource with tooltip only if text is longer than VISIBLE_TITLE_LENGTH
+export const renderDatasourceTitle = displayString =>
+  displayString.length > VISIBLE_TITLE_LENGTH ? (
+    // Add a tooltip only for long names that will be visually truncated
+    <Tooltip title={displayString}>
+      <span className="title-select">{displayString}</span>
+    </Tooltip>
+  ) : (
+    <span title={displayString} className="title-select">
+      {displayString}
+    </span>
+  );
+
+// Different data source types use different attributes for the display title
+export const getDatasourceTitle = datasource => {
+  let text = '';
+  const dataSourceType = datasource?.type;
+  if (dataSourceType) {
+    switch (dataSourceType) {
+      case DatasourceType.Query:
+        text = datasource?.sql ?? '';
+        break;
+      default:
+        text = datasource?.name ?? '';

Review Comment:
   similar comment here re: duck typing. You may want to do something like 'if it has a name use it, otherwise, use sql if it has it', instead of switching on the type.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] github-actions[bot] commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1162086582

   @hughhhh Ephemeral environment spinning up at http://54.203.230.246:8080. Credentials are `admin`/`admin`. Please allow several minutes for bootstrapping and startup.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] Antonio-RiveroMartnez commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
Antonio-RiveroMartnez commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r925570424


##########
superset/explore/commands/get.py:
##########
@@ -152,11 +153,6 @@ def run(self) -> Optional[Dict[str, Any]]:
         except (SupersetException, SQLAlchemyError):
             dataset_data = dummy_dataset_data
 
-        if dataset:

Review Comment:
   @hughhhh `DatasourceEditor` uses it, without it you would get the `Owners is invalid` error every time you try to edit a datasource in explore, so before putting back I'd like to ask if there was any particular reason why we removed it?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r918201232


##########
superset-frontend/src/explore/components/controls/DatasourceControl/index.jsx:
##########
@@ -224,7 +263,7 @@ class DatasourceControl extends React.PureComponent {
       showSaveDatasetModal,
     } = this.state;
     const { datasource, onChange, theme } = this.props;
-    const isMissingDatasource = datasource.id == null;
+    const isMissingDatasource = datasource?.id == null;

Review Comment:
   if datasource is undefined, is the expectation that this value should be true or false?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] AAfghahi commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
AAfghahi commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r918274622


##########
superset-frontend/src/explore/components/controls/DatasourceControl/index.jsx:
##########
@@ -156,33 +198,33 @@ class DatasourceControl extends React.PureComponent {
     if (this.props.onDatasourceSave) {
       this.props.onDatasourceSave(datasource);
     }
-  }
+  };
 
-  toggleShowDatasource() {
+  toggleShowDatasource = () => {
     this.setState(({ showDatasource }) => ({
       showDatasource: !showDatasource,

Review Comment:
   what happens if someone double clicks on the x sign with this logic? Wouldn't it be better to have it change it to false or true instead?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1158193081

   /testenv up


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh closed pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
hughhhh closed pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ
URL: https://github.com/apache/superset/pull/20281


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r917036853


##########
superset-frontend/packages/superset-ui-core/src/query/types/Datasource.ts:
##########
@@ -47,11 +47,17 @@ export interface Datasource {
   };
 }
 
-export const DEFAULT_METRICS = [
+export const DEFAULT_METRICS: Metric[] = [
   {
     metric_name: 'COUNT(*)',
     expression: 'COUNT(*)',
   },
 ];
 
+export const isValidDatasourceType = (datasource: DatasourceType) =>
+  datasource === DatasourceType.Dataset ||

Review Comment:
   can we do something like `datasource in DatasourceType` or do we need to list out all of the types?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] github-actions[bot] commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1155361297

   @hughhhh Ephemeral environment spinning up at http://54.188.75.19:8080. Credentials are `admin`/`admin`. Please allow several minutes for bootstrapping and startup.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
hughhhh commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r921589962


##########
superset-frontend/src/SqlLab/components/ResultSet/index.tsx:
##########
@@ -220,6 +224,15 @@ export default class ResultSet extends React.PureComponent<
       const { showSaveDatasetModal } = this.state;
       const { query } = this.props;
 
+      const dataset: ISaveableDatasource = {

Review Comment:
   change this var to `datasource`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
hughhhh commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1162078921

   /testenv up


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r904065294


##########
superset-frontend/src/explore/components/DatasourcePanel/index.tsx:
##########
@@ -282,22 +293,22 @@ export default function DataSourcePanel({
   }, [columns, datasource, metrics]);
 
   const sortCertifiedFirst = (slice: ColumnMeta[]) =>
-    slice.sort((a, b) => b.is_certified - a.is_certified);
+    slice.sort((a, b) => b?.is_certified - a?.is_certified);
 
   const metricSlice = useMemo(
     () =>
       showAllMetrics
-        ? lists.metrics
-        : lists.metrics.slice(0, DEFAULT_MAX_METRICS_LENGTH),
-    [lists.metrics, showAllMetrics],
+        ? lists?.metrics
+        : lists?.metrics?.slice?.(0, DEFAULT_MAX_METRICS_LENGTH),

Review Comment:
   why the `?` after slice? If metrics is undefined, would be anything else other than an array?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] AAfghahi commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
AAfghahi commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1171594840

   /testenv up


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] github-actions[bot] commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1154539714

   @yousoph Ephemeral environment creation failed. Please check the Actions logs for details.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
hughhhh commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1176399662

   /testenv up


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] github-actions[bot] commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1176446186

   @hughhhh Ephemeral environment creation failed. Please check the Actions logs for details.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
hughhhh commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1176226553

   /testenv up


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r929322869


##########
superset/models/sql_lab.py:
##########
@@ -179,6 +231,53 @@ def raise_for_access(self) -> None:
 
         security_manager.raise_for_access(query=self)
 
+    @property
+    def db_engine_spec(self) -> Type["BaseEngineSpec"]:
+        return self.database.db_engine_spec
+
+    @property
+    def owners_data(self) -> List[Dict[str, Any]]:
+        return []
+
+    @property
+    def uid(self) -> str:
+        return f"{self.id}__{self.type}"
+
+    @property
+    def is_rls_supported(self) -> bool:
+        return False
+
+    @property
+    def cache_timeout(self) -> int:
+        return 0

Review Comment:
   the viz class checks if this is `None` and if not, it will look at the database. Should we set this to `None` instead?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] jinghua-qa commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
jinghua-qa commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1180552355

   /testenv up


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r918197919


##########
superset-frontend/src/explore/components/controls/DatasourceControl/index.jsx:
##########
@@ -122,24 +126,62 @@ const EDIT_DATASET = 'edit_dataset';
 const QUERY_PREVIEW = 'query_preview';
 const SAVE_AS_DATASET = 'save_as_dataset';
 
+// If the string is longer than this value's number characters we add
+// a tooltip for user can see the full name by hovering over the visually truncated string in UI
+const VISIBLE_TITLE_LENGTH = 25;
+
+// Assign icon for each DatasourceType.  If no icon assingment is found in the lookup, no icon will render
+export const datasourceIconLookup = {
+  [DatasourceType.Query]: (
+    <Icons.ConsoleSqlOutlined className="datasource-svg" />
+  ),
+  [DatasourceType.Table]: <Icons.DatasetPhysical className="datasource-svg" />,
+};
+
+// Render title for datasource with tooltip only if text is longer than VISIBLE_TITLE_LENGTH
+export const renderDatasourceTitle = (displayString, tooltip) =>
+  displayString.length > VISIBLE_TITLE_LENGTH ? (
+    // Add a tooltip only for long names that will be visually truncated
+    <Tooltip title={tooltip}>
+      <span className="title-select">{displayString}</span>
+    </Tooltip>
+  ) : (
+    <span title={tooltip} className="title-select">
+      {displayString}
+    </span>
+  );
+
+// Different data source types use different attributes for the display title
+export const getDatasourceTitle = datasource =>
+  datasource?.sql ?? datasource?.name ?? '';
+
+// When this is a Query with SQL, we wnt the SQL to be the tooltip
+export const getTooltip = datasource =>
+  datasource?.sql ?? datasource?.name ?? '';

Review Comment:
   this is the same as get title?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r929316285


##########
superset/models/sql_lab.py:
##########
@@ -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]:
+        bool_types = ("BOOL",)
+        num_types = (
+            "DOUBLE",
+            "FLOAT",
+            "INT",
+            "BIGINT",
+            "NUMBER",
+            "LONG",
+            "REAL",
+            "NUMERIC",
+            "DECIMAL",
+            "MONEY",
+        )
+        date_types = ("DATE", "TIME")
+        str_types = ("VARCHAR", "STRING", "CHAR")
+        columns = []
+        col_type = ""
+        for col in self.extra.get("columns", []):
+            computed_column = {**col}
+            col_type = col.get("type")
+
+            if col_type and any(map(lambda t: t in col_type.upper(), str_types)):
+                computed_column["type_generic"] = GenericDataType.STRING
+            if col_type and any(map(lambda t: t in col_type.upper(), bool_types)):
+                computed_column["type_generic"] = GenericDataType.BOOLEAN
+            if col_type and any(map(lambda t: t in col_type.upper(), num_types)):
+                computed_column["type_generic"] = GenericDataType.NUMERIC
+            if col_type and any(map(lambda t: t in col_type.upper(), date_types)):
+                computed_column["type_generic"] = GenericDataType.TEMPORAL
+
+            computed_column["column_name"] = col.get("name")
+            computed_column["groupby"] = True
+            columns.append(computed_column)

Review Comment:
   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. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
hughhhh commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r918256952


##########
superset-frontend/src/explore/components/controls/DatasourceControl/index.jsx:
##########
@@ -122,23 +125,59 @@ const EDIT_DATASET = 'edit_dataset';
 const QUERY_PREVIEW = 'query_preview';
 const SAVE_AS_DATASET = 'save_as_dataset';
 
+// If the string is longer than this value's number characters we add
+// a tooltip for user can see the full name by hovering over the visually truncated string in UI
+const VISIBLE_TITLE_LENGTH = 25;
+
+// Assign icon for each DatasourceType.  If no icon assingment is found in the lookup, no icon will render
+export const datasourceIconLookup = {
+  [DatasourceType.Query]: (
+    <Icons.ConsoleSqlOutlined className="datasource-svg" />
+  ),
+  [DatasourceType.Table]: <Icons.DatasetPhysical className="datasource-svg" />,
+};
+
+// Render title for datasource with tooltip only if text is longer than VISIBLE_TITLE_LENGTH
+export const renderDatasourceTitle = displayString =>
+  displayString.length > VISIBLE_TITLE_LENGTH ? (
+    // Add a tooltip only for long names that will be visually truncated
+    <Tooltip title={displayString}>
+      <span className="title-select">{displayString}</span>
+    </Tooltip>
+  ) : (
+    <span title={displayString} className="title-select">
+      {displayString}
+    </span>
+  );
+
+// Different data source types use different attributes for the display title
+export const getDatasourceTitle = datasource => {
+  let text = '';
+  const dataSourceType = datasource?.type;
+  if (dataSourceType) {
+    switch (dataSourceType) {
+      case DatasourceType.Query:
+        text = datasource?.sql ?? '';
+        break;
+      default:
+        text = datasource?.name ?? '';

Review Comment:
   `Query` and `SqlaTable` will have `name` associated with it in this context. I think we should leave this how it is for now



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] github-actions[bot] commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1180573978

   @jinghua-qa Container image not yet published for this PR. Please try again when build is complete.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
hughhhh commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1176466092

   /testenv up


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] yousoph commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
yousoph commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1154539344

   /testenv up


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] pkdotson commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
pkdotson commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r922549070


##########
superset-frontend/src/explore/components/ExploreChartPanel.jsx:
##########
@@ -145,9 +149,17 @@ const ExploreChartPanel = ({
     getItem(LocalStorageKeys.chart_split_sizes, INITIAL_SIZES),
   );
 
+  const [showDatasetModal, setShowDatasetModal] = useState(false);
+
+  const metaDataRegistry = getChartMetadataRegistry();
+  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

Review Comment:
   liking all the comments!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh merged pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
hughhhh merged PR #20281:
URL: https://github.com/apache/superset/pull/20281


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r917042860


##########
superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx:
##########
@@ -148,10 +172,10 @@ export const SaveDatasetModal: FunctionComponent<SaveDatasetModalProps> = ({
   const handleOverwriteDataset = async () => {
     const [, key] = await Promise.all([
       updateDataset(
-        query.dbId,
+        datasource.dbId,
         datasetToOverwrite.datasetid,
-        query.sql,
-        query.results.selected_columns.map(
+        datasource.sql,
+        datasource?.columns?.map(

Review Comment:
   we have some datasources that seem optional here (via the optional chaining) and some that aren't. Is that intentional?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] github-actions[bot] commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1163382438

   @hughhhh Ephemeral environment spinning up at http://34.220.26.98:8080. Credentials are `admin`/`admin`. Please allow several minutes for bootstrapping and startup.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r904087362


##########
superset-frontend/src/explore/components/controls/DatasourceControl/index.jsx:
##########
@@ -122,23 +125,59 @@ const EDIT_DATASET = 'edit_dataset';
 const QUERY_PREVIEW = 'query_preview';
 const SAVE_AS_DATASET = 'save_as_dataset';
 
+// If the string is longer than this value's number characters we add
+// a tooltip for user can see the full name by hovering over the visually truncated string in UI
+const VISIBLE_TITLE_LENGTH = 25;
+
+// Assign icon for each DatasourceType.  If no icon assingment is found in the lookup, no icon will render
+export const datasourceIconLookup = {
+  [DatasourceType.Query]: (
+    <Icons.ConsoleSqlOutlined className="datasource-svg" />
+  ),
+  [DatasourceType.Table]: <Icons.DatasetPhysical className="datasource-svg" />,
+};
+
+// Render title for datasource with tooltip only if text is longer than VISIBLE_TITLE_LENGTH
+export const renderDatasourceTitle = displayString =>
+  displayString.length > VISIBLE_TITLE_LENGTH ? (
+    // Add a tooltip only for long names that will be visually truncated
+    <Tooltip title={displayString}>
+      <span className="title-select">{displayString}</span>
+    </Tooltip>
+  ) : (
+    <span title={displayString} className="title-select">
+      {displayString}
+    </span>
+  );
+
+// Different data source types use different attributes for the display title
+export const getDatasourceTitle = datasource => {
+  let text = '';
+  const dataSourceType = datasource?.type;
+  if (dataSourceType) {
+    switch (dataSourceType) {
+      case DatasourceType.Query:
+        text = datasource?.sql ?? '';
+        break;
+      default:
+        text = datasource?.name ?? '';

Review Comment:
   similar comment here re: duck typing. You may want to do something like 'if it has a name use it, otherwise, use sql if it has it'



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r929323292


##########
superset/models/sql_lab.py:
##########
@@ -179,6 +231,53 @@ def raise_for_access(self) -> None:
 
         security_manager.raise_for_access(query=self)
 
+    @property
+    def db_engine_spec(self) -> Type["BaseEngineSpec"]:
+        return self.database.db_engine_spec
+
+    @property
+    def owners_data(self) -> List[Dict[str, Any]]:
+        return []
+
+    @property
+    def uid(self) -> str:
+        return f"{self.id}__{self.type}"
+
+    @property
+    def is_rls_supported(self) -> bool:
+        return False
+
+    @property
+    def cache_timeout(self) -> int:
+        return 0
+
+    @property
+    def column_names(self) -> List[Any]:
+        return [col.get("column_name") for col in self.columns]
+
+    @property
+    def offset(self) -> int:
+        return 0
+
+    @property
+    def main_dttm_col(self) -> Optional[str]:
+        for col in self.columns:
+            if col.get("is_dttm"):
+                return col.get("column_name")  # type: ignore
+        return None
+
+    @property
+    def dttm_cols(self) -> List[Any]:
+        return [col.get("column_name") for col in self.columns if col.get("is_dttm")]
+
+    @property
+    def default_endpoint(self) -> str:
+        return ""

Review Comment:
   is this a todo?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] github-actions[bot] commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1176466698

   @hughhhh Ephemeral environment creation failed. Please check the Actions logs for details.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r917034734


##########
superset-frontend/packages/superset-ui-core/src/query/types/Column.ts:
##########
@@ -38,7 +38,7 @@ export type PhysicalColumn = string;
  * Column information defined in datasource.
  */
 export interface Column {
-  id: number;
+  id?: number;

Review Comment:
   when would a query column not have an id?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
hughhhh commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r921494761


##########
superset-frontend/src/explore/components/controls/DatasourceControl/index.jsx:
##########
@@ -156,33 +198,33 @@ class DatasourceControl extends React.PureComponent {
     if (this.props.onDatasourceSave) {
       this.props.onDatasourceSave(datasource);
     }
-  }
+  };
 
-  toggleShowDatasource() {
+  toggleShowDatasource = () => {
     this.setState(({ showDatasource }) => ({
       showDatasource: !showDatasource,

Review Comment:
   the `!` is doing the toggle functionality logic wise



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
hughhhh commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r921598260


##########
superset/models/sql_lab.py:
##########
@@ -179,6 +232,53 @@ def raise_for_access(self) -> None:
 
         security_manager.raise_for_access(query=self)
 
+    @property
+    def db_engine_spec(self) -> Type["BaseEngineSpec"]:
+        return self.database.db_engine_spec
+
+    @property
+    def owners_data(self) -> List[Dict[str, Any]]:
+        return []
+
+    @property
+    def metrics(self) -> List[Any]:
+        return []
+
+    @property
+    def uid(self) -> str:

Review Comment:
   if self.id doesn't exist return None -> this will help mitigate unsaved objects 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] github-actions[bot] commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1176446174

   @hughhhh Container image not yet published for this PR. Please try again when build is complete.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r918193398


##########
superset-frontend/src/SqlLab/components/ResultSet/index.tsx:
##########
@@ -220,6 +224,15 @@ export default class ResultSet extends React.PureComponent<
       const { showSaveDatasetModal } = this.state;
       const { query } = this.props;
 
+      const dataset: ISaveableDataset = {
+        columns: query.columns as ISimpleColumn[],
+        name: query?.tab || 'Untitled',
+        dbId: 1,
+        sql: query.sql,
+        templateParams: query.templateParams,
+        schema: query.schema,

Review Comment:
   if this is a query and not a dataset, can we call it something more generic like a datasource? Dataset is a different model altogether, so it's a little confusing. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r918191448


##########
superset-frontend/packages/superset-ui-core/src/query/types/Column.ts:
##########
@@ -38,7 +38,7 @@ export type PhysicalColumn = string;
  * Column information defined in datasource.
  */
 export interface Column {
-  id: number;
+  id?: number;

Review Comment:
   got it, thanks



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r918190739


##########
superset-frontend/packages/superset-ui-core/src/query/DatasourceKey.ts:
##########
@@ -29,6 +29,7 @@ export default class DatasourceKey {
     this.id = parseInt(idStr, 10);
     this.type =
       typeStr === 'table' ? DatasourceType.Table : DatasourceType.Druid;

Review Comment:
   bump @AAfghahi or @hughhhh 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r904056881


##########
superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx:
##########
@@ -138,7 +146,7 @@ export const SaveDatasetModal: FunctionComponent<SaveDatasetModalProps> = ({
 
   const handleOverwriteDataset = async () => {
     await updateDataset(
-      query.dbId,
+      query?.dbId ?? query?.database?.id,

Review Comment:
   do we want to accept 0 as a truthy value here?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r904054574


##########
superset-frontend/packages/superset-ui-core/src/query/DatasourceKey.ts:
##########
@@ -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;

Review Comment:
   you can remove DatasourceType.Druid



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r904062320


##########
superset-frontend/src/explore/components/DatasourcePanel/index.tsx:
##########
@@ -265,8 +275,9 @@ export default function DataSourcePanel({
             ],
             keepDiacritics: true,
             baseSort: (a, b) =>
-              Number(b.item.is_certified) - Number(a.item.is_certified) ||
-              String(a.rankedValue).localeCompare(b.rankedValue),
+              Number(b?.item?.is_certified ?? 0) -

Review Comment:
   what's the scenario where a falsy value wouldn't be coerced to a 0 here? I'm thinking in the original implementation of Number(boolean or undefined) rather than Number(boolean or undefined ?? 0)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
hughhhh commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1163366541

   /testenv up


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r918193398


##########
superset-frontend/src/SqlLab/components/ResultSet/index.tsx:
##########
@@ -220,6 +224,15 @@ export default class ResultSet extends React.PureComponent<
       const { showSaveDatasetModal } = this.state;
       const { query } = this.props;
 
+      const dataset: ISaveableDataset = {
+        columns: query.columns as ISimpleColumn[],
+        name: query?.tab || 'Untitled',
+        dbId: 1,
+        sql: query.sql,
+        templateParams: query.templateParams,
+        schema: query.schema,

Review Comment:
   if this is a query and not a dataset, can we call it something more generic like a datasource? Dataset is a different model altogether, so it's a little confusing. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] AAfghahi commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
AAfghahi commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r918263361


##########
superset-frontend/packages/superset-ui-core/src/query/DatasourceKey.ts:
##########
@@ -29,6 +29,7 @@ export default class DatasourceKey {
     this.id = parseInt(idStr, 10);
     this.type =
       typeStr === 'table' ? DatasourceType.Table : DatasourceType.Druid;

Review Comment:
   Hi! Sorry, I just saw this, and yes it is still in master. We should change it here. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r918202513


##########
superset-frontend/src/explore/components/controls/DatasourceControl/index.jsx:
##########
@@ -272,35 +311,54 @@ class DatasourceControl extends React.PureComponent {
 
     const queryDatasourceMenu = (
       <Menu onClick={this.handleMenuItemClick}>
-        <Menu.Item key={QUERY_PREVIEW}>{t('Query preview')}</Menu.Item>
+        <Menu.Item key={QUERY_PREVIEW}>
+          <ModalTrigger
+            triggerNode={
+              <span data-test="view-query-menu-item">{t('Query preview')}</span>
+            }
+            modalTitle={t('Query preview')}
+            modalBody={
+              <ViewQuery
+                sql={datasource?.sql || datasource?.select_star || ''}
+              />
+            }
+            modalFooter={
+              <ViewQueryModalFooter
+                changeDatasource={this.toggleSaveDatasetModal}
+                datasource={datasource}
+              />
+            }
+            draggable={false}
+            resizable={false}
+            responsive
+          />
+        </Menu.Item>
         <Menu.Item key={VIEW_IN_SQL_LAB}>{t('View in SQL Lab')}</Menu.Item>
         <Menu.Item key={SAVE_AS_DATASET}>{t('Save as dataset')}</Menu.Item>
       </Menu>
     );
 
     const { health_check_message: healthCheckMessage } = datasource;
 
-    let extra = {};
+    let extra;
     if (datasource?.extra) {
-      try {
-        extra = JSON.parse(datasource?.extra);
-      } catch {} // eslint-disable-line no-empty
+      if (isString(datasource.extra)) {
+        try {
+          extra = JSON.parse(datasource?.extra);

Review Comment:
   don't think you need the optional chaining here b/c of the if statement above.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r904093706


##########
superset/models/sql_lab.py:
##########
@@ -179,6 +232,53 @@ def raise_for_access(self) -> None:
 
         security_manager.raise_for_access(query=self)
 
+    @property
+    def db_engine_spec(self) -> Type["BaseEngineSpec"]:
+        return self.database.db_engine_spec
+
+    @property
+    def owners_data(self) -> List[Dict[str, Any]]:
+        return []
+
+    @property
+    def metrics(self) -> List[Any]:
+        return []
+
+    @property
+    def uid(self) -> str:

Review Comment:
   I asked about the datasource uid on a different PR. I suppose if we go this route, we'll need to make sure that there aren't duplicate uuids between datasources, which could be tricky unless we use a prefix. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r904062320


##########
superset-frontend/src/explore/components/DatasourcePanel/index.tsx:
##########
@@ -265,8 +275,9 @@ export default function DataSourcePanel({
             ],
             keepDiacritics: true,
             baseSort: (a, b) =>
-              Number(b.item.is_certified) - Number(a.item.is_certified) ||
-              String(a.rankedValue).localeCompare(b.rankedValue),
+              Number(b?.item?.is_certified ?? 0) -

Review Comment:
   what's the scenario where a falsy value wouldn't be coerced to a 0 here? I'm thinking in the original implementation of Number(boolean) rather than Number(boolean ?? 0)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] codecov[bot] commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1155150405

   # [Codecov](https://codecov.io/gh/apache/superset/pull/20281?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#20281](https://codecov.io/gh/apache/superset/pull/20281?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (e076f13) into [master](https://codecov.io/gh/apache/superset/commit/c6b1523db548f9eb325439dedef6c78fa6aa9e15?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (c6b1523) will **decrease** coverage by `0.00%`.
   > The diff coverage is `85.03%`.
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #20281      +/-   ##
   ==========================================
   - Coverage   66.64%   66.63%   -0.01%     
   ==========================================
     Files        1738     1738              
     Lines       65078    65081       +3     
     Branches     6885     6890       +5     
   ==========================================
     Hits        43368    43368              
     Misses      19962    19962              
   - Partials     1748     1751       +3     
   ```
   
   | Flag | Coverage Ξ” | |
   |---|---|---|
   | javascript | `51.67% <66.66%> (-0.01%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/superset/pull/20281?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Ξ” | |
   |---|---|---|
   | [...ckages/superset-ui-core/src/query/DatasourceKey.ts](https://codecov.io/gh/apache/superset/pull/20281/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvcGFja2FnZXMvc3VwZXJzZXQtdWktY29yZS9zcmMvcXVlcnkvRGF0YXNvdXJjZUtleS50cw==) | `85.71% <0.00%> (-14.29%)` | :arrow_down: |
   | [.../explore/components/ExploreViewContainer/index.jsx](https://codecov.io/gh/apache/superset/pull/20281/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29tcG9uZW50cy9FeHBsb3JlVmlld0NvbnRhaW5lci9pbmRleC5qc3g=) | `52.84% <ΓΈ> (ΓΈ)` | |
   | [superset/views/core.py](https://codecov.io/gh/apache/superset/pull/20281/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvdmlld3MvY29yZS5weQ==) | `77.34% <71.18%> (ΓΈ)` | |
   | [superset/models/sql\_lab.py](https://codecov.io/gh/apache/superset/pull/20281/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvbW9kZWxzL3NxbF9sYWIucHk=) | `91.08% <95.00%> (ΓΈ)` | |
   | [...re/components/controls/DatasourceControl/index.jsx](https://codecov.io/gh/apache/superset/pull/20281/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29tcG9uZW50cy9jb250cm9scy9EYXRhc291cmNlQ29udHJvbC9pbmRleC5qc3g=) | `75.25% <100.00%> (+0.52%)` | :arrow_up: |
   | [superset/common/query\_context\_factory.py](https://codecov.io/gh/apache/superset/pull/20281/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvY29tbW9uL3F1ZXJ5X2NvbnRleHRfZmFjdG9yeS5weQ==) | `96.42% <100.00%> (ΓΈ)` | |
   | [superset/common/query\_context\_processor.py](https://codecov.io/gh/apache/superset/pull/20281/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvY29tbW9uL3F1ZXJ5X2NvbnRleHRfcHJvY2Vzc29yLnB5) | `90.65% <100.00%> (ΓΈ)` | |
   | [superset/models/helpers.py](https://codecov.io/gh/apache/superset/pull/20281/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvbW9kZWxzL2hlbHBlcnMucHk=) | `90.40% <100.00%> (ΓΈ)` | |
   | [superset/utils/core.py](https://codecov.io/gh/apache/superset/pull/20281/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvdXRpbHMvY29yZS5weQ==) | `90.14% <100.00%> (ΓΈ)` | |
   | ... and [7 more](https://codecov.io/gh/apache/superset/pull/20281/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/superset/pull/20281?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Ξ” = absolute <relative> (impact)`, `ΓΈ = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/superset/pull/20281?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [c6b1523...e076f13](https://codecov.io/gh/apache/superset/pull/20281?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] AAfghahi commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
AAfghahi commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r894725953


##########
superset/common/query_context_factory.py:
##########
@@ -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

Review Comment:
   Is there a benefit to importing this in the function versus globally



##########
superset/models/sql_lab.py:
##########
@@ -167,8 +170,42 @@ 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]:
+        # todo(hughhh): move this logic into a base class
+        from superset.utils.core import GenericDataType

Review Comment:
   Also why import this here?



##########
superset-frontend/src/explore/components/controls/DatasourceControl/index.jsx:
##########
@@ -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 && (

Review Comment:
   Is this supposed to be an if and then statement?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] github-actions[bot] commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1176231150

   @hughhhh Ephemeral environment spinning up at http://54.187.212.185:8080. Credentials are `admin`/`admin`. Please allow several minutes for bootstrapping and startup.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] github-actions[bot] commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1176428387

   Ephemeral environment shutdown and build artifacts deleted.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh closed pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
hughhhh closed pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ
URL: https://github.com/apache/superset/pull/20281


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] github-actions[bot] commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1176466676

   @hughhhh Container image not yet published for this PR. Please try again when build is complete.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r904089656


##########
superset-frontend/src/views/components/MenuRight.tsx:
##########
@@ -332,9 +332,9 @@ const RightMenu = ({
           title={t('Settings')}
           icon={<Icons.TriangleDown iconSize="xl" />}
         >
-          {settings.map((section, index) => [
+          {settings?.map?.((section, index) => [
             <Menu.ItemGroup key={`${section.label}`} title={section.label}>
-              {section.childs?.map(child => {
+              {section?.childs?.map?.(child => {

Review Comment:
   same question here re the extra ? after the map. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r904071735


##########
superset-frontend/src/explore/components/DatasourcePanel/index.tsx:
##########
@@ -429,24 +444,27 @@ export default function DataSourcePanel({
       columnSlice,
       inputValue,
       lists.columns.length,
-      lists.metrics.length,
+      lists?.metrics?.length,
       metricSlice,
       search,
       showAllColumns,
       showAllMetrics,
+      dataSourceIsQuery,
       shouldForceUpdate,
     ],
   );
 
   return (
     <DatasourceContainer>
-      <SaveDatasetModal
-        visible={showSaveDatasetModal}
-        onHide={() => setShowSaveDatasetModal(false)}
-        buttonTextOnSave={t('Save')}
-        buttonTextOnOverwrite={t('Overwrite')}
-        datasource={datasource}
-      />
+      {dataSourceIsQuery && (

Review Comment:
   The other reason is for long-term extendability of this feature. I'm cautious of us setting up too much logic based on the datasource type, and instead more on the functionality.. utilize duck typing when possible in other words. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r904071735


##########
superset-frontend/src/explore/components/DatasourcePanel/index.tsx:
##########
@@ -429,24 +444,27 @@ export default function DataSourcePanel({
       columnSlice,
       inputValue,
       lists.columns.length,
-      lists.metrics.length,
+      lists?.metrics?.length,
       metricSlice,
       search,
       showAllColumns,
       showAllMetrics,
+      dataSourceIsQuery,
       shouldForceUpdate,
     ],
   );
 
   return (
     <DatasourceContainer>
-      <SaveDatasetModal
-        visible={showSaveDatasetModal}
-        onHide={() => setShowSaveDatasetModal(false)}
-        buttonTextOnSave={t('Save')}
-        buttonTextOnOverwrite={t('Overwrite')}
-        datasource={datasource}
-      />
+      {dataSourceIsQuery && (

Review Comment:
   The other reason is for long-term extendability of this feature. I'm cautious of setting up too much logic based on the datasource type, and instead more on the functionality.. utilize duck typing when possible in other words. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] github-actions[bot] commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1180574015

   @jinghua-qa Ephemeral environment creation failed. Please check the Actions logs for details.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
hughhhh commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r918261812


##########
superset-frontend/packages/superset-ui-core/src/query/DatasourceKey.ts:
##########
@@ -29,6 +29,7 @@ export default class DatasourceKey {
     this.id = parseInt(idStr, 10);
     this.type =
       typeStr === 'table' ? DatasourceType.Table : DatasourceType.Druid;

Review Comment:
   yea it's still there going to remove it now



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] github-actions[bot] commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1171600104

   @AAfghahi Ephemeral environment spinning up at http://52.10.228.79:8080. Credentials are `admin`/`admin`. Please allow several minutes for bootstrapping and startup.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] Antonio-RiveroMartnez commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
Antonio-RiveroMartnez commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r925570424


##########
superset/explore/commands/get.py:
##########
@@ -152,11 +153,6 @@ def run(self) -> Optional[Dict[str, Any]]:
         except (SupersetException, SQLAlchemyError):
             dataset_data = dummy_dataset_data
 
-        if dataset:

Review Comment:
   @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 back I'd like to ask if there was any particular reason why we removed it?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] github-actions[bot] commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1176818771

   @yousoph Container image not yet published for this PR. Please try again when build is complete.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r917037544


##########
superset-frontend/src/SqlLab/components/ResultSet/index.tsx:
##########
@@ -220,6 +224,15 @@ export default class ResultSet extends React.PureComponent<
       const { showSaveDatasetModal } = this.state;
       const { query } = this.props;
 
+      const dataset: ISaveableDataset = {

Review Comment:
   @eric-briscoe what does the convention of naming with a prefix of `I` mean? interface?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] github-actions[bot] commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1176495816

   @hughhhh Container image not yet published for this PR. Please try again when build is complete.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
hughhhh commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1176495247

   /testenv up


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] github-actions[bot] commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1176818788

   @yousoph Ephemeral environment creation failed. Please check the Actions logs for details.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] github-actions[bot] commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1158209549

   @eschutho Ephemeral environment spinning up at http://35.155.199.221:8080. Credentials are `admin`/`admin`. Please allow several minutes for bootstrapping and startup.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] github-actions[bot] commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1165563820

   @hughhhh Ephemeral environment spinning up at http://35.163.70.20:8080. Credentials are `admin`/`admin`. Please allow several minutes for bootstrapping and startup.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] zhaoyongjie commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
zhaoyongjie commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1186075099

   @hughhhh @hughhhh have we really done testing? The explore page of master branch seems doesn't work at all.
   
   https://user-images.githubusercontent.com/2016594/179336747-ce3fa9e7-6e43-489c-a74d-0d1868ce228c.mov
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
hughhhh commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1187789343

   @zhaoyongjie I have fixes out for these 2 bugs
   https://github.com/apache/superset/pull/20747
   https://github.com/apache/superset/pull/20751


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r904065562


##########
superset-frontend/src/explore/components/DatasourcePanel/index.tsx:
##########
@@ -282,22 +293,22 @@ export default function DataSourcePanel({
   }, [columns, datasource, metrics]);
 
   const sortCertifiedFirst = (slice: ColumnMeta[]) =>
-    slice.sort((a, b) => b.is_certified - a.is_certified);
+    slice.sort((a, b) => b?.is_certified - a?.is_certified);
 
   const metricSlice = useMemo(
     () =>
       showAllMetrics
-        ? lists.metrics
-        : lists.metrics.slice(0, DEFAULT_MAX_METRICS_LENGTH),
-    [lists.metrics, showAllMetrics],
+        ? lists?.metrics
+        : lists?.metrics?.slice?.(0, DEFAULT_MAX_METRICS_LENGTH),
+    [lists?.metrics, showAllMetrics],
   );
 
   const columnSlice = useMemo(
     () =>
       showAllColumns
-        ? sortCertifiedFirst(lists.columns)
+        ? sortCertifiedFirst(lists?.columns)
         : sortCertifiedFirst(
-            lists.columns.slice(0, DEFAULT_MAX_COLUMNS_LENGTH),
+            lists?.columns?.slice?.(0, DEFAULT_MAX_COLUMNS_LENGTH),

Review Comment:
   same q here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
hughhhh commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r917795493


##########
superset-frontend/packages/superset-ui-core/src/query/types/Column.ts:
##########
@@ -38,7 +38,7 @@ export type PhysicalColumn = string;
  * Column information defined in datasource.
  */
 export interface Column {
-  id: number;
+  id?: number;

Review Comment:
   When it's of type datasource is `Query` we don't have an id for this object, since we are just saving it has a JSON blob inside `extra_json`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] Antonio-RiveroMartnez commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
Antonio-RiveroMartnez commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r925570424


##########
superset/explore/commands/get.py:
##########
@@ -152,11 +153,6 @@ def run(self) -> Optional[Dict[str, Any]]:
         except (SupersetException, SQLAlchemyError):
             dataset_data = dummy_dataset_data
 
-        if dataset:

Review Comment:
   @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?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r929307687


##########
superset/utils/core.py:
##########
@@ -1717,11 +1727,20 @@ def is_test() -> bool:
     return strtobool(os.environ.get("SUPERSET_TESTENV", "false"))
 
 
-def get_time_filter_status(
+def get_time_filter_status(  # pylint: disable=too-many-branches
     datasource: "BaseDatasource",
     applied_time_extras: Dict[str, str],
 ) -> Tuple[List[Dict[str, str]], List[Dict[str, str]]]:
-    temporal_columns = {col.column_name for col in datasource.columns if col.is_dttm}
+
+    temporal_columns: Set[Any]
+    if datasource.type == "query":

Review Comment:
   TODO: @hughhhh 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
hughhhh commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r921592355


##########
superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx:
##########
@@ -148,10 +172,10 @@ export const SaveDatasetModal: FunctionComponent<SaveDatasetModalProps> = ({
   const handleOverwriteDataset = async () => {
     const [, key] = await Promise.all([
       updateDataset(
-        query.dbId,
+        datasource.dbId,
         datasetToOverwrite.datasetid,
-        query.sql,
-        query.results.selected_columns.map(
+        datasource.sql,

Review Comment:
   add this back from @lyndsiWilliams PR:
   ```
   if (!shouldOverwriteDataset) {
         setShouldOverwriteDataset(true);
         return;
   }
   ``



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r917042860


##########
superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx:
##########
@@ -148,10 +172,10 @@ export const SaveDatasetModal: FunctionComponent<SaveDatasetModalProps> = ({
   const handleOverwriteDataset = async () => {
     const [, key] = await Promise.all([
       updateDataset(
-        query.dbId,
+        datasource.dbId,
         datasetToOverwrite.datasetid,
-        query.sql,
-        query.results.selected_columns.map(
+        datasource.sql,
+        datasource?.columns?.map(

Review Comment:
   we have some datasources that seem optional here (via the optional chaining) and some that aren't. Is that intentional?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] hughhhh commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
hughhhh commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1176445510

   /testenv up


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] github-actions[bot] commented on pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #20281:
URL: https://github.com/apache/superset/pull/20281#issuecomment-1176495823

   @hughhhh Ephemeral environment creation failed. Please check the Actions logs for details.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eric-briscoe commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
eric-briscoe commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r909078344


##########
superset-frontend/src/explore/components/DatasourcePanel/index.tsx:
##########
@@ -282,22 +293,22 @@ export default function DataSourcePanel({
   }, [columns, datasource, metrics]);
 
   const sortCertifiedFirst = (slice: ColumnMeta[]) =>
-    slice.sort((a, b) => b.is_certified - a.is_certified);
+    slice.sort((a, b) => b?.is_certified - a?.is_certified);
 
   const metricSlice = useMemo(
     () =>
       showAllMetrics
-        ? lists.metrics
-        : lists.metrics.slice(0, DEFAULT_MAX_METRICS_LENGTH),
-    [lists.metrics, showAllMetrics],
+        ? lists?.metrics
+        : lists?.metrics?.slice?.(0, DEFAULT_MAX_METRICS_LENGTH),

Review Comment:
   @eschutho I always try to write code that assumes every prop passed to a component will be the wrong data type, null, undefined so that it is impossible for the component to throw a runtime error.  
   
   TypeScript will only help us when we don't pass around object refs (without explicit new object mapping each value to attribute on new object) component to component which essentially makes us think we are doing type checking, but in reality the object can be mutated at any point along the chain of props between components drilling, or redux and end up in a bad state.  We also have cases where components that are not TypeScript migrated yet are in the mix.  
   
   While it is unlikely metrics would get set to something other than undefined, null, or array, if it does get an incorrect value assigned this would error out.  Whenever there is not a performance concern - something called repeatedly in loops, I prefer to make the code runtime bomb proof.  
   
   I am completely flexible on this approach and can dial back the `?.(` pre function invocation checks if that is a preferred approach.  Probably worth deciding and discussing with team either way to be consistent :)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] AAfghahi commented on a diff in pull request #20281: feat: Visualize SqlLab.Query model data in Explore πŸ“ˆ

Posted by GitBox <gi...@apache.org>.
AAfghahi commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r918256943


##########
superset-frontend/src/components/Chart/Chart.jsx:
##########
@@ -193,6 +202,17 @@ class Chart extends React.PureComponent {
     });
   }
 
+  getDatasourceAsSaveableDataset = source => {

Review Comment:
   we repeat this pattern a couple of times, should we put it into utils?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org