You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the BQL overview document, the "as" keyword should be able to be used to return a different name for variables. However, the keyword causes an error when running the program. The keyword only works when used with an aggregation.
When running this program:
# Create a graph.
CREATE GRAPH ?family;
# Insert some data into the graph.
INSERT DATA INTO ?family {
/u<joe> "parent_of"@[] /u<mary> .
/u<joe> "parent_of"@[] /u<peter> .
/u<peter> "parent_of"@[] /u<john> .
/u<peter> "parent_of"@[] /u<eve>
};
# Find all Joe's offspring names.
# Works fine without "as" keyword.
SELECT ?name
FROM ?family
WHERE {
/u<joe> "parent_of"@[] ?offspring ID ?name
};
# Find all Joe's offspring names.
# Fails with "as" keyword.
SELECT ?name as ?n
FROM ?family
WHERE {
/u<joe> "parent_of"@[] ?offspring ID ?name
};
# Count offspring.
# Works with "as" keyword.
SELECT ?parent_name, count(?name) as ?n
FROM ?family
WHERE {
?parent ID ?parent_name "parent_of"@[] ?offspring ID ?name
}
GROUP BY ?parent_name;
# Drop the graph.
DROP GRAPH ?family;
The output is:
Processing file bug.bql
Processing statement (1/6):
CREATE GRAPH ?family;
Result:
OK
Processing statement (2/6):
INSERT DATA INTO ?family { /u<joe> "parent_of"@[] /u<mary> . /u<joe> "parent_of"@[] /u<peter> . /u<peter> "parent_of"@[] /u<john> . /u<peter> "parent_of"@[] /u<eve> };
Result:
OK
Processing statement (3/6):
SELECT ?name FROM ?family WHERE { /u<joe> "parent_of"@[] ?offspring ID ?name };
Result:
?name
mary
peter
OK
Processing statement (4/6):
SELECT ?name as ?n FROM ?family WHERE { /u<joe> "parent_of"@[] ?offspring ID ?name };
[FAIL] [ERROR] Failed to execute BQL statement with error cannot project against unknow binding ?n; known bindinds are [?offspring ?name]
Processing statement (5/6):
SELECT ?parent_name, count(?name) as ?n FROM ?family WHERE { ?parent ID ?parent_name "parent_of"@[] ?offspring ID ?name } GROUP BY ?parent_name;
Result:
?parent_name ?n
joe "2"^^type:int64
peter "2"^^type:int64
OK
Processing statement (6/6):
DROP GRAPH ?family;
Result:
OK
The text was updated successfully, but these errors were encountered:
According to the BQL overview document, the "as" keyword should be able to be used to return a different name for variables. However, the keyword causes an error when running the program. The keyword only works when used with an aggregation.
When running this program:
The output is:
The text was updated successfully, but these errors were encountered: