Comments (2)
@QMalcolm I wanted to lay out a proposed implementation to get your feedback on whether I'm heading in the right direction. Dimensions contain 4 classes that we'll want to migrate over:
- DimensionType (enum)
- DimensionValidityParams
- DimensionTypeParams
- Dimension
For the final three, I think it is reasonable for us to create Protocols for each of them.
Where I'm a bit fuzzy is in regard to our implementation of enums and methods that we've used the @property
decorator on. Let's start with methods.
@Property Methods
To the best of my knowledge, Protocols can't support methods as properties. Which means:
@property
def is_primary_time(self) -> bool: # noqa: D
if self.type == DimensionType.TIME and self.type_params is not None:
return self.type_params.is_primary
return False
Would become:
def is_primary_time(self) -> bool:
if self.type == DimensionType.TIME and self.type_params is not None:
return self.type_params.is_primary
return False
Then when we implement it in MetricFlow we would use the @Property decorator and the default implementation from the Protocol. That way we ensure that we don't need to change its use all throughout the codebase.
@property
def is_primary_time(self) -> bool:
return super().is_primary_time()
Does that seem like a reasonable implementation to you?
Enums
Okay this one I'm a bit more confused about. Do we ... have to do anything here beyond moving the Enum into this repo and then referencing it in the Protocol? Is it as simple as that?
Protocols
Oh just to make sure I'm also thinking about the Protocols correctly, is this looking fine? Do we have a naming convention of wanting to keep it to the same name or would we want Protocol to be appended onto the end of it so the implementing libraries can use the original name 🤔
class DimensionTypeParamsProtocol(Protocol):
is_primary: bool
time_granularity: TimeGranularity
validity_params: Optional[DimensionValidityParams]
from dbt-semantic-interfaces.
While we wait to cut the code over from MetricFlow, I'm gonna throw a draft into this issue.
# Keeping this the same!
class DimensionType(ExtendedEnum):
"""Determines types of values expected of dimensions."""
CATEGORICAL = "categorical"
TIME = "time"
def is_time_type(self) -> bool:
"""Checks if this type of dimension is a time type"""
return self in [DimensionType.TIME]
class DimensionValidityParamsProtocol(Protocol):
is_start: bool = False
is_end: bool = False
class DimensionTypeParamsProtocol(Protocol):
is_primary: bool
time_granularity: TimeGranularity
validity_params: Optional[DimensionValidityParams]
class DimensionProtocol(Protocol):
name: str
description: Optional[str]
type: DimensionType
type_params: Optional[DimensionTypeParams]
is_partition: bool
expr: Optional[str]
is_primary_time: bool
reference: DimensionReference
time_dimension_reference: TimeDimensionReference
validity_params: Optional[DimensionValidityParams]
from dbt-semantic-interfaces.
Related Issues (20)
- [SL-1325] [EPIC] DSI 0.5.0 HOT 1
- [SL-1435] make the `label` attribute required HOT 1
- [SL-1460] Add Dependabot config to dbt-semantic-interfaces
- Automate changelog generation for dependabot PRs
- [Feature] Add config block to saved queries to flag a saved query as enabled/disabled for the declarative cache.
- [Bug] Please support pydantic-2.x HOT 1
- [SL-1489] [Bug] The pydantic shim isn't being included in the `wheel` distributions of the package
- [SL-1491] [CI/CD] Create github action that checks the produced distributions are functional
- [SL-1507] Release 0.5.0a3
- [SL-1508] Release 0.4.3 HOT 1
- [SL-1563] [Feature] Add `meta` to Metric/SemanticModel HOT 2
- [Feature] Add cache config to saved query HOT 3
- [Feature] Add `timezone` key to time dimensions `type_params` HOT 1
- [SL-1603] Remove `create_metric` from protocol spec
- [SL-1610] [SL-1610] [Bug] Referencing entities in where filter causes an error.
- [Python 3.12] Support + test against python 3.12 in dbt-semantic-interfaces
- [Feature] Allow specifying saved query group by items with dundered syntax vs the object syntax HOT 1
- [Bug] Derived metric validation allows empty input metric set
- [Bug] Make `expr` required for derived metrics
- [Feature] Support referencing a metric in where filter HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dbt-semantic-interfaces.