PrakharAgarwal17 commented on code in PR #46008:
URL: https://github.com/apache/superset/pull/46008#discussion_r4473285651


##########
superset-frontend/plugins/plugin-chart-table/test/buildQuery.test.ts:
##########
@@ -268,6 +268,69 @@ test('preserves semantic reference when a filter overrides 
the chart grain', ()
   ]);
 });
 
+test('applies grain to every temporal dimension and keeps the first axis 
first', () => {
+  const grain = TimeGranularity.MONTH;
+  const customColumn: AdhocColumn = {
+    expressionType: 'SQL',
+    sqlExpression: 'year(created_at)',
+    label: 'created_year',
+  };
+  const query = buildQueryUncached({
+    ...basicFormData,
+    groupby: ['category', customColumn, 'EndDate', 'StartDate'],
+    metrics: ['count'],
+    time_grain_sqla: grain,
+    temporal_columns_lookup: { EndDate: true, StartDate: true },
+  }).queries[0];
+
+  expect(query.columns).toEqual([
+    {
+      timeGrain: grain,
+      columnType: 'BASE_AXIS',
+      sqlExpression: 'EndDate',
+      label: 'EndDate',
+      expressionType: 'SQL',
+    },
+    'category',
+    customColumn,
+    {
+      timeGrain: grain,
+      columnType: 'BASE_AXIS',
+      sqlExpression: 'StartDate',
+      label: 'StartDate',
+      expressionType: 'SQL',
+    },
+  ]);

Review Comment:
   Addressed in 67bf0fc: added `isColumnReference: true` to both 
temporal-column expectations in `applies grain to every temporal dimension and 
keeps the first axis first`.



##########
superset-frontend/plugins/plugin-chart-table/test/buildQuery.test.ts:
##########
@@ -268,6 +268,69 @@ test('preserves semantic reference when a filter overrides 
the chart grain', ()
   ]);
 });
 
+test('applies grain to every temporal dimension and keeps the first axis 
first', () => {
+  const grain = TimeGranularity.MONTH;
+  const customColumn: AdhocColumn = {
+    expressionType: 'SQL',
+    sqlExpression: 'year(created_at)',
+    label: 'created_year',
+  };
+  const query = buildQueryUncached({
+    ...basicFormData,
+    groupby: ['category', customColumn, 'EndDate', 'StartDate'],
+    metrics: ['count'],
+    time_grain_sqla: grain,
+    temporal_columns_lookup: { EndDate: true, StartDate: true },
+  }).queries[0];
+
+  expect(query.columns).toEqual([
+    {
+      timeGrain: grain,
+      columnType: 'BASE_AXIS',
+      sqlExpression: 'EndDate',
+      label: 'EndDate',
+      expressionType: 'SQL',
+    },
+    'category',
+    customColumn,
+    {
+      timeGrain: grain,
+      columnType: 'BASE_AXIS',
+      sqlExpression: 'StartDate',
+      label: 'StartDate',
+      expressionType: 'SQL',
+    },
+  ]);
+});
+
+test('applies dashboard grain override to every temporal dimension', () => {
+  const query = buildQueryUncached({
+    ...basicFormData,
+    groupby: ['StartDate', 'EndDate'],
+    metrics: ['count'],
+    time_grain_sqla: TimeGranularity.DAY,
+    extra_form_data: { time_grain_sqla: TimeGranularity.MONTH },
+    temporal_columns_lookup: { StartDate: true, EndDate: true },
+  }).queries[0];
+
+  expect(query.columns).toEqual([
+    {
+      timeGrain: TimeGranularity.MONTH,
+      columnType: 'BASE_AXIS',
+      sqlExpression: 'StartDate',
+      label: 'StartDate',
+      expressionType: 'SQL',
+    },
+    {
+      timeGrain: TimeGranularity.MONTH,
+      columnType: 'BASE_AXIS',
+      sqlExpression: 'EndDate',
+      label: 'EndDate',
+      expressionType: 'SQL',
+    },
+  ]);

Review Comment:
   Addressed in 67bf0fc: added `isColumnReference: true` to the `StartDate` and 
`EndDate` expectations in `applies dashboard grain override to every temporal 
dimension`.



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

  • Re: [PR] fi... PrakharAgarwal17 (via GitHub) via notifications
  • Re: [PR] fi... PrakharAgarwal17 (via GitHub) via notifications
  • Re: [PR] fi... netlify[bot] (via GitHub) via notifications
  • Re: [PR] fi... PrakharAgarwal17 (via GitHub) via notifications
  • Re: [PR] fi... codeant-ai-for-open-source[bot] (via GitHub) via notifications
  • Re: [PR] fi... codecov[bot] (via GitHub) via notifications
  • Re: [PR] fi... codeant-ai-for-open-source[bot] (via GitHub) via notifications
  • Re: [PR] fi... PrakharAgarwal17 (via GitHub) via notifications
  • Re: [PR] fi... PrakharAgarwal17 (via GitHub) via notifications
  • Re: [PR] fi... codeant-ai-for-open-source[bot] (via GitHub) via notifications
  • Re: [PR] fi... PrakharAgarwal17 (via GitHub) via notifications
  • Re: [PR] fi... codeant-ai-for-open-source[bot] (via GitHub) via notifications

Reply via email to