You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "dineshvk2 (via GitHub)" <gi...@apache.org> on 2024/09/24 14:24:21 UTC

[I] APi - /api/v1/chart/data - failing for missing Datetime column not provided for certain charts only [superset]

dineshvk2 opened a new issue, #30376:
URL: https://github.com/apache/superset/issues/30376

   ### Bug description
   
   I’m encountering an issue with the API (/api/v1/chart/data) when fetching chart data. The error message states: 'Datetime column not provided as part of the table configuration and is required for this chart type.' Although the chart renders correctly in the UI, the API call fails. As a workaround, opening and saving the chart without making any changes resolves the issue.
   Has a fix been implemented for this?
   Same issue was reported earlier - https://apache-superset.slack.com/archives/C015WAZL0KH/p1667844640596479
   Chart details - Temporal X-Axis - day column (timestamp)
   Time Grain - Week
   
   ### How to reproduce the bug
   
   Query context payload difference between initial version rendered and changes occurred after saving the chart without changes.
   <img width="783" alt="image" src="https://github.com/user-attachments/assets/2fda8f1c-8474-4d81-a4de-20d9d5894b79">
   <img width="809" alt="image" src="https://github.com/user-attachments/assets/93df4884-d79c-489b-bbb9-125a38d4278f">
   
   
   ### Screenshots/recordings
   
   _No response_
   
   ### Superset version
   
   master / latest-dev
   
   ### Python version
   
   3.10
   
   ### Node version
   
   16
   
   ### Browser
   
   Chrome
   
   ### Additional context
   
   _No response_
   
   ### Checklist
   
   - [X] I have searched Superset docs and Slack and didn't find a solution to my problem.
   - [ ] I have searched the GitHub issue tracker and didn't find a similar bug report.
   - [X] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.


-- 
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: notifications-unsubscribe@superset.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] APi - /api/v1/chart/data - failing for missing Datetime column not provided for certain charts only [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on issue #30376:
URL: https://github.com/apache/superset/issues/30376#issuecomment-2802564271

   I'm not sure what to make of this one, and I'm guessing others aren't either, thus it's at at-risk of being closed as stale/not-planned. Are you still facing this issue in 4.1.2 or newer? There may have been some API changes in that time. 
   
   You also mention this is an API question... if you can give a failing payload/CURL with example dashboards/charts/data, that would help us reproduce it at least.


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] APi - /api/v1/chart/data - failing for missing Datetime column not provided for certain charts only [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #30376:
URL: https://github.com/apache/superset/issues/30376#issuecomment-2371460344

   <!-- Greeting -->
   Hey @dineshvk2! I'm here to help you with any bugs, questions, or contributions you have regarding the API issue. Let's work together to find a solution.
   
   <!-- Answer -->
   A similar issue has been reported and addressed. The error occurs when the `granularity` variable is not provided and the `is_timeseries` variable is `True`. This triggers the 'Datetime column not provided' error in the API <sup>[[1]](https://github.com/apache/superset/blob/master/superset/models/helpers.py)</sup>.
   
   A fix has been implemented to address this issue. The specific change involves ensuring that the temporal column is added first to the columns array if it meets certain conditions. Here is the relevant code snippet:
   
   ```ts
   const temporalColumnsLookup = formData?.temporal_columns_lookup;
   // Filter out the column if needed and prepare the temporal column object
   
   columns = columns.filter(col => {
     const shouldBeAdded =
       isPhysicalColumn(col) &&
       time_grain_sqla &&
       temporalColumnsLookup?.[col];
     if (shouldBeAdded && !temporalColumnAdded) {
       temporalColumn = {
         timeGrain: time_grain_sqla,
         columnType: 'BASE_AXIS',
         sqlExpression: col,
         label: col,
         expressionType: 'SQL',
       } as AdhocColumn;
       temporalColumnAdded = true;
       return false; // Do not include this in the output; it's added separately
     }
     return true;
   });
   
   // So we ensure the temporal column is added first
   if (temporalColumn) {
     columns = [temporalColumn, ...columns];
   }
   ```
   
   This code ensures that the temporal column is correctly added, thus resolving the issue with the missing Datetime column <sup>[[2]](https://github.com/apache/superset/blob/master/superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts)</sup>.
   
   Additionally, saving the chart without making any changes updates the `metadata` state, ensuring that the `metadata` used for rendering in the UI and the `metadata` sent in the API call are synchronized. This resolves any discrepancies and prevents the error from occurring <sup>[[3]](https://github.com/apache/superset/blob/master/superset-frontend/src/dashboard/actions/dashboardInfo.ts)</sup>.
   
   For best practices, always specify the `granularity` parameter for timeseries charts and ensure that the Datetime column is correctly configured in the table schema <sup>[[1]](https://github.com/apache/superset/blob/master/superset/models/helpers.py)</sup><sup>[[4]](https://github.com/apache/superset/blob/master/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/legacy-preset-chart-nvd3/Compare/stories/timeFormat.tsx)</sup>.
   
   
   <!-- Dosu Comment Footer -->
   *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] APi - /api/v1/chart/data - failing for missing Datetime column not provided for certain charts only [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas closed issue #30376: APi - /api/v1/chart/data - failing for missing Datetime column not provided for certain charts only
URL: https://github.com/apache/superset/issues/30376


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] APi - /api/v1/chart/data - failing for missing Datetime column not provided for certain charts only [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on issue #30376:
URL: https://github.com/apache/superset/issues/30376#issuecomment-3109868635

   Since we haven't heard back with any context in newer versions, or any repro steps, I'll close this as not-planned. Happy to revisit/reopen with more context. 


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org