EnxDev commented on code in PR #44997:
URL: https://github.com/apache/superset/pull/44997#discussion_r4200904864
##########
superset/semantic_layers/models.py:
##########
@@ -595,6 +595,18 @@ def column_names(self) -> list[str]:
def data(self) -> ExplorableData:
dimensions = self._unique_dimensions
metrics = list(self.implementation.get_metrics())
+ preferred_time_dimension: str | None = (
+ self.implementation.preferred_time_dimension
+ )
+ main_dttm_col: str | None = next(
Review Comment:
This only reaches the `data` payload. The backend paths that do
`getattr(datasource, "main_dttm_col", None)` on the model still get None, so a
view that declares `metric_time` still hits the "multiple datetime dimensions"
error in `tabular_query.py:148`, and the granularity inference at
`query_context_factory.py:268` won't use it either.
Could this live in a `main_dttm_col` property on the model, with `data`
reading from it, so both sides agree?
##########
superset/semantic_layers/models.py:
##########
@@ -595,6 +595,18 @@ def column_names(self) -> list[str]:
def data(self) -> ExplorableData:
dimensions = self._unique_dimensions
metrics = list(self.implementation.get_metrics())
+ preferred_time_dimension: str | None = (
+ self.implementation.preferred_time_dimension
+ )
+ main_dttm_col: str | None = next(
+ (
+ dimension.name
+ for dimension in dimensions
+ if dimension.name == preferred_time_dimension
+ and get_column_type(dimension.type) == GenericDataType.TEMPORAL
+ ),
+ None,
Review Comment:
Nit, take it or leave it. If the name has a typo, or names a dimension the
view doesn't expose, this falls back silently, and a provider author will have
a hard time spotting it.
A `logger.warning` when `preferred_time_dimension` is set but nothing
matches would make it visible.
--
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]