1) query parameters cannot be used in the same way in syntax v2
This is valid in syntax v1 but gives an error in v2:
[CREATE QUERY HelloWorld2(string vType) FOR GRAPH Entellect syntax v2 { ]
CREATE QUERY HelloWorld2(string vType) FOR GRAPH Entellect {
ListAccum<string> @@test;
start = {vType.*}; // *v2 has an error here: undefined vertex type used as seed*
test = select n from start:s -(Any:e)- :n ;
}
2) some functions don’t work in v2
Assuming there is a vertex type of vtype and a particular vertex has a string property of name that is nullable the following works in syntax v1 but gives an error in syntax v2.
start = {vType.*};
test = select n from start:s -(Any:e)- :n
Accum @@test += coalesce(n.Name, "N/A"); // error no type can be inferred for coalesce(n.name, "N/A"
To your first point, when you use a STRING variable as the vertex set initializer, you do not need the period or star symbols afterward.
For instance, if Topic is a vertex type in my schema:
CREATE QUERY test() FOR GRAPH MyGraph {
start = {Topic.*};
print start;
}
// Gets all Topic vertices
should function the same as
CREATE QUERY test(STRING vType) FOR GRAPH MyGraph {
start = {vType};
print start;
}
// Now, call this query with argument "Topic"
// (note: query installation required, cannot interpret)
(This should work for both syntax v1 and v2)
Hi @Leo_Shestakov , regarding your point for SYNTAX V2, its working fine without .* and installing query but only print or basic functions like start.size() is working. when i use below code, it throws error , what I am doing wrong.
CREATE DISTRIBUTED QUERY z_dynamic_syntax_v2 (STRING vType) //parameterized schema
FOR GRAPH ABC SYNTAX V2
{
SumAccum @@Vertex_CNT = 0;
start = {vType}; //no error after removing period & star symbols.
print vType, start.size(); ///working fine as expected
result = select s from start:s where s.Status==“Active” ACCUM @@Vertex_CNT+=1;
// FROM keyword(highlighted in red) is showing warning as “unsatisfiable FROM pattern, query result always empty” & start(highlighted in yellow) shows error "unsatisfiable pattern start"
PRINT @@Vertex_CNT as Total_Number_of_records;
}
Hi Ankita,
Do all of your vertex types have an attribute called Status
? Since the vertex type input is dynamic, the traversal needs to be valid for all possible inputs. If not all of your vertices have a Status
attribute, then you can use an IF
or CASE
statement to ensure you’re only looking for Status
on vertices that have a Status
attribute.
@Dan_Barkus , Thanks for your response.
I have removed where clause for Status column but still I am getting same warning at START & FROM keywords. is that not supported in SYNTAX V2?
Can you share any sample query where its working, Its very basic query to store count in accumulator & print but not using size() function. we want to achieve it using “select” query.