codeant-ai-for-open-source[bot] commented on code in PR #43757:
URL: https://github.com/apache/superset/pull/43757#discussion_r4161937942
##########
superset/datasets/schemas.py:
##########
@@ -100,6 +100,17 @@ class DatasetColumnsPutSchema(Schema):
datetime_format = fields.String(
allow_none=True, validate=[Length(1, 100), validate_python_date_format]
)
+ partition_value_transform = fields.String(
+ allow_none=True,
+ metadata={
+ "description": (
+ "SQL expression containing a :value placeholder. Filters on "
+ "this column are mirrored onto the dataset's partition column "
+ "with the value passed through this transform."
+ )
+ },
+ )
+ partition_transform_is_monotonic = fields.Boolean(load_default=False)
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and
marked this thread resolved** as of `0b4ba99`.
`partition_transform_is_monotonic` has no `load_default`, so omitted fields
remain absent from the deserialized payload and are treated as unchanged. New
columns still use the model default.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it
open.</sub>
<!-- codeant-auto-resolve-reply -->
##########
superset/commands/dataset/update.py:
##########
@@ -291,6 +295,8 @@ def _validate_semantics(self, exceptions:
list[ValidationError]) -> None:
if predicate := self._properties.get("fetch_values_predicate"):
self._validate_fetch_values_predicate(predicate, exceptions)
+ self._validate_partition_mapping(exceptions)
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and
marked this thread resolved** as of `0b4ba99`.
`_validate_partition_mapping` now returns immediately when
`PARTITION_FILTER_MAPPING` is disabled, preventing mapping validation from
rejecting updates in disabled deployments.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it
open.</sub>
<!-- codeant-auto-resolve-reply -->
##########
superset/connectors/sqla/models.py:
##########
@@ -1894,8 +1925,44 @@ def data(self) -> ExplorableData:
data_["extra"] = self.extra
data_["always_filter_main_dttm"] = self.always_filter_main_dttm
data_["normalize_columns"] = self.normalize_columns
+ data_["partition_column"] = self.partition_column
+ data_["partition_mapped_column"] = self.partition_mapped_column
+ data_["partition_filter_mapping"] =
self.partition_filter_mapping_summary
return data_
+ @property
+ def partition_filter_mapping_summary(self) -> dict[str, Any] | None:
+ """
+ Self-contained summary of the mapping for the Explore indicator.
+
+ Deliberately not a lookup into `columns`: `data_for_slices` prunes
+ columns no chart references, and the partition column is typically
+ referenced by none of them, so anything reading it out of
+ `datasource.columns` would work in Explore and break on dashboards.
+
+ `active` is derived from cheap signals only. This property is
serialized
+ on every chart and dashboard load, so parsing the transform here would
+ put a per-request cost on a hot path for a value that only changes on
+ save.
+ """
+ if not self.partition_column:
+ return None
+
+ columns_by_name = {column.column_name: column for column in
self.columns}
+ mapped_column_name = self.partition_mapped_column or self.main_dttm_col
+ mapped_column = columns_by_name.get(mapped_column_name or "")
+ active = bool(
+ self.partition_column in columns_by_name
+ and mapped_column is not None
+ and mapped_column_name != self.partition_column
+ and (mapped_column.partition_value_transform or "").strip()
+ )
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and
marked this thread resolved** as of `0b4ba99`.
The summary now derives `active` from `is_transform_active(...)` in addition
to checking the partition and mapped columns, so invalid or inactive transforms
are not reported as active.
<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]