I need to query HTTP/JSON datasource with parameters like this:
/values?Name=Foobar&Start=2024-01-16&End=2024-01-17 (the previous and the current days)
so I create a Base view with relative URL like this:
/values?Name=Foobar&Start=@start&End=@end
and then I try to use functions for START and END variables, e.g:
START: FORMATDATE('yyyy-MM-dd', ADDDAY(now(), -1)) (Is this correct for yesturday??)
END: FORMATDATE('yyyy-MM-dd', now())
but denodo uses formulas as a plaintext:
Unable to obtain the data structure:
com.denodo.util.exceptions.InternalErrorException:
Error retrieving data from '.../values?Name=Foobar&End=FORMATDATE('yyyy-MM-dd',%20now())'.
HTTP error code: 404.
What is the correct way to do this?
This question was answered at Denodo Community website with Denodo team
Hi,
Generally the values in interpolation variables are passed as strings. If I need to pass dynamic values in the interpolation variables, I would follow the below steps:
I would create a new HTTP/JSON datasource named
ds_samplewith the base URL as mentioned below:<BASE_URL>/values?Start=@start&End=@endAfter saving the data source, I would create a base view,
bv_sampleover theds_samplesource.Then, I would create a new view named
dateswith two fieldsStartandEndwith the field expressionformatdate('yyyy-MM-dd', addday(now(), -1))forStartandformatdate('yyyy-MM-dd', now())forEndfields.I would create a Join view for the two base views
datesandbv_sampleand I would join the fieldsdates.start,dates.endandbv_sample.start,bv_sample.endrespectively.Finally, on executing the join view the results of the query matching the given conditions will be retrieved.
Hope this helps!
UPD
For beginners, the least obvious item may be the one about "create a new view named dates", I still don't know the correct way, too=) So you can create any type of View in the UI, open it's VQL editor and put this code there:
CREATE OR REPLACE VIEW dates FOLDER = '/general'
LAYOUT (bv_sample = [20, 20, 200, 205])
AS SELECT
formatdate('yyyy-MM-dd', addday(now(), -1)) AS "Yesterday",
formatdate('yyyy-MM-dd', addday(now(), -1)) AS "Start",
formatdate('yyyy-MM-dd', now()) AS "Today",
formatdate('yyyy-MM-dd', now()) AS "End"
CONTEXT ('formatted' = 'yes');