# tests/cypher/corpus/library.jsonl, method get_document_stats
query: "\n            MATCH (d:Document {path: $path, latest: true}) \n            CALL { WITH d MATCH (d)-[:HAS_STRUCTURE|HAS_CHILD*1..]->(n:StructureNode)\n                    RETURN count(n) AS n_nodes }\n            CALL { WITH d MATCH (d)-[:HAS_STRUCTURE|HAS_CHILD*1..]->(:StructureNode)-[:HAS_INFO_UNIT]->(u:InfoUnit)\n                    RETURN count(u) AS n_units }\n            CALL { WITH d MATCH (d)-[:HAS_STRUCTURE|HAS_CHILD*1..]->(:StructureNode)-[:HAS_MODEL_DECISION]->(md:ModelDecision)\n                    RETURN count(md) AS n_dec,\n                           sum(CASE WHEN md.matched_model_class IS NOT NULL THEN 1 ELSE 0 END) AS n_matched,\n                           sum(CASE WHEN md.propose_new_model THEN 1 ELSE 0 END) AS n_proposed }\n            CALL { WITH d MATCH (d)-[:HAS_STRUCTURE|HAS_CHILD*1..]->(:StructureNode)-[:HAS_EXTRACTION]->(er:ExtractionResult)\n                    OPTIONAL MATCH (er)-[hr*1..12]->(mi:ModelInstance)\n                    WHERE all(x IN hr WHERE type(x) STARTS WITH 'HAS_')\n                    RETURN count(DISTINCT er) AS n_er, count(DISTINCT mi) AS n_mi }\n            RETURN d.version AS version, n_nodes, n_units, n_dec, n_matched, n_proposed, n_er, n_mi\n            "
---
Match optional=False
  Path var=None selector=None
    Node var=d labels=(Document) props={path: (Param path), latest: (Lit true)} where=None
  where=None
CallSubquery imports=(d)
  Match optional=False
    Path var=None selector=None
      Node var=d labels=* props={} where=None
      Quantified min=1 max=None
        Node var=__a0 labels=* props={} where=None
        Rel var=__r0 types=(HAS_STRUCTURE|HAS_CHILD) dir=out props={} where=None
        Node var=__a1 labels=* props={} where=None
      Node var=n labels=(StructureNode) props={} where=None
    where=None
  Return distinct=False order=() skip=None limit=None
    n_nodes = (Func count (Var n))
CallSubquery imports=(d)
  Match optional=False
    Path var=None selector=None
      Node var=d labels=* props={} where=None
      Quantified min=1 max=None
        Node var=__a2 labels=* props={} where=None
        Rel var=__r1 types=(HAS_STRUCTURE|HAS_CHILD) dir=out props={} where=None
        Node var=__a3 labels=* props={} where=None
      Node var=__a4 labels=(StructureNode) props={} where=None
      Rel var=__r2 types=(HAS_INFO_UNIT) dir=out props={} where=None
      Node var=u labels=(InfoUnit) props={} where=None
    where=None
  Return distinct=False order=() skip=None limit=None
    n_units = (Func count (Var u))
CallSubquery imports=(d)
  Match optional=False
    Path var=None selector=None
      Node var=d labels=* props={} where=None
      Quantified min=1 max=None
        Node var=__a5 labels=* props={} where=None
        Rel var=__r3 types=(HAS_STRUCTURE|HAS_CHILD) dir=out props={} where=None
        Node var=__a6 labels=* props={} where=None
      Node var=__a7 labels=(StructureNode) props={} where=None
      Rel var=__r4 types=(HAS_MODEL_DECISION) dir=out props={} where=None
      Node var=md labels=(ModelDecision) props={} where=None
    where=None
  Return distinct=False order=() skip=None limit=None
    n_dec = (Func count (Var md))
    n_matched = (Func sum (Case (WHEN (IS NOT NULL (Prop (Var md) matched_model_class)) (Lit 1)) else=(Lit 0)))
    n_proposed = (Func sum (Case (WHEN (Prop (Var md) propose_new_model) (Lit 1)) else=(Lit 0)))
CallSubquery imports=(d)
  Match optional=False
    Path var=None selector=None
      Node var=d labels=* props={} where=None
      Quantified min=1 max=None
        Node var=__a8 labels=* props={} where=None
        Rel var=__r5 types=(HAS_STRUCTURE|HAS_CHILD) dir=out props={} where=None
        Node var=__a9 labels=* props={} where=None
      Node var=__a10 labels=(StructureNode) props={} where=None
      Rel var=__r6 types=(HAS_EXTRACTION) dir=out props={} where=None
      Node var=er labels=(ExtractionResult) props={} where=None
    where=None
  Match optional=True
    Path var=None selector=None
      Node var=er labels=* props={} where=None
      Quantified min=1 max=12
        Node var=__a11 labels=* props={} where=None
        Rel var=hr types=* dir=out props={} where=None
        Node var=__a12 labels=* props={} where=None
      Node var=mi labels=(ModelInstance) props={} where=None
    where=(all x (Var hr) where=(STARTS WITH (Func type (Var x)) (Lit "HAS_")))
  Return distinct=False order=() skip=None limit=None
    n_er = (Func count DISTINCT (Var er))
    n_mi = (Func count DISTINCT (Var mi))
Return distinct=False order=() skip=None limit=None
  version = (Prop (Var d) version)
  n_nodes = (Var n_nodes)
  n_units = (Var n_units)
  n_dec = (Var n_dec)
  n_matched = (Var n_matched)
  n_proposed = (Var n_proposed)
  n_er = (Var n_er)
  n_mi = (Var n_mi)
