betodealmeida commented on code in PR #36247:
URL: https://github.com/apache/superset/pull/36247#discussion_r2561352482


##########
superset-frontend/plugins/plugin-chart-ag-grid-table/test/buildQuery.test.ts:
##########
@@ -474,5 +474,35 @@ describe('plugin-chart-ag-grid-table', () => {
 
       expect(query.columns).toEqual(['state', 'city']);
     });
+
+    it('should preserve undefined metrics in RAW RECORDS mode with 
columnOrder', () => {
+      const rawFormData: TableChartFormData = {
+        viz_type: VizType.Table,
+        datasource: '11__table',
+        query_mode: QueryMode.Raw,
+        all_columns: ['order_number', 'product_line', 'country'],
+      };
+
+      const query = buildQuery(
+        {
+          ...rawFormData,
+          result_format: 'csv',
+        },
+        {
+          ownState: {
+            columnOrder: ['country', 'product_line', 'order_number'],
+          },
+        },
+      ).queries[0];
+
+      // Columns should be reordered
+      expect(query.columns).toEqual([
+        'country',
+        'product_line',
+        'order_number',
+      ]);
+      // Metrics must be undefined (not []) to prevent backend from adding 
GROUP BY

Review Comment:
   Why are we adding a group by when `metrics=[]`? Shouldn't we fix that 
instead?
   
   If we don't want to change it because we're worried we're going to break 
something, can we at least have `metrics=null` here, instead of `undefined`? 
Relying on a variable being `undefined` and having to do extra work to not 
define it is such a brittle flow...



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