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