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

Unable to access time_grain in custom SQL #17598

Closed
dipej-reddy opened this issue Nov 30, 2021 · 7 comments
Closed

Unable to access time_grain in custom SQL #17598

dipej-reddy opened this issue Nov 30, 2021 · 7 comments
Labels
#bug Bug report inactive Inactive for >= 30 days need:more-info Requires more information from author

Comments

@dipej-reddy
Copy link

A clear and concise description of what the bug is.

How to reproduce the bug

  1. Go to 'Create Chart'
  2. Click on 'METRICS' and select 'Custom SQL' tab

Expected results

Should be able to access time_grain value

Screenshots

image

@dipej-reddy dipej-reddy added the #bug Bug report label Nov 30, 2021
@dipej-reddy
Copy link
Author

dipej-reddy commented Nov 30, 2021

Also trying to use jinja template in custom sql:

SELECT TIME_FLOOR("__time", 'PT15M') AS "__timestamp", '{{ from_dttm }}' - '{{ to_dttm }}' AS "DURATION" FROM "druid"."tableAbc" WHERE "__time" >= '2021-11-29 00:00:00.000000' AND "__time" < '2021-11-30 00:00:00.000000' GROUP BY TIME_FLOOR("__time", 'PT15M') ORDER BY "DURATION" DESC LIMIT 50000;

image

But, the jinja expression is not getting evaluated

@villebro
Copy link
Member

villebro commented Dec 1, 2021

@dneelapareddy have you set the ENABLE_TEMPLATE_PROCESSING config flag to True? See the docs for more info: https://superset.apache.org/docs/installation/sql-templating

@dipej-reddy
Copy link
Author

@villebro I have enabled ENABLE_TEMPLATE_PROCESSING to True,
I am able to get the '{{ current_username() }}' from custom sql,

image

But Jinja template is unable to evaluate '{{ to_dttm }}' - '{{ from_dttm }}' AS Duration

image

I have even tried it in the SQL lab, but not working there too:
image

Is there anything else i need to enable to get this working?

@villebro
Copy link
Member

Which version are you on? I believe the template processor was until fairly recently only implemented in certain query controls, but should now be universally supported on the current master branch. See also this PR that added more temporal variables to the template processor context: #16680

@geido geido added the need:more-info Requires more information from author label Jan 25, 2022
@stale
Copy link

stale bot commented Apr 17, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

@stale stale bot added the inactive Inactive for >= 30 days label Apr 17, 2022
@rusackas
Copy link
Member

Closing due to lack of follow-up details after over a year. If this is still an issue, holler and we can re-open!

@rusackas rusackas closed this as not planned Won't fix, can't repro, duplicate, stale Jan 17, 2023
@villebro
Copy link
Member

FYI this should be fully resolved on master branch (I can dig out the PRs if needed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
#bug Bug report inactive Inactive for >= 30 days need:more-info Requires more information from author
Projects
None yet
Development

No branches or pull requests

4 participants