Open
Description
Bug description
I am creating dataset for dynamic date range filter and dataset look like below query:
{% set time_filter = get_time_filter("bucket", default="Last week", remove_filter=True) %}
WITH calculated_data AS (
SELECT
(wspmcdd.bucket AT TIME ZONE 'AUSTRALIA/BRISBANE' + INTERVAL '1 day') AS "date",
wspmcdd.meter_id,
wspmcdd.meter_channel_id,
wspmcdd.maximum_value,
wspmcdd.minimum_value,
ROUND(
CASE
WHEN wspmcdd.channel_type = 'Interval' THEN wspmcdd.total_value::NUMERIC
WHEN wspmcdd.channel_type = 'Cumulative' THEN (wspmcdd.maximum_value - LAG(wspmcdd.maximum_value) OVER (
PARTITION BY wspmcdd.meter_id, wspmcdd.meter_channel_id
ORDER BY wspmcdd.bucket
))::NUMERIC
ELSE wspmcdd.total_value::NUMERIC
END, 3
) AS calculated_value,
wspmcdd.status,
wspmcdd.nem12_status,
wspmcdd.meter_type,
wspmcdd.channel_type,
wspmcdd.unit_of_measurement,
wspmcdd.meter_property_name,
wspmcdd.customer_name,
wspmcdd.site_name,
wspmcdd.physical_time_zone,
wspmcdd.channel_name,
wspmcdd.average_value,
wspmcdd.reading_count,
'{{ time_filter.time_range }}' AS time_range
FROM
west_Side_place_meter_channel_data_daily AS wspmcdd
JOIN
Dashboard_Meter_Type_Channel_Configuration AS dmtcc
ON lower(dmtcc.channel_name) = lower(wspmcdd.channel_name)
AND dmtcc.meter_type = wspmcdd.meter_type
AND lower(dmtcc.unit_of_measurement) = lower(wspmcdd.unit_of_measurement)
AND lower(dmtcc.channel_type) = lower(wspmcdd.channel_type)
WHERE wspmcdd.bucket >= ((TIMESTAMP {{ time_filter.from_expr }} + INTERVAL '-1 day') AT TIME ZONE 'AUSTRALIA/BRISBANE')
AND wspmcdd.bucket < ((TIMESTAMP {{ time_filter.to_expr }}) AT TIME ZONE 'AUSTRALIA/BRISBANE')
AND wspmcdd.meter_type = 'Electricity'
)
SELECT *
FROM
calculated_data
WHERE
"date" > ((TIMESTAMP {{ time_filter.to_expr }}))
ORDER BY
"date";
But i am getting error Error: Error while rendering virtual dataset query: 'get_time_filter' is undefined
.
Screenshots/recordings
No response
Superset version
4.1.1
Python version
3.11
Node version
16
Browser
Chrome
Additional context
No response
Checklist
- I have searched Superset docs and Slack and didn't find a solution to my problem.
- I have searched the GitHub issue tracker and didn't find a similar bug report.
- I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.