ingraph icon indicating copy to clipboard operation
ingraph copied to clipboard

Support "metaqueries"

Open szarnyasg opened this issue 8 years ago • 4 comments

We should definitely support labels() and type(). I am not sure about properties() and keys().

szarnyasg avatar Dec 31 '16 17:12 szarnyasg

Some thoughts:

  • type() returns a single string
  • labels() returns a collection of strings
  • properties() returns a map
  • keys() returns a collection of strings

Propagating these in the Rete network should be the responsibility of the inferencer classes, the most likely candidate being the ExtraAttributeInferencer. Where should we propagate these?

  • For type(), the GetEdgesOperator should add the type to the edge as an additional element (string) in the tuple.
  • For labels(), either the GetVerticesOperator or the respective endpoint (source/target) of the GetEdgesOperator should add the labels as an additional element (list of strings) in the tuple.
  • properties() and keys() work for both vertices and edges and should be provided by the respective nullary operator: the GetEdgesOperator for edges, and the GetVerticesOperator/GetEdgesOperator for vertices.

szarnyasg avatar Feb 25 '17 18:02 szarnyasg

Also, m:Message-style expressions could also be considered to be metaqueries as they are a special case of 'Message' IN labels(m)-style expressions.

szarnyasg avatar Feb 24 '18 21:02 szarnyasg

:NodeLabel-style expressions now work, except when there are joins (expands or plain Cartesian products), in which case the schema inferencer just crashes because it does not propagate the variable either way.

MATCH (message2:Message) //, (x:X)
RETURN message2:Comment AS isComment

szarnyasg avatar Sep 29 '18 18:09 szarnyasg

Related queries with the following exception:

java.lang.AssertionError: assertion failed: Some properties were not propagated to either side of the join-like operator at scala.Predef$.assert(Predef.scala:170) at ingraph.compiler.plantransformers.NPlanToFPlan$.transform(NPlanToFPlan.scala:94)

LDBC SNB / Interactive / complex / 2

MATCH (:Person {id:19791209300143})-[:KNOWS]-(friend:Person)<-[:HAS_CREATOR]-(message)
WHERE message.creationDate <= 20121128000000000 AND (message:Post OR message:Comment)
RETURN
  friend.id AS personId,
  friend.firstName AS personFirstName,
  friend.lastName AS personLastName,
  message.id AS postOrCommentId,
  CASE exists(message.content)
    WHEN true THEN message.content
    ELSE message.imageFile
  END AS postOrCommentContent,
  message.creationDate AS postOrCommentCreationDate
ORDER BY postOrCommentCreationDate DESC, toInteger(postOrCommentId) ASC
LIMIT 20

TCK "MatchAcceptance2": "Multiple anonymous nodes in a pattern"

MATCH (a)<--()<--(b)-->()-->(c)
WHERE a:A
RETURN c

TCK "OptionalMatchAcceptance": "Return null when no matches due to label predicate in WHERE"

MATCH (n:Single)
OPTIONAL MATCH (n)-[r]-(m)
WHERE m:NonExistent
RETURN r

marci543 avatar Oct 07 '18 17:10 marci543