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 2021/09/27 15:52:26 UTC
[superset] branch pexdax/snowflake updated (0d064f4 -> 3228ed9)
This is an automated email from the ASF dual-hosted git repository.
hugh pushed a change to branch pexdax/snowflake
in repository https://gitbox.apache.org/repos/asf/superset.git.
from 0d064f4 Be able to lookup driver by engine alias (#16800)
add 1ff682f fix: Updates the selected values when changing the native filter type, column or default value (#16833)
add 55e2872 Fix 500 tab title (#16836)
add 04f7eca display tooltip when disabled (#16837)
add a341319 chore: upgrade to Node 16 (#16809)
add c520eb7 refactor: sqllab: move sqllab ralated enumns and utils to more logical place (#16843)
add ef95458 Exit init script immediately on error (#16758)
add 42fa548 fix(native-filters): filter indicator stale state (#16831)
add 0a8d0c6 fix(native-filters): emitted filter label format (#16828)
add 100760c fix(gallery): Hide the bottom info section when no chart is being selected (#16840)
add bbe7aa3 chore: db migrate timeseries_limit_metric to legacy_order_by in pivottable2 (#16849)
add f703c12 chore: bump superset-ui to 0.18.8 (#16850)
add 0f16177 fix(native-filters): ignore unset filter box time range (#16854)
add 8ad03c4 chore: Select component refactoring - FilterControl - Iteration 5 (#15777)
add 913df18 chore: Select component refactoring - MetricControl - Iteration 5 (#16423)
add e40ff3a chore: Select component refactoring - DndColumnSelectControl - Iteration 5 (#16440)
add ab9f8cb chore: Select component refactoring - PropertiesModal - Iteration 5 (#16445)
add 271ec6e chore: Select component refactoring - SaveModal - Iteration 5 (#16446)
add 667b88c chore: Select component refactoring - TimeSeriesColumnControl - Iteration 5 (#16442)
new 3228ed9 update snowflake spec for dyanmic form
The 1 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.
Summary of changes:
.github/workflows/bashlib.sh | 2 -
.github/workflows/superset-e2e.yml | 22 +-
.github/workflows/superset-frontend.yml | 4 +
.github/workflows/superset-translations.yml | 4 +
CONTRIBUTING.md | 14 +-
Dockerfile | 2 +-
UPDATING.md | 2 +
docker-compose.yml | 2 +-
helm/superset/Chart.yaml | 2 +-
helm/superset/values.yaml | 1 +
setup.cfg | 2 +-
.../integration/dashboard/nativeFilters.test.ts | 4 +-
.../integration/explore/AdhocFilters.test.ts | 2 +-
.../integration/explore/AdhocMetrics.test.ts | 8 +-
.../cypress/integration/explore/link.test.ts | 16 +-
.../explore/visualizations/line.test.ts | 6 +-
superset-frontend/package-lock.json | 606 ++++++++++-----------
superset-frontend/package.json | 58 +-
.../dashboard/components/PropertiesModal_spec.jsx | 5 +-
.../components/AdhocMetricEditPopover_spec.jsx | 6 +-
.../explore/components/SaveModal_spec.jsx | 5 +-
.../spec/javascripts/sqllab/ResultSet_spec.jsx | 2 +
.../javascripts/sqllab/SqlEditorLeftBar_spec.jsx | 3 +-
superset-frontend/src/assets/staticPages/500.html | 2 +-
.../AlteredSliceTag/AlteredSliceTag.test.jsx | 2 +-
superset-frontend/src/components/Button/index.tsx | 4 +-
.../dashboard/components/FiltersBadge/selectors.ts | 15 +-
.../dashboard/components/Header/Header.test.tsx | 36 +-
.../components/nativeFilters/FilterBar/index.tsx | 54 +-
superset-frontend/src/dataMask/actions.ts | 9 +-
superset-frontend/src/dataMask/reducer.ts | 4 +-
.../PropertiesModal/PropertiesModal.test.tsx | 4 +-
.../explore/components/PropertiesModal/index.tsx | 102 ++--
.../src/explore/components/SaveModal.tsx | 25 +-
.../DndColumnSelectControl/ColumnSelectPopover.tsx | 69 +--
.../DndFilterSelect.test.tsx | 17 +-
.../FilterControl/AdhocFilterEditPopover/index.jsx | 5 -
.../index.tsx | 165 ++----
.../AdhocFilterEditPopoverSqlTabContent/index.jsx | 30 +-
.../MetricControl/AdhocMetricEditPopover/index.jsx | 90 ++-
.../TimeSeriesColumnControl.test.tsx | 10 +-
.../controls/TimeSeriesColumnControl/index.jsx | 28 +-
.../controls/VizTypeControl/VizTypeGallery.tsx | 53 +-
.../components/Select/SelectFilterPlugin.tsx | 31 +-
superset-frontend/src/filters/utils.ts | 15 -
.../data/database/DatabaseModal/index.test.jsx | 5 +
superset-websocket/Dockerfile | 2 +-
.../db_query_status.py} | 16 +-
superset/common/query_actions.py | 2 +-
superset/common/query_context.py | 2 +-
superset/common/utils.py | 3 +-
superset/connectors/sqla/models.py | 9 +-
superset/db_engine_specs/base.py | 2 -
superset/db_engine_specs/druid.py | 2 +-
superset/db_engine_specs/hive.py | 2 +-
superset/db_engine_specs/presto.py | 2 +-
superset/db_engine_specs/snowflake.py | 76 ++-
...53f4e2e_migrate_timeseries_limit_metric_to_.py} | 47 +-
superset/models/helpers.py | 2 +-
superset/models/sql_lab.py | 10 +-
superset/sql_lab.py | 11 +-
superset/sqllab/command.py | 11 +-
.../sqllab/limiting_factor.py | 11 +-
superset/sqllab/utils.py | 47 ++
superset/utils/core.py | 4 +-
superset/utils/sqllab_execution_context.py | 1 -
superset/views/core.py | 9 +-
superset/views/utils.py | 3 +-
superset/viz.py | 17 +-
tests/integration_tests/cache_tests.py | 2 +-
tests/integration_tests/celery_tests.py | 2 +-
tests/integration_tests/core_tests.py | 17 +-
tests/integration_tests/model_tests.py | 3 +-
tests/integration_tests/queries/api_tests.py | 3 +-
tests/integration_tests/sqllab_tests.py | 3 +-
tests/integration_tests/utils_tests.py | 44 +-
tests/unit_tests/core_tests.py | 4 -
77 files changed, 1011 insertions(+), 911 deletions(-)
copy superset/{sqllab/command_status.py => common/db_query_status.py} (71%)
copy superset/migrations/versions/{67a6ac9b727b_update_spatial_params.py => 60dc453f4e2e_migrate_timeseries_limit_metric_to_.py} (60%)
copy docs/.asf.yaml => superset/sqllab/limiting_factor.py (79%)
create mode 100644 superset/sqllab/utils.py
[superset] 01/01: update snowflake spec for dyanmic form
Posted by hu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
hugh pushed a commit to branch pexdax/snowflake
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 3228ed955ae6bbe2a3e5498c979e67564209565f
Author: hughhhh <hu...@gmail.com>
AuthorDate: Mon Sep 27 11:50:57 2021 -0400
update snowflake spec for dyanmic form
---
setup.cfg | 2 +-
superset/db_engine_specs/snowflake.py | 76 ++++++++++++++++++++++++++++++++++-
2 files changed, 75 insertions(+), 3 deletions(-)
diff --git a/setup.cfg b/setup.cfg
index 9a108f7..20bf908 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -30,7 +30,7 @@ combine_as_imports = true
include_trailing_comma = true
line_length = 88
known_first_party = superset
-known_third_party =alembic,apispec,backoff,bleach,cachelib,celery,click,colorama,cron_descriptor,croniter,cryptography,dateutil,deprecation,flask,flask_appbuilder,flask_babel,flask_caching,flask_compress,flask_jwt_extended,flask_login,flask_migrate,flask_sqlalchemy,flask_talisman,flask_testing,flask_wtf,freezegun,geohash,geopy,graphlib,holidays,humanize,isodate,jinja2,jwt,markdown,markupsafe,marshmallow,marshmallow_enum,msgpack,numpy,pandas,parameterized,parsedatetime,pgsanity,pkg_resour [...]
+known_third_party =alembic,apispec,babel,backoff,bleach,cachelib,celery,click,colorama,cron_descriptor,croniter,cryptography,dateutil,deprecation,flask,flask_appbuilder,flask_babel,flask_caching,flask_compress,flask_jwt_extended,flask_login,flask_migrate,flask_sqlalchemy,flask_talisman,flask_testing,flask_wtf,freezegun,geohash,geopy,graphlib,holidays,humanize,isodate,jinja2,jwt,markdown,markupsafe,marshmallow,marshmallow_enum,msgpack,numpy,pandas,parameterized,parsedatetime,pgsanity,pkg_ [...]
multi_line_output = 3
order_by_type = false
diff --git a/superset/db_engine_specs/snowflake.py b/superset/db_engine_specs/snowflake.py
index 6dd8570..b5132d3 100644
--- a/superset/db_engine_specs/snowflake.py
+++ b/superset/db_engine_specs/snowflake.py
@@ -17,14 +17,18 @@
import json
import re
from datetime import datetime
-from typing import Any, Dict, Optional, Pattern, Tuple, TYPE_CHECKING
+from typing import Any, Dict, List, Optional, Pattern, Tuple, TYPE_CHECKING, TypedDict
from urllib import parse
+from apispec import APISpec
+from apispec.ext.marshmallow import MarshmallowPlugin
+from babel.core import default_locale
from flask_babel import gettext as __
+from marshmallow import fields, Schema
from sqlalchemy.engine.url import URL
from superset.db_engine_specs.postgres import PostgresBaseEngineSpec
-from superset.errors import SupersetErrorType
+from superset.errors import SupersetError, SupersetErrorType
from superset.models.sql_lab import Query
from superset.utils import core as utils
@@ -42,12 +46,24 @@ SYNTAX_ERROR_REGEX = re.compile(
)
+class SnowflakeParametersSchema(Schema):
+ username = fields.Str(required=True)
+
+
+class SnowflakeParametersType(TypedDict):
+ username: str
+
+
class SnowflakeEngineSpec(PostgresBaseEngineSpec):
engine = "snowflake"
engine_name = "Snowflake"
force_column_alias_quotes = True
max_column_name_length = 256
+ parameters_schema = SnowflakeParametersSchema()
+ default_driver = "snowflake"
+ sqlalchemy_uri_placeholder = "snowflake://"
+
_time_grain_expressions = {
None: "{col}",
"PT1S": "DATE_TRUNC('SECOND', {col})",
@@ -160,3 +176,59 @@ class SnowflakeEngineSpec(PostgresBaseEngineSpec):
return False
return True
+
+ @classmethod
+ def build_sqlalchemy_uri(
+ cls,
+ parameters: SnowflakeParametersType,
+ encrypted_extra: Optional[Dict[str, Any]] = None,
+ ) -> str:
+ query = parameters.get("query", {})
+ query_params = urllib.parse.urlencode(query)
+
+ if not encrypted_extra:
+ raise ValidationError("Missing service credentials")
+
+ project_id = encrypted_extra.get("credentials_info", {}).get("project_id")
+
+ if project_id:
+ return f"{cls.default_driver}://{project_id}/?{query_params}"
+
+ raise ValidationError("Invalid service credentials")
+
+ @classmethod
+ def get_parameters_from_uri(
+ cls, uri: str, encrypted_extra: Optional[Dict[str, str]] = None
+ ) -> Any:
+ value = make_url(uri)
+
+ # Building parameters from encrypted_extra and uri
+ if encrypted_extra:
+ return {**encrypted_extra, "query": value.query}
+
+ raise ValidationError("Invalid service credentials")
+
+ @classmethod
+ def validate_parameters(
+ cls, parameters: SnowflakeParametersType # pylint: disable=unused-argument
+ ) -> List[SupersetError]:
+ return []
+
+ @classmethod
+ def parameters_json_schema(cls) -> Any:
+ """
+ Return configuration parameters as OpenAPI.
+ """
+ if not cls.parameters_schema:
+ return None
+
+ ma_plugin = MarshmallowPlugin()
+ spec = APISpec(
+ title="Database Parameters",
+ version="1.0.0",
+ openapi_version="3.0.0",
+ plugins=[ma_plugin],
+ )
+
+ spec.components.schema(cls.__name__, schema=cls.parameters_schema)
+ return spec.to_dict()["components"]["schemas"][cls.__name__]