Allpaths built in filter

Hello,
Im trying to use your built in /allpaths endpoint with a filter on an attribute edge where the attribute is a DATETIME type.
When running the query through TigerStudio UI it seems that this specific attribute doesn’t appear .
How can i filter edges with DATETIME attribute in the /allpaths endpoint?
I tried the below filter but with no success

"{\"edgeFilters\":[{\"type\": \"some_edge_type\", \"condition\":\"(start_date < 2019-12-30)\"}]}"

The correct format of your condition is:

{"edgeFilters":["type": "some_edge_type", "condition": "(start_date < to_datetime(\"2019-12-30)\""}]}

(I removed the outermost double quotes to be able to eliminate the escaping of the double quotes to make the example easier to understand).
So:

  • You need to add t_datetime() for explicit data type conversion
  • You need to double quote the date/time literal (it’s effectively a string)
1 Like

Hi Szilard,
Thanks for the quick reply!
When trying this format:

"{\"edgeFilters\":[{\"type\": \"device_fraud\", \"condition\":\"(start_date < to_datetime(\"2019-12-30\"))\"}]}"

I’m getting this error:

Parse JSON jsonFilterStr fails, the given jsonFilterStr is: '{"edgeFilters":[{"type": "phone_fraud", "condition":"(start_date < to_datetime("2019-12-30"))"}]}'

What i’m doing wrong?

Note:
When i tried with this filter:
"{\"edgeFilters\":[{\"type\": \"device_fraud\", \"condition\":\"(start_date < bla)\"}]}"

I got the following error

error_: unexpected error Graph entity device_fraud does not have attribute bla.

meaning my issue is parsing the to_datetime(“2019-12-30”)

Thanks again

Since your whole JSON construct is within double quotes you need to escape the \ characters (within to_datetime()) too, like this:

"{\"edgeFilters\":[{\"type\": \"device_fraud\", \"condition\":\"(start_date < to_datetime(\\\"2019-12-30\\\"))\"}]}"

I am not sure why you need the outermost double quotes, but because you use it, you need to escape all inner, JSON-level double quotes; this you did. But because you have a pair of GSQL level double quotes within JSON double quotes (for the date/time string parameter of to_datetime()), you need to doubly escape those GSQL double quotes: once for JSON, and once for the outermost double quotes. So, \\\" will be parsed as \" in JSON and then will be parsed simply as " in GSQL.

Maybe \\" would be enough. Not sure how your language/tool works with character escaping.

Hi,
Thanks again for all your help.
I still have a parsing issue with the to_datetime() but i tried something similar and i got a different error.

This time i used the now() function - > it gives the same output as to_datetime (DATETIME).
The filter is:

"edgeFilters":[{"type":"some_type","condition":"start_date <'now()'"},{"type":"some_other_type","condition":"start_date < 'now()'"}]

And the error is:
{"version":{ "edition":"enterprise", "api":"v2", "schema":0},"error":true,"message":"error_: unexpected error task EdgeActionTask_178failed: boost::bad_get: failed value get using boost::get"}

Also,
When i run this
"edgeFilters":[{"type":"some_type"},{"type":"some_other_type"}]

i get the correct result, meaning the condition is not working correct (the start_date is always before now() hence the condition is true)

as for your question - Im using the curl tool just like the example in the documentation
https://docs.tigergraph.com/v/2.5/dev/restpp-api/built-in-endpoints#post-allpaths-graphname-all-paths-search

I really appreciate your help on this manner

Hi @Szilard_Barany,
Any ideas on how to overcome this issue?
Right now this behaviour prevent me from using this feature :slightly_frowning_face:

Thanks in advance,
Lior

Hi @liorazar,

First of all, you definitely need not enclose now() with single quotes. On the other hand, when I tried to replicate your issue, I got

unexpected error Graph entity e does not have attribute now.

so it might be that now() is not supported by this endpoint. I asked internally, I will get back to you when I got response.

Hi @Szilard_Barany,
Yes, i tried without the single quote also and faced with the same error so figured i maybe need to add it.

If now() is not supported by this endpoint, it directly means that to_datetime(‘some_date_string’) is also not supported?
And if they both are not supported, may there is a different way to add a filter of a datetime?

Looking forward to your response.
Thanks again,
Lior