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

Time filtering - Not working on calculated fields #13702

Closed
2 of 3 tasks
ValentinC-BR opened this issue Mar 19, 2021 · 8 comments
Closed
2 of 3 tasks

Time filtering - Not working on calculated fields #13702

ValentinC-BR opened this issue Mar 19, 2021 · 8 comments
Assignees
Labels
#bug Bug report data:connect:athena Related to Athena data:connect:clickhouse Related to Clickhouse explore:time Related to the time filters in Explore

Comments

@ValentinC-BR
Copy link

When using a calculated column as the TIME COLUMN, the preset filters (actually all the filters in the time section) do not work.
The calculated field (date or datetime) is compared to a STRING, causing the SQL request not to work.

Expected results

The calculated column should be compared to a DATE or DATETIME value when the user applies a filter

Actual results

The calculated column is compared to a STRING value

Screenshots

TABLE CONFIGURATION

image

CHART CONFIGURATION

image

GENERATED QUERY

Capture d’écran 2021-03-19 à 08 33 19

How to reproduce the bug

  1. Create a calculated column, with a date or datetime format
  2. Select it as THE time column
  3. Chose any time filter (last month for instance)
  4. RUN query

Environment

(please complete the following information):

  • superset version: 1.0.1
  • python version: 3.7.9
  • node.js version: doesn't apply, I run on Kubernetes, using gunicorn as server
  • source : Athena

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 have reproduced the issue with at least the latest released version of superset.
  • I have checked the issue tracker for the same issue and I haven't found one similar.

Additional context

None

@ValentinC-BR ValentinC-BR added the #bug Bug report label Mar 19, 2021
@ValentinC-BR
Copy link
Author

I made a mistake while taking the screenshots (the ' character shouldn't be present). Sorry !

The error is present anyway, it is not related to it.

@zhaoyongjie
Copy link
Member

It seems that Athena is not implicitly converted from string to datetime-like. This problem may exist in Athena / Clickhouse / Kylin2.

@ValentinC-BR
could you try this SQL using SQLLab, and change the where clause to like this:

....
WHERE date_add('day', 10, subscription_date) >= cast('2021-02-19 00:00:00' as date)
AND  date_add('day', 10, subscription_date) < cast('2021-03-19 00:00:00' as date)
... 

Can it query?

@ValentinC-BR
Copy link
Author

I get the following error : Value cannot be cast to date: 2021-02-19 00:00:00

Casting it as TIMESTAMP work, however.

@zhaoyongjie
Copy link
Member

ok. thanks for this debug. We will improve the corresponding SQL generation logic.

@junlincc

@zhaoyongjie zhaoyongjie added data:connect:athena Related to Athena data:connect:clickhouse Related to Clickhouse explore:time Related to the time filters in Explore labels Mar 19, 2021
@junlincc
Copy link
Member

@ValentinC-BR feel free to push a fix if it's urgent. 🙏 thanks for reporting

@zhaoyongjie
Copy link
Member

closes by #14813

@john-bodley
Copy link
Member

john-bodley commented Oct 7, 2021

@ValentinC-BR regarding your issue I was wondering whether you tried setting the calculated column type—in the same modal where you defined the SQL expression? The reason I ask is I believe that is the correct mechanism for addressing your issue.

See #16950 for details.

@ValentinC-BR
Copy link
Author

Yes I did. But it wasn't working at that time.
Now it seems to work, however Superset still doesn't support some data types like "Timestamp with Timezone" (I think there's already an issue around this)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
#bug Bug report data:connect:athena Related to Athena data:connect:clickhouse Related to Clickhouse explore:time Related to the time filters in Explore
Projects
None yet
Development

No branches or pull requests

4 participants