Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date column in superset displayed as unix timestamp #21508

Closed
3 tasks
alfredho811 opened this issue Sep 18, 2022 · 10 comments · Fixed by #25009
Closed
3 tasks

Date column in superset displayed as unix timestamp #21508

alfredho811 opened this issue Sep 18, 2022 · 10 comments · Fixed by #25009
Labels
#bug Bug report v2.1 validation:required A committer should validate the issue

Comments

@alfredho811
Copy link

A clear and concise description of what the bug is.

How to reproduce the bug

Using Superset verion 2.0.0 and postgres as data warehouse,

I created a heatmap where the x-axis are the dates and y-axis stock codes.

image

The SQL is as follows

SELECT date_trunc('month', release_time_hkt) AS release_month,
       sehk_code AS sehk_code,
       COUNT(*) AS count
FROM l1_trading.vw_trd_hkex_listed_company_publication
GROUP BY date_trunc('month', release_time_hkt),
         sehk_code
ORDER BY count DESC
LIMIT 10000;

I would expect that the x-axis would show the dates in the standard format (e.g. 2022-08-01), not in unix timestamp.

I found a similar issue reported here: #3027

but that's for older superset version.

Environment

(please complete the following information):

  • browser type and version:

  • superset version: superset version ---> 2.0.0

  • python version: python --version (I did not check, because I am simply using the official apache superset docker image apache/superset:2.0.0)

  • node.js version: node -v

  • any feature flags active:

Checklist

Make sure to follow these steps before submitting your issue - thank you!

  • I have checked the superset logs for python stacktraces and included it here as text if there are any.
    ---> I don't see any logs specific to this conversion to unix timestamp

  • I have reproduced the issue with at least the latest released version of superset.
    --> 2.0.0 is the latest superset version

  • I have checked the issue tracker for the same issue and I haven't found one similar.
    ---> I cannot find a similar issue with superset version 2.0.0

Additional context

Add any other context about the problem here.

@alfredho811 alfredho811 added the #bug Bug report label Sep 18, 2022
@mdeshmu
Copy link
Contributor

mdeshmu commented Sep 18, 2022

You will have to mark column as "is temporal" in dataset settings and specify date format as epoch_s or epoch_ms based on the granularity of the stored values. Let me know if this helps.

@alfredho811
Copy link
Author

Hey @mdeshmu

Thanks for your reply.

I guess I did not phrase my problem correcty.

image

As you can see from the above screenshot, the problem is that the column date_trunc('month', release_time_hkt) becomes unix timestamp.

Instead, I want it to be like 2022-08-01, 2022-09-01 instead.

=============

For the column release_time_hkt, I notice that Superset marked it as TIMESTAMP WITHOUT TIME ZONE

image

==========
Similar problem

Given that I am using Postgres as my database and the problematic column is of type date in postgres, I find that the below issue is quite similar to mine.

The solution here is to format the datetime as string

#13295 (comment)

Is that the only solution?

Thanks

@alfredho811
Copy link
Author

alfredho811 commented Sep 19, 2022

I have created a varchar version of the timestamp/date in postgres and it's working like a charm.

image

============

Below is what I did in the code.

image

@sfirke
Copy link
Member

sfirke commented Sep 19, 2022

Is this same / related to #20074 ? That one should be fixed in upcoming 2.0.1

@sfirke
Copy link
Member

sfirke commented Feb 24, 2023

This is fixed in 2.0.1 for me, is this still an issue for you?

@rusackas
Copy link
Member

rusackas commented Mar 7, 2023

Closing since this appears to be fixed :)

@rusackas rusackas closed this as completed Mar 7, 2023
@sqja
Copy link

sqja commented Apr 12, 2023

This problem with timestamp field on X axis seems to be back in 2.1.0, the same was working well with 2.0.1

image

@rusackas rusackas added the v2.1 label Apr 12, 2023
@rusackas rusackas reopened this Apr 12, 2023
@rusackas rusackas added the validation:required A committer should validate the issue label Apr 12, 2023
@michael-s-molina
Copy link
Member

It seems that to resolve this problem we need to add a control to the Heatmap chart so that users can select the appropriate time format similar to what other chart types do. This is an example from Bar chart:

Screenshot 2023-07-28 at 12 07 45

The problem is that Heatmap is a legacy chart so it would be more valuable if we did this fix when migrating it to ECharts to avoid duplicated work.

This problem with timestamp field on X axis seems to be back in 2.1.0, the same was working well with 2.0.1

I don't know how this was working before given that this control never existed in this chart? Did it assumed a specific format by default?

@sqja
Copy link

sqja commented Jul 29, 2023

I don't know how this was working before given that this control never existed in this chart? Did it assumed a specific format by default?

Indeed in this regards here is an example of a currently working Heatmap we use (superset 2.0.1, last working version) with same data and displaying properly formatted date on X. Visible also on the screenshot some settings currently applied to configure it

image

The problem is that Heatmap is a legacy chart so it would be more valuable if we did this fix when migrating it to ECharts to avoid duplicated work.

Is there currently any plan in your roadmap to migrate Heatmap to EChart ?

@michael-s-molina
Copy link
Member

Is there currently any plan in your roadmap to migrate Heatmap to EChart ?

Yes. We're planning to migrate more charts after 3.0. We already have some PRs in the works here an here. I added a card to our roadmap to ensure this chart gets prioritized given this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
#bug Bug report v2.1 validation:required A committer should validate the issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants