mikebridge commented on code in PR #44270:
URL: https://github.com/apache/superset/pull/44270#discussion_r4041219273
##########
superset/mcp_service/semantic_layer/tool/get_table.py:
##########
@@ -180,8 +194,52 @@ def _resolve_external_view(
error_type="ValidationError",
)
+ duration: str | None
+ valid_grains: dict[str, str] = {
+ duration: grain["name"]
+ for grain in view.get_time_grains()
+ if (duration := grain["duration"]) is not None
+ }
+ grain_column: str | None = request.time_column
+ if request.time_grain:
+ selected: list[str] = sorted(set(request.dimensions) &
valid_dttm_columns)
+ if grain_column is None:
+ if len(selected) != 1:
+ return SemanticLayerError.create(
+ error=f"time_grain on view '{display_name}' requires one
temporal "
+ f"dimension; selected: {selected}. Set time_column
explicitly.",
+ error_type="ValidationError",
+ )
+ grain_column = selected[0]
+ # The mapper chooses variants by dimension name, not the view-wide
union.
+ valid_grains = {
+ dimension.grain.representation: dimension.grain.name
+ for dimension in view.implementation.get_dimensions()
+ if dimension.name == grain_column and dimension.grain is not None
+ }
+ if request.time_grain not in valid_grains:
+ choices: str = ", ".join(
+ f"{duration} ({name})"
+ for duration, name in sorted(valid_grains.items())
+ )
Review Comment:
addressed in 56ba2b91c0ec05f94f9c3707bef06384030fbb5e
--
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]