codeant-ai-for-open-source[bot] commented on code in PR #43480:
URL: https://github.com/apache/superset/pull/43480#discussion_r3846279446


##########
superset/mcp_service/chart/schemas.py:
##########
@@ -1094,6 +1094,136 @@ def reject_sql_expression_on_dimensions(self) -> 
"PivotTableChartConfig":
         return self
 
 
+class InteractivePivotChartConfig(BaseChartConfig):
+    """Config for Preset's AG Grid interactive pivot visualization.
+
+    This is intentionally separate from :class:`PivotTableChartConfig`, which
+    targets the OSS ``pivot_table_v2`` visualization.
+    """
+
+    model_config = ConfigDict(extra="ignore", populate_by_name=True)
+
+    chart_type: Literal["interactive_pivot"] = "interactive_pivot"
+    rows: List[ColumnRef] = Field(
+        ...,
+        min_length=1,
+        description=(
+            "Dimensions placed in the AG Grid Rows side-panel bucket, in 
nesting order"
+        ),
+    )
+    columns: List[ColumnRef] = Field(
+        default_factory=list,
+        description=(
+            "Dimensions placed in the AG Grid Column Labels side-panel bucket"
+        ),
+    )
+    metrics: List[ColumnRef] = Field(
+        ...,
+        min_length=1,
+        description=(
+            "Value columns. Each metric's aggregate controls the SQL 
aggregation "
+            "and its AG Grid group rollup (AVG/MIN/MAX map to avg/min/max; 
additive "
+            "aggregates roll up with sum)."
+        ),
+    )
+    time_grain: TimeGrain | None = Field(
+        None,
+        description="PT1H, P1D, P1W, P1M, P3M, or P1Y for temporal dimensions",
+        validation_alias=AliasChoices("time_grain", "time_grain_sqla"),
+    )
+    filters: List[FilterConfig] | None = Field(
+        None,
+        description=(
+            "Structured filters (column/op/value). Do NOT use adhoc_filters or 
"
+            "raw SQL expressions."
+        ),
+    )
+    series_limit: int | None = Field(
+        None,
+        description="Maximum number of pivot series",
+        ge=0,
+        le=50000,
+    )
+    series_limit_metric: ColumnRef | None = Field(
+        None,
+        description="Metric used to rank series when a series/cell limit 
applies",
+    )

Review Comment:
   **Suggestion:** The `series_limit_metric` field accepts any `ColumnRef`, 
including a plain dimension with no aggregate or saved-metric marker. 
`map_interactive_pivot_config` then passes it to `create_metric_object`, which 
defaults such a reference to `SUM(column)`. A request such as `{"name": 
"region"}` therefore becomes a series-ranking metric of `SUM(region)`, 
potentially producing an invalid SQL aggregation or ranking by unintended 
values. Require this reference to represent a metric (an aggregate, saved 
metric, or SQL expression) before accepting it. [api mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Interactive Pivot generation can fail for nonnumeric ranking dimensions.
   - ⚠️ Numeric dimensions may rank series by unintended SUM values.
   - ⚠️ Series limiting produces incorrect user-visible pivot results.
   ```
   </details>
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=75edd9c68024477ba500b9a569b1d6c5&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=75edd9c68024477ba500b9a569b1d6c5&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/mcp_service/chart/schemas.py
   **Line:** 1147:1150
   **Comment:**
        *Api Mismatch: The `series_limit_metric` field accepts any `ColumnRef`, 
including a plain dimension with no aggregate or saved-metric marker. 
`map_interactive_pivot_config` then passes it to `create_metric_object`, which 
defaults such a reference to `SUM(column)`. A request such as `{"name": 
"region"}` therefore becomes a series-ranking metric of `SUM(region)`, 
potentially producing an invalid SQL aggregation or ranking by unintended 
values. Require this reference to represent a metric (an aggregate, saved 
metric, or SQL expression) before accepting it.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43480&comment_hash=2b163c6162c97bd3b76aacf22b35e4e2c8db72d86143440d7ff02d8ddcb09223&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43480&comment_hash=2b163c6162c97bd3b76aacf22b35e4e2c8db72d86143440d7ff02d8ddcb09223&reaction=dislike'>👎</a>



-- 
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]

Reply via email to