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


##########
superset-frontend/plugins/plugin-chart-pivot-table/test/plugin/buildQuery.test.ts:
##########
@@ -56,9 +55,41 @@ const formData: PivotTableQueryFormData = {
   currencyFormat: { symbol: 'USD', symbolPosition: 'prefix' },
 };
 
-test('should build groupby with series in form data', () => {
+test('additive metrics use the fast-path: a single full-detail query', () => {
+  const { queries } = buildQuery({
+    ...formData,
+    metrics: [
+      {
+        expressionType: 'SIMPLE',
+        aggregate: 'SUM',
+        column: { column_name: 'num' },
+        label: 'sum_num',
+      },
+    ] as any,
+  });
+  expect(queries).toHaveLength(1);
+  // The single leaf query carries all dimensions (2 rows + 2 cols).
+  expect(queries[0].columns).toHaveLength(4);
+});
+
+test('non-additive metrics emit a single GROUPING SETS query with all levels', 
() => {
+  // 2 row dims x 2 col dims -> (2+1) x (2+1) = 9 rollup levels, carried as
+  // grouping_sets on a single query (saved-metric strings are non-additive).
   const queryContext = buildQuery(formData);
+  expect(queryContext.queries).toHaveLength(1);
   const [query] = queryContext.queries;
+  // The single query selects the full set of dimensions ...
+  expect(query.columns).toHaveLength(4);
+  // ... and requests every rollup level via grouping_sets (grand total = []).
+  expect((query as any).grouping_sets).toHaveLength(9);
+  expect((query as any).grouping_sets[0]).toEqual([]);
+  expect((query as any).grouping_sets[8]).toHaveLength(4);

Review Comment:
   **Suggestion:** Introduce a typed query interface (including 
`grouping_sets`) and cast `query` to that concrete type instead of using `any` 
in assertions. [custom_rule]
   
   **Severity Level:** Minor ๐Ÿงน
   <details>
   <summary><b>Why it matters? โญ </b></summary>
   
   The new assertions cast `query` to `any` three times, which is a direct 
TypeScript `any` usage in changed code. That matches the no-any-types rule 
violation exactly.
   </details>
   <details>
   <summary><b>Rule source ๐Ÿ“– </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 16)
   </details>
   
   [![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=8f605b8e8a2b4cb2a9425cae9fc3fcb8&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=8f605b8e8a2b4cb2a9425cae9fc3fcb8&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** 
superset-frontend/plugins/plugin-chart-pivot-table/test/plugin/buildQuery.test.ts
   **Line:** 75:86
   **Comment:**
        *Custom Rule: Introduce a typed query interface (including 
`grouping_sets`) and cast `query` to that concrete type instead of using `any` 
in assertions.
   
   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%2F41184&comment_hash=4eda982ff6cc90118d8e7ca4331819a044db7291dd30bc9a9e941cd24ceb7f27&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41184&comment_hash=4eda982ff6cc90118d8e7ca4331819a044db7291dd30bc9a9e941cd24ceb7f27&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