sadpandajoe commented on code in PR #43891:
URL: https://github.com/apache/superset/pull/43891#discussion_r3949596545
##########
superset/connectors/sqla/partition_mapping.py:
##########
@@ -689,27 +783,94 @@ def preview_partition_mapping(
transform=value_transform,
engine=engine,
):
- return {"valid": False, "error": str(issue.message)}
+ return {
+ "valid": False,
+ # The parse failure is the one an owner sees constantly, and it is
+ # the only one the mockup gives its own headline to.
+ "reason": (
+ "parse"
+ if issue.field == "partition_value_transform"
+ and not is_parseable(value_transform, engine)
+ else "validation"
+ ),
+ "error": str(issue.message),
+ }
- evaluated = evaluate_transform(
- datasource.database,
- datasource.catalog,
- datasource.schema,
- cast(str, value_transform),
- [sample_value],
+ mapping = PartitionMapping(
+ partition_column=str(partition_column),
+ mapped_column=mapped_column,
+ value_transform=cast(str, value_transform),
+ is_monotonic=is_monotonic,
)
- if evaluated is None:
+ sample_input = _render_sample_input(mapped_column, operator, sample_values)
+
+ if not mapping.mirrors(operator):
return {
"valid": False,
- "error": _("The transform could not be evaluated against the
database."),
+ "reason": "operator",
+ "sample_input": sample_input,
+ "error": _(
+ "A %(operator)s filter is only mirrored when the transform "
+ "preserves ordering, which this one is not declared to do.",
+ operator=operator.value,
+ ),
+ }
+
+ value: Any = sample_values if operator == FilterOperator.IN else
sample_values[0]
+ errors: list[str] = []
+ predicates = build_mirrored_predicates(
+ datasource, mapping, [(operator, value)], errors=errors
+ )
Review Comment:
`TEMPORAL_RANGE` is allowed by the preview schema, but this path forwards
the single transformed value to `handle_comparison_filter`, whose base
implementation only handles scalar comparison operators and raises `ValueError`
for `TEMPORAL_RANGE`. Should the preview either reject this operator or build
both range bounds with the same temporal-range path as chart queries?
--
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]