apache / superset

Apache Superset is a Data Visualization and Data Exploration Platform
https://superset.apache.org/
Apache License 2.0
61.76k stars 13.51k forks source link

Error rendering Event Flow graph #30068

Open Cmagno13 opened 2 weeks ago

Cmagno13 commented 2 weeks ago

Bug description

Bug Description When a user creates an Event Flow chart, the chart gives the following error "Date and time column not provided as part of the table configuration is required by this chart type". However, these requirements are met

image

How to reproduce the bug

1 - Create an Event Flow chart 2 - Add data to the chart, 3 - Your dataset must have a date column

Screenshots/recordings

No response

Superset version

4.0.2

Python version

3.9

Node version

16

Browser

Chrome

Additional context

No response

Checklist

dosubot[bot] commented 2 weeks ago

@Cmagno13 Hello there! I'm here to help you with any issues you may be experiencing. I can assist in solving bugs, answering questions, and even guide you on becoming a contributor. Let's work together to resolve your concerns.

I found a similar issue related to the Event Flow chart in Superset version 4.0.2. The error "Datetime column not provided as part table configuration and is required by this type of chart" typically occurs when the datetime column is not correctly included in the table configuration.

To resolve this, ensure that your dataset includes a column mapped to the __timestamp field. The TS (timestamp) is derived from the __timestamp field in the data records. Here is the relevant part of the code that handles the datetime column:

[TS]: (datum: TimeseriesDataRecord): Date | null =>
  datum.__timestamp || datum.__timestamp === 0
    ? new Date(datum.__timestamp)
    : null,

Make sure your dataset includes a __timestamp field with valid datetime values. If your dataset does not have a __timestamp field, you need to add it or map your existing datetime column to __timestamp [1].

Additionally, ensure that your visualization class, such as EventFlowViz, correctly handles the datetime column. The EventFlowViz class inherits from BaseViz and sets is_timeseries to True, indicating that a datetime column is required:

class EventFlowViz(BaseViz):
    """A visualization to explore patterns in event sequences"""

    viz_type = "event_flow"
    verbose_name = _("Event flow")
    credits = 'from <a href="https://github.com/williaster/data-ui">@data-ui</a>'
    is_timeseries = True

    @deprecated(deprecated_in="3.0")
    def query_obj(self) -> QueryObjectDict:
        query = super().query_obj()
        form_data = self.form_data

        event_key = form_data["all_columns_x"]
        entity_key = form_data["entity"]
        meta_keys = [
            col
            for col in form_data["all_columns"] or []
            if col not in (event_key, entity_key)
        ]

        query["columns"] = [event_key, entity_key] + meta_keys

        if form_data["order_by_entity"]:
            query["orderby"] = [(entity_key, True)]

        return query

    @deprecated(deprecated_in="3.0")
    def get_data(self, df: pd.DataFrame) -> VizData:
        return df.to_dict(orient="records")

Ensure that your form data includes the necessary datetime configuration and that the query_obj method correctly includes the datetime column in the query [2].

To continue talking to Dosu, mention @dosu.

rusackas commented 2 weeks ago

I'm not sure, but this plugin is built with some libraries that are no longer supported, and don't support newer versions of React. We'll be deprecating this in the next major version of Superset so that the rest of the project can move forward. Iv anyone needs an event flow diagram, we would more than welcome any volunteers to build a more modern one with ECharts or otherwise.

michael-s-molina commented 1 week ago

There's a 5.0 proposal to remove this plugin.

rusackas commented 1 week ago

Honestly, I'm tempted to close this as "won't fix" but I can leave it open if you want to take a shot at it, @Cmagno13.