-
Notifications
You must be signed in to change notification settings - Fork 47
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 use function calls in start_date and end_date #27
Comments
For anyone else following along, discussion is happening on the PR: #28 (comment) |
Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest; add a comment to notify the maintainers. |
Since this has been reopened, and there's not really much discussion on the PR (#28), copy-pasting my comment to save future people a click:
|
Description of the Issue
When defining
end_date='dateadd(day, -1, date_trunc("day", getdate()))'
to dynamically get "yeterday" on a metric, the compiled SQL (Snowflake) throws an error:This is due to the fact that #20 and release tag
0.1.5
is now wrapping allstart_date
andend_date
input in single-quoted strings.How to reproduce:
Execute
dbt run -s metric_test
which will complete succsfully. The error occurs when querying the table/view in the database:Error
Compiled SQL snipet
Proposed Solution
I want to define a metric that uses a mix of functions to calculate a date
'date_trunc("day", getdate()))'
, and plain date strings'2021-01-01'
. The macro should detect:start_date
contains a function call, then leave it un-quoted so the call will be executedstate_date
contains only a basic date string, wrap it in quotesstart_date
isn't definedDesired compile SQL snipet
PR to resolve
The text was updated successfully, but these errors were encountered: