UltipaDocs
Try Playground
  • Introduction
  • Terminologies
    • Graphset
    • Schema
    • Property
    • Constraints
    • Insert
    • Overwrite or Insert
    • Upsert
    • Update
    • Delete
    • Find Nodes
    • Find Edges
      • AB
      • Autonet
      • Spread
      • Path Template
      • K-Hop
      • K-Hop Template
    • GROUP BY
    • ORDER BY
    • SKIP
    • LIMIT
    • WHERE
    • RETURN
    • WITH
    • UNCOLLECT
    • UNION
    • UNION ALL
    • CALL
    • All Functions
    • Path Functions
    • Aggregate Functions
    • Mathematical Functions
    • Trigonometric Functions
    • String Functions
    • List Functions
    • Datetime Functions
    • Spatial Functions
    • Table Functions
    • Null Functions
    • Type Conversion Functions
  • Operators
  • Expressions
    • Index
    • Full-text Index
    • Vector Index
    • Cache
    • Overview
    • Managing HDC Graphs
    • HDC Graph Queries
    • Process
    • Job
    • Execution Plan
    • Alias
    • Filter
    • Values and Types
    • Data Flow in Queries
    • Comments
    • Reserved Words
  • Access Control
  1. Docs
  2. /
  3. UQL
  4. /
  5. Querying

UNCOLLECT

Overview

The UNCOLLECT statement transforms elements in a list into individual records.

Syntax

Syntax
UNCOLLECT <listExp> as <alias>

Details

  • The <listExp> is an expression that represents or produces data of the list type.
  • An <alias> is mandatory to represent the data uncollected.

Example Graph

To create the graph, execute each of the following UQL queries sequentially in an empty graphset:

UQL
create().edge_property(@default, "weight", int32)
insert().into(@default).nodes([{_id:"A"}, {_id:"B"}, {_id:"C"}, {_id:"D"}, {_id:"E"}, {_id:"F"}])
insert().into(@default).edges([{_from:"A", _to:"C", weight:1}, {_from:"E", _to:"B", weight:1}, {_from:"A", _to:"E", weight:4}, {_from:"D", _to:"C", weight:2}, {_from:"E", _to:"D", weight:3}, {_from:"B", _to:"A", weight:2}, {_from:"F", _to:"A", weight:4}])

Uncollecting a List

UQL
uncollect [1,1,2,3,null] as item
return item

Result:

item
1
1
2
3
null
UQL
uncollect [[1,2], [2,3,5]] as item
return item

Result:

item
[1,2]
[2,3,5]

Uncollecting Node/Edge Lists

The pnodes() or pedges() function collects nodes or edges in a path into a list.

UQL
n({_id == "A"}).e()[2].n({_id == "D"}) as p
call {
  with p
  uncollect pedges(p) as edges
  return sum(edges.weight) as totalWeights
}
return totalWeights

Result:

totalWeights
3
7