codeant-ai-for-open-source[bot] commented on code in PR #43891:
URL: https://github.com/apache/superset/pull/43891#discussion_r4067125310
##########
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:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and
marked this thread resolved** as of `cf75501`.
Added an early `mapping.mirrors(operator)` guard that returns a structured
invalid response before calling `build_mirrored_predicates` for unsupported
operators.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it
open.</sub>
<!-- codeant-auto-resolve-reply -->
--
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]