mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
fix(snowflake): opt-in denormalization of column names (#24982)
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from typing import Any
|
||||
from typing import Any, Optional
|
||||
|
||||
from marshmallow import fields, post_load, pre_load, Schema, validate
|
||||
from typing_extensions import TypedDict
|
||||
@@ -29,6 +29,7 @@ class ExternalMetadataParams(TypedDict):
|
||||
database_name: str
|
||||
schema_name: str
|
||||
table_name: str
|
||||
normalize_columns: Optional[bool]
|
||||
|
||||
|
||||
get_external_metadata_schema = {
|
||||
@@ -36,6 +37,7 @@ get_external_metadata_schema = {
|
||||
"database_name": "string",
|
||||
"schema_name": "string",
|
||||
"table_name": "string",
|
||||
"normalize_columns": "boolean",
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +46,7 @@ class ExternalMetadataSchema(Schema):
|
||||
database_name = fields.Str(required=True)
|
||||
schema_name = fields.Str(allow_none=True)
|
||||
table_name = fields.Str(required=True)
|
||||
normalize_columns = fields.Bool(allow_none=True)
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
@post_load
|
||||
@@ -57,6 +60,7 @@ class ExternalMetadataSchema(Schema):
|
||||
database_name=data["database_name"],
|
||||
schema_name=data.get("schema_name", ""),
|
||||
table_name=data["table_name"],
|
||||
normalize_columns=data["normalize_columns"],
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -77,6 +77,8 @@ class Datasource(BaseSupersetView):
|
||||
return json_error_response(_("Request missing data field."), status=500)
|
||||
|
||||
datasource_dict = json.loads(data)
|
||||
normalize_columns = datasource_dict.get("normalize_columns", False)
|
||||
datasource_dict["normalize_columns"] = normalize_columns
|
||||
datasource_id = datasource_dict.get("id")
|
||||
datasource_type = datasource_dict.get("type")
|
||||
database_id = datasource_dict["database"].get("id")
|
||||
@@ -196,6 +198,7 @@ class Datasource(BaseSupersetView):
|
||||
database=database,
|
||||
table_name=params["table_name"],
|
||||
schema_name=params["schema_name"],
|
||||
normalize_columns=params.get("normalize_columns") or False,
|
||||
)
|
||||
except (NoResultFound, NoSuchTableError) as ex:
|
||||
raise DatasetNotFoundError() from ex
|
||||
|
||||
Reference in New Issue
Block a user