michael-s-molina commented on code in PR #37815: URL: https://github.com/apache/superset/pull/37815#discussion_r2891581487
########## superset-core/src/superset_core/semantic_layers/semantic_view.py: ########## @@ -0,0 +1,109 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +from __future__ import annotations + +import enum +from abc import ABC, abstractmethod + +from superset_core.semantic_layers.types import ( + Dimension, + Filter, + GroupLimit, + Metric, + OrderTuple, + SemanticResult, +) + + +# TODO (betodealmeida): move to the extension JSON +class SemanticViewFeature(enum.Enum): + """ + Custom features supported by semantic layers. + """ + + ADHOC_EXPRESSIONS_IN_ORDERBY = "ADHOC_EXPRESSIONS_IN_ORDERBY" + GROUP_LIMIT = "GROUP_LIMIT" + GROUP_OTHERS = "GROUP_OTHERS" + + +class SemanticView(ABC): + """ + Abstract base class for semantic views. + """ + + features: frozenset[SemanticViewFeature] + + @abstractmethod + def uid(self) -> str: + """ + Returns a unique identifier for the semantic view. + """ + + @abstractmethod + def get_dimensions(self) -> set[Dimension]: + """ + Get the dimensions defined in the semantic view. + """ + + @abstractmethod + def get_metrics(self) -> set[Metric]: + """ + Get the metrics defined in the semantic view. + """ + + @abstractmethod + def get_values( + self, + dimension: Dimension, + filters: set[Filter] | None = None, + ) -> SemanticResult: + """ + Return distinct values for a dimension. + """ + + @abstractmethod + def get_dataframe( Review Comment: Can we rename to something else than `get_dataframe`? -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
