You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by hu...@apache.org on 2023/04/18 19:17:29 UTC

[superset] branch hxgh-apiv1-sqllab-viz created (now b6e7d39165)

This is an automated email from the ASF dual-hosted git repository.

hugh pushed a change to branch hxgh-apiv1-sqllab-viz
in repository https://gitbox.apache.org/repos/asf/superset.git


      at b6e7d39165 Merge branch 'master' of https://github.com/apache/superset into hxgh-apiv1-sqllab-viz

This branch includes the following new commits:

     new 718db127d8 save
     new b6e7d39165 Merge branch 'master' of https://github.com/apache/superset into hxgh-apiv1-sqllab-viz

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[superset] 02/02: Merge branch 'master' of https://github.com/apache/superset into hxgh-apiv1-sqllab-viz

Posted by hu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hugh pushed a commit to branch hxgh-apiv1-sqllab-viz
in repository https://gitbox.apache.org/repos/asf/superset.git

commit b6e7d39165c68869b3250e80340219ab19620d29
Merge: 718db127d8 8bd432274a
Author: hughhhh <hu...@gmail.com>
AuthorDate: Tue Apr 18 12:16:51 2023 -0700

    Merge branch 'master' of https://github.com/apache/superset into hxgh-apiv1-sqllab-viz

 .github/workflows/cancel_duplicates.yml            |     9 +-
 .github/workflows/check_db_migration_confict.yml   |     7 +-
 .github/workflows/chromatic-master.yml             |    17 +-
 .github/workflows/docker-ephemeral-env.yml         |    22 +-
 .github/workflows/docker-release.yml               |    18 +-
 .github/workflows/docker.yml                       |    19 +-
 .github/workflows/embedded-sdk-release.yml         |    17 +-
 .github/workflows/embedded-sdk-test.yml            |     2 +-
 .github/workflows/ephemeral-env-pr-close.yml       |    19 +-
 .github/workflows/ephemeral-env.yml                |    32 +-
 .github/workflows/latest-release-tag.yml           |     6 +-
 .github/workflows/license-check.yml                |    17 +-
 .github/workflows/pr-lint.yml                      |     7 +-
 .github/workflows/prefer-typescript.yml            |     9 +-
 .github/workflows/release.yml                      |    37 +-
 .github/workflows/superset-applitool-cypress.yml   |    17 +-
 .../workflows/superset-applitools-storybook.yml    |    15 +
 .github/workflows/superset-cli.yml                 |     2 +-
 .github/workflows/superset-docs.yml                |    17 +-
 .github/workflows/superset-e2e.yml                 |     9 +-
 .github/workflows/superset-frontend.yml            |     2 +-
 .github/workflows/superset-helm-lint.yml           |     2 +-
 .github/workflows/superset-helm-release.yml        |     7 +-
 .../workflows/superset-python-integrationtest.yml  |     6 +-
 .github/workflows/superset-python-misc.yml         |     6 +-
 .github/workflows/superset-python-presto-hive.yml  |     4 +-
 .github/workflows/superset-python-unittest.yml     |     2 +-
 .github/workflows/superset-translations.yml        |     4 +-
 .github/workflows/superset-websocket.yml           |     2 +-
 .github/workflows/welcome-new-users.yml            |     2 +-
 CHANGELOG.md                                       |  1177 +
 CONTRIBUTING.md                                    |    40 +-
 Dockerfile                                         |    68 +-
 RESOURCES/FEATURE_FLAGS.md                         |     7 +-
 UPDATING.md                                        |     3 +
 docs/docs/contributing/translations.mdx            |     2 +-
 .../creating-your-first-dashboard.mdx              |     5 +-
 helm/superset/Chart.lock                           |     6 +-
 helm/superset/Chart.yaml                           |     4 +-
 helm/superset/README.md                            |     4 +-
 helm/superset/templates/NOTES.txt                  |     4 +-
 helm/superset/templates/_helpers.tpl               |    45 +-
 helm/superset/templates/configmap-superset.yaml    |     8 +-
 helm/superset/templates/deployment-beat.yaml       |    75 +-
 helm/superset/templates/deployment-flower.yaml     |    76 +-
 helm/superset/templates/deployment-worker.yaml     |    95 +-
 helm/superset/templates/deployment-ws.yaml         |    68 +-
 helm/superset/templates/deployment.yaml            |    96 +-
 helm/superset/templates/ingress.yaml               |    21 +-
 helm/superset/templates/init-job.yaml              |    48 +-
 helm/superset/templates/secret-env.yaml            |     2 +-
 .../superset/templates/secret-superset-config.yaml |    18 +-
 helm/superset/templates/secret-ws.yaml             |     6 +-
 helm/superset/templates/service-account.yaml       |     2 +-
 helm/superset/templates/service.yaml               |    19 +-
 helm/superset/values.yaml                          |    51 +-
 scripts/babel_update.sh                            |    13 +
 .../explore/visualizations/table.test.ts           |     4 +-
 superset-frontend/cypress-base/package-lock.json   |    12 +-
 superset-frontend/package-lock.json                |   107 +-
 superset-frontend/package.json                     |     3 +-
 .../superset-ui-chart-controls/src/constants.ts    |    20 +-
 .../src/sections/echartsTimeSeriesQuery.tsx        |     6 +-
 .../src/shared-controls/customControls.tsx         |    65 +-
 .../superset-ui-chart-controls/src/types.ts        |    13 +
 .../src/chart/components/SuperChart.tsx            |    10 +-
 .../src/chart/components/SuperChartCore.tsx        |    28 +-
 .../src/color/CategoricalColorScale.ts             |    20 +-
 .../packages/superset-ui-core/src/color/types.ts   |     4 +
 .../src/components/SafeMarkdown.tsx                |     7 +-
 .../superset-ui-core/src/utils/featureFlags.ts     |     4 -
 .../test/color/CategoricalColorScale.test.ts       |    15 +
 .../test/utils/featureFlag.test.ts                 |    10 +-
 .../legacy-preset-chart-nvd3/src/NVD3Vis.js        |     8 +-
 .../src/Gauge/transformProps.ts                    |     5 +-
 .../src/MixedTimeseries/transformProps.ts          |     4 +-
 .../src/Timeseries/constants.ts                    |     6 +-
 .../src/Timeseries/transformProps.ts               |    13 +-
 .../plugin-chart-echarts/src/Timeseries/types.ts   |     2 +
 .../plugins/plugin-chart-echarts/src/constants.ts  |     7 -
 .../plugins/plugin-chart-echarts/src/controls.tsx  |    17 +-
 .../plugins/plugin-chart-echarts/src/types.ts      |    13 -
 .../plugin-chart-echarts/src/utils/series.ts       |   131 +-
 .../plugin-chart-echarts/test/utils/series.test.ts |   345 +-
 .../src/PivotTableChart.tsx                        |    19 +-
 .../src/react-pivottable/TableRenderers.jsx        |    18 +-
 .../preset-chart-xy/src/components/Line/Line.tsx   |    10 +-
 .../src/utils/createMarginSelector.tsx             |    10 +-
 superset-frontend/spec/fixtures/mockStore.js       |    47 +-
 superset-frontend/spec/helpers/testing-library.tsx |    19 +-
 superset-frontend/src/SqlLab/App.jsx               |    29 +-
 .../SqlLab/components/SaveDatasetModal/index.tsx   |    14 +-
 .../SqlLab/components/SqlEditor/SqlEditor.test.jsx |    49 +-
 .../src/SqlLab/components/SqlEditor/index.jsx      |     3 +-
 superset-frontend/src/SqlLab/fixtures.ts           |     6 +-
 superset-frontend/src/SqlLab/reducers/index.js     |     6 +-
 .../{ => ChartContextMenu}/ChartContextMenu.tsx    |    66 +-
 .../Chart/ChartContextMenu/useContextMenu.test.tsx |    86 +
 .../Chart/ChartContextMenu/useContextMenu.tsx      |    82 +
 .../src/components/Chart/ChartRenderer.jsx         |    17 +-
 .../components/Chart/DrillBy/DrillByChart.test.tsx |    47 +-
 .../src/components/Chart/DrillBy/DrillByChart.tsx  |    61 +-
 .../Chart/DrillBy/DrillByMenuItems.test.tsx        |    70 +-
 .../components/Chart/DrillBy/DrillByMenuItems.tsx  |    53 +-
 .../components/Chart/DrillBy/DrillByModal.test.tsx |    96 +-
 .../src/components/Chart/DrillBy/DrillByModal.tsx  |   249 +-
 .../Chart/DrillBy/useDisplayModeToggle.tsx         |    64 +
 .../Chart/DrillBy/useDrillByBreadcrumbs.test.ts    |    72 +
 .../Chart/DrillBy/useDrillByBreadcrumbs.tsx        |    93 +
 superset-frontend/src/components/Chart/types.ts    |     7 +
 superset-frontend/src/components/index.ts          |     1 +
 .../dashboard/components/PropertiesModal/index.tsx |     2 +-
 .../src/dashboard/components/SliceHeader/index.tsx |     2 +-
 .../FiltersConfigForm/FiltersConfigForm.tsx        |     2 +-
 superset-frontend/src/dashboard/styles.ts          |     3 +
 .../src/explore/actions/saveModalActions.js        |    40 +-
 .../src/explore/actions/saveModalActions.test.js   |   122 +
 .../DataTablesPane/test/DataTablesPane.test.tsx    |     2 +-
 .../DndColumnSelectControl/DndFilterSelect.tsx     |     2 +-
 .../DndColumnSelectControl/DndMetricSelect.tsx     |    18 +-
 .../controls/MetricControl/AdhocMetricOption.jsx   |     2 +-
 .../databases/DatabaseModal/ExtraOptions.tsx       |     4 +-
 .../src/features/databases/DatabaseModal/index.tsx |     5 +-
 superset-frontend/src/utils/common.js              |    10 +-
 superset-frontend/src/utils/common.test.jsx        |    24 +-
 superset-frontend/src/utils/hostNamesConfig.js     |     4 +-
 superset-frontend/src/views/menu.tsx               |     2 +-
 superset-frontend/src/views/store.ts               |    62 +-
 superset-websocket/package-lock.json               |   535 +-
 superset-websocket/package.json                    |     6 +-
 superset/charts/data/api.py                        |     5 +-
 superset/config.py                                 |    14 +-
 superset/connectors/base/models.py                 |     4 +-
 superset/connectors/sqla/models.py                 |   769 +-
 superset/db_engine_specs/base.py                   |    33 +-
 superset/db_engine_specs/bigquery.py               |    22 +
 superset/db_engine_specs/hive.py                   |     2 +
 superset/db_engine_specs/mysql.py                  |     6 +-
 superset/db_engine_specs/presto.py                 |    44 +-
 superset/db_engine_specs/trino.py                  |     2 +
 superset/migrations/env.py                         |     4 +-
 ...2af1b_drop_postgres_enum_constrains_for_tags.py |     4 +-
 superset/models/core.py                            |     3 +-
 superset/models/helpers.py                         |   488 +-
 superset/models/sql_lab.py                         |    67 +-
 superset/reports/commands/execute.py               |     4 +-
 superset/security/manager.py                       |    19 +-
 superset/sql_parse.py                              |     4 +-
 superset/translations/de/LC_MESSAGES/messages.json |  2434 +-
 superset/translations/de/LC_MESSAGES/messages.po   | 15813 ++++++----
 superset/translations/en/LC_MESSAGES/messages.json |  5935 +++-
 superset/translations/en/LC_MESSAGES/messages.po   | 13850 ++++++---
 superset/translations/es/LC_MESSAGES/messages.json |  5446 ++--
 superset/translations/es/LC_MESSAGES/messages.po   | 14829 ++++++---
 superset/translations/fr/LC_MESSAGES/messages.json |  6759 +++--
 superset/translations/fr/LC_MESSAGES/messages.po   | 15237 ++++++----
 superset/translations/it/LC_MESSAGES/messages.json |  5326 ++--
 superset/translations/it/LC_MESSAGES/messages.po   | 14426 ++++++---
 superset/translations/ja/LC_MESSAGES/messages.json |  5513 ++--
 superset/translations/ja/LC_MESSAGES/messages.po   | 14541 ++++++---
 superset/translations/ko/LC_MESSAGES/messages.json |  5409 ++--
 superset/translations/ko/LC_MESSAGES/messages.po   | 14383 ++++++---
 superset/translations/messages.pot                 | 13851 ++++++---
 superset/translations/nl/LC_MESSAGES/messages.json |  7787 ++---
 superset/translations/nl/LC_MESSAGES/messages.po   | 26763 +++++++++-------
 superset/translations/pt/LC_MESSAGES/message.po    |  7766 -----
 superset/translations/pt/LC_MESSAGES/messages.json |  4840 ++-
 .../{ru => pt}/LC_MESSAGES/messages.po             | 14358 ++++-----
 .../translations/pt_BR/LC_MESSAGES/messages.json   |  5607 ++--
 .../translations/pt_BR/LC_MESSAGES/messages.po     | 14841 +++++----
 superset/translations/ru/LC_MESSAGES/messages.json |   127 +-
 superset/translations/ru/LC_MESSAGES/messages.po   |  6045 ++--
 superset/translations/sk/LC_MESSAGES/messages.json |  6055 ++--
 superset/translations/sk/LC_MESSAGES/messages.po   | 13899 ++++++---
 superset/translations/sl/LC_MESSAGES/messages.json |  8824 +++---
 superset/translations/sl/LC_MESSAGES/messages.po   | 30317 +++++++++++--------
 superset/translations/zh/LC_MESSAGES/messages.json |  1105 +-
 superset/translations/zh/LC_MESSAGES/messages.po   | 14939 +++++----
 superset/utils/core.py                             |    16 +-
 superset/utils/decorators.py                       |     6 +-
 superset/views/core.py                             |    58 +-
 superset/views/dashboard/mixin.py                  |     2 +-
 superset/views/utils.py                            |     8 +-
 superset/viz.py                                    |     3 +-
 tests/integration_tests/charts/data/api_tests.py   |     4 +-
 .../dashboards/security/security_rbac_tests.py     |    59 +-
 tests/integration_tests/datasets/api_tests.py      |     2 +-
 tests/integration_tests/datasets/commands_tests.py |     2 +-
 .../db_engine_specs/base_engine_spec_tests.py      |    23 +
 .../db_engine_specs/bigquery_tests.py              |    83 +-
 tests/integration_tests/model_tests.py             |    15 +
 tests/integration_tests/sqllab_tests.py            |    24 +-
 tests/unit_tests/db_engine_specs/test_mysql.py     |    34 +-
 tests/unit_tests/sql_parse_tests.py                |    22 +
 194 files changed, 197572 insertions(+), 126626 deletions(-)



[superset] 01/02: save

Posted by hu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hugh pushed a commit to branch hxgh-apiv1-sqllab-viz
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 718db127d8a1046a4bc73b18d3feb3b49ee2368d
Author: hughhhh <hu...@gmail.com>
AuthorDate: Fri Apr 7 11:07:07 2023 -0400

    save
---
 superset/datasets/api.py | 111 +++++++++++++++++++++++++++++++++++++++++++++++
 superset/views/core.py   |   1 +
 2 files changed, 112 insertions(+)

diff --git a/superset/datasets/api.py b/superset/datasets/api.py
index 48c429d32d..f505b2288c 100644
--- a/superset/datasets/api.py
+++ b/superset/datasets/api.py
@@ -989,3 +989,114 @@ class DatasetRestApi(BaseSupersetModelRestApi):
                 exc_info=True,
             )
             return self.response_422(message=ex.message)
+
+    @expose("/sqllab_viz/", methods=["POST"])
+    @protect()
+    @safe
+    @statsd_metrics
+    @event_logger.log_this_with_context(
+        action=lambda self, *args, **kwargs: f"{self.__class__.__name__}"
+        f".sqllab_viz",
+        log_to_statsd=False,
+    )
+    def sqllab_viz(self) -> Response:
+        """ endpoint that builds a dataset from sqllab
+        ---
+        post:
+          summary: {fill this in}
+          requestBody:
+            required: true
+            content:
+              application/json:
+                schema:
+                  $ref: {fill this in} '#/components/schemas/GetOrCreateDatasetSchema'
+          responses:
+            200:
+              description: The ID of the dataset
+              content:
+                application/json:
+                  schema:
+                    type: object
+                    properties:
+                      result:
+                        type: object
+                        properties:
+                          table_id:
+                            type: integer
+            400:
+              $ref: '#/components/responses/400'
+            401:
+              $ref: '#/components/responses/401'
+            422:
+              $ref: '#/components/responses/422'
+            500:
+              $ref: '#/components/responses/500'
+        """
+        try:
+            data = json.loads(request.form["data"])
+            table_name = data["datasourceName"]
+            database_id = data["dbId"]
+        except KeyError as ex:
+            raise SupersetGenericErrorException(
+                __(
+                    "One or more required fields are missing in the request. Please try "
+                    "again, and if the problem persists contact your administrator."
+                ),
+                status=400,
+            ) from ex
+        database = db.session.query(Database).get(database_id)
+        if not database:
+            raise SupersetErrorException(
+                SupersetError(
+                    message=__("The database was not found."),
+                    error_type=SupersetErrorType.DATABASE_NOT_FOUND_ERROR,
+                    level=ErrorLevel.ERROR,
+                ),
+                status=404,
+            )
+        table = (
+            db.session.query(SqlaTable)
+            .filter_by(database_id=database_id, table_name=table_name)
+            .one_or_none()
+        )
+
+        if table:
+            return json_errors_response(
+                [
+                    SupersetError(
+                        message=f"Dataset [{table_name}] already exists",
+                        error_type=SupersetErrorType.GENERIC_BACKEND_ERROR,
+                        level=ErrorLevel.WARNING,
+                    )
+                ],
+                status=422,
+            )
+
+        table = SqlaTable(table_name=table_name, owners=[g.user])
+        table.database = database
+        table.schema = data.get("schema")
+        table.template_params = data.get("templateParams")
+        table.is_sqllab_view = True
+        table.sql = ParsedQuery(data.get("sql")).stripped()
+        db.session.add(table)
+        cols = []
+        for config_ in data.get("columns"):
+            column_name = config_.get("name")
+            col = TableColumn(
+                column_name=column_name,
+                filterable=True,
+                groupby=True,
+                is_dttm=config_.get("is_dttm", False),
+                type=config_.get("type", False),
+            )
+            cols.append(col)
+
+        table.columns = cols
+        table.metrics = [SqlMetric(metric_name="count", expression="count(*)")]
+        db.session.commit()
+
+        return json_success(
+            json.dumps(
+                {"table_id": table.id, "data": sanitize_datasource_data(table.data)}
+            )
+        )
\ No newline at end of file
diff --git a/superset/views/core.py b/superset/views/core.py
index 6559db1254..7dff351adf 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -1973,6 +1973,7 @@ class Superset(BaseSupersetView):  # pylint: disable=too-many-public-methods
     @has_access
     @expose("/sqllab_viz/", methods=["POST"])
     @event_logger.log_this
+    @deprecated
     def sqllab_viz(self) -> FlaskResponse:  # pylint: disable=no-self-use
         data = json.loads(request.form["data"])
         try: