How to allow Superset to recognize that a string is a datetime?
Asked Answered
S

1

9

I am using Superset as a data visualizer with an SQLite database. Because SQLite doesn't have DATETIME type, I use the type TEXT to add a date and an hour.

Nevertheless, Superset then doesn't recognize that this "TEXT" or String is a date!

This is my data:

CREATE TABLE TEST(
    TEST_ID int PRIMARY KEY NOT NULL,
    VEHICLE_ID int NULL,
    TEST_TYPE_ID int NULL,
    CHECK_TYPE_ID int NULL,
    NUM_TEST int NULL,
    TEST_DATE TEXT NOT NULL
);

INSERT INTO TEST (TEST_ID, VEHICLE_ID, TEST_TYPE_ID, CHECK_TYPE_ID, NUM_TEST, TEST_DATE) VALUES (844, 504, 3, 1, 3, '2007-01-01 10:00:00');

Then in Superset I have the following message:

Datetime column not provided as part table configuration and is required by this type of chart

With the details:

  Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/superset/viz.py", line 234, in get_payload
    df = self.get_df()
  File "/usr/lib/python2.7/site-packages/superset/viz.py", line 78, in get_df
    self.results = self.datasource.query(query_obj)
  File "/usr/lib/python2.7/site-packages/superset/connectors/sqla/models.py", line 538, in query
    qry = self.get_sqla_query(**query_obj)
  File "/usr/lib/python2.7/site-packages/superset/connectors/sqla/models.py", line 370, in get_sqla_query
    "Datetime column not provided as part table configuration "
Exception: Datetime column not provided as part table configuration and is required by this type of chart

I tried to replace TEXT by TEXT AS DATETIME creating the table but it's a syntax error.

Do you have any solution?

Stephanestephani answered 25/4, 2017 at 8:32 Comment(2)
Just write DATETIME (or whatever Superset requires) in the table definition.Tonatonal
@CL I tried it before, but with Datetime, Superset doesn't even recognize the data inside the table because, if I'm not wrong, SQLite doesn't use DATETIME type.Stephanestephani
T
5

There is a setting in the Datasource editor. On the Columns tab, change the Is Temporal flag to checked (true)

Topee answered 25/8, 2020 at 16:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.