Skip to content

Overload project by list of nodes and edges#2611

Merged
colinbarry merged 6 commits intomasterfrom
feat/overload-project
Feb 13, 2025
Merged

Overload project by list of nodes and edges#2611
colinbarry merged 6 commits intomasterfrom
feat/overload-project

Conversation

@colinbarry
Copy link
Contributor

@colinbarry colinbarry commented Jan 15, 2025

project() is overloaded to project a subgraph from a list of nodes and
a list of edges. Any duplicates or nulls in these lists are ignored, as
are any edges whose From or To node is not in the node list.

The following two statements produce identical results:

MATCH p=(x:Person)-(r)-(y:Person)
RETURN project(p)
MATCH (x:Person)-(r)-(y:Person)
RETURN project([x, y], [r])

@colinbarry colinbarry changed the title tidy: Clarify comment Overload project by list of nodes and edges Jan 15, 2025
@colinbarry colinbarry self-assigned this Jan 15, 2025
@colinbarry colinbarry added bug bug Severity - S2 Severity - S2 customer customer labels Jan 15, 2025
@colinbarry colinbarry linked an issue Jan 15, 2025 that may be closed by this pull request
@colinbarry
Copy link
Contributor Author

colinbarry commented Jan 15, 2025

Tracking

  • [Link to Epic/Issue] #fixes 2606

Standard development

CI Testing Labels

  • Select the appropriate CI test labels (CI -build=build-name -test=test-suite)

Documentation checklist

  • Add the documentation label

  • Add the bug / feature label

  • Add the milestone for which this feature is intended

    • If not known, set for a later milestone
  • Write a release note, including added/changed clauses
    added: project() can now project a subgraph from lists of nodes and relationships, rather than just from paths. This relaxes the required format of query results needed to create subgraphs for further processing, or to pass to query modules. Users can build a subgraph from nodes and relationships which are computed separately, or come from different parts of your query, making queries cleaner, more performant, and easier to maintain. #2611

  • [ Documentation PR link memgraph/documentation#XXXX ]

  • [ Tag someone from docs team ] @katarinasupe

@colinbarry colinbarry added this to the mg-v3.1.0 milestone Jan 15, 2025
@colinbarry colinbarry force-pushed the feat/overload-project branch 6 times, most recently from 5839e55 to 5d269bb Compare January 23, 2025 13:04
@colinbarry colinbarry added the Docs needed Docs needed label Jan 23, 2025
@colinbarry colinbarry force-pushed the feat/overload-project branch 2 times, most recently from f8c7aac to 6f5763c Compare January 23, 2025 17:14
`project()` is overloaded to project a subgraph from a list of nodes and
a list of edges. Any duplicates or nulls in these lists are ignored, as
are any edges whose `From` or `To` node is not in the node list.

The following two statements produce identical results:

```cypher
MATCH p=(x:Person)-(r)-(y:Person)
RETURN project(p)
```

```cypher
MATCH (x:Person)-(r)-(y:Person)
RETURN project([x, y], [r])
```
(Bundled here because one of the use cases for `project()` involves
using `collect()`ed nodes and edges being appended.)
@colinbarry colinbarry force-pushed the feat/overload-project branch from bf48cc3 to 2c3f50d Compare January 24, 2025 17:25
@colinbarry colinbarry added CI -build=release -test=core Run release build and core tests on push CI -build=release -test=e2e Run release build and e2e tests on push labels Jan 27, 2025
@colinbarry colinbarry marked this pull request as ready for review January 27, 2025 10:58
@Ignition Ignition dismissed their stale review February 4, 2025 15:55

changes applied

- `Graph.Expand` behaviour is changed to throw an error when called with
  any edges whose incident nodes are missing from the projection.
- Updated gql_behave tests to check for failure when nodes are missing.
This reverts the public facing name of the `arg1` and `arg2` aggregation
parameters, instead referring to them as they were before, i.e.:
- `key`, `value` in the case of `map(,)`
- `value` otherwise

And for the new function:
- `nodes`, `relationships` in the case of `project(,)`
@sonarqubecloud
Copy link

@Ignition Ignition added this pull request to the merge queue Feb 13, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 13, 2025
@colinbarry colinbarry added this pull request to the merge queue Feb 13, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 13, 2025
@colinbarry colinbarry added this pull request to the merge queue Feb 13, 2025
Merged via the queue into master with commit b2d6263 Feb 13, 2025
15 checks passed
@colinbarry colinbarry deleted the feat/overload-project branch February 13, 2025 19:49
@gitbuda gitbuda added enhancement enhancement feature feature and removed bug bug labels Mar 11, 2025
as51340 pushed a commit that referenced this pull request Oct 24, 2025
`project()` is overloaded to project a subgraph from a list of nodes and
a list of edges. Any duplicates or nulls in these lists are ignored, as
are any edges whose `From` or `To` node is not in the node list.

The following two statements produce identical results:

```cypher
MATCH p=(x:Person)-(r)-(y:Person)
RETURN project(p)
```

```cypher
MATCH (x:Person)-(r)-(y:Person)
RETURN project([x, y], [r])
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI -build=release -test=core Run release build and core tests on push CI -build=release -test=e2e Run release build and e2e tests on push customer customer Docs needed Docs needed enhancement enhancement feature feature Severity - S2 Severity - S2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Overload project by list of nodes and edges

3 participants