Skip to content

mixing return of both groupby and value should not allowed #95

@khoale88

Description

@khoale88

The current implementation allows GroupBy of a value with the value itself

    def test_alias_with_order_by(self):
        host = nx.MultiDiGraph()
        host.add_node("a", name="Alice", age=25)
        host.add_node("b", name="Bob", age=30)
        host.add_node("c", name="Carol", age=20)
        host.add_edge("b", "a", __labels__={"paid"}, value=14)
        host.add_edge("a", "b", __labels__={"paid"}, value=9)
        host.add_edge("a", "b", __labels__={"paid"}, amount=96)
        host.add_edge("a", "b", __labels__={"paid"}, value=40)

        qry = """
        MATCH (n)-[r]->(m)
        RETURN n.name, AVG(r.value) AS average, m.name, r.value
        ORDER BY average ASC
        """
        res = GrandCypher(host).run(qry)
        assert res["n.name"] == ["Bob", "Alice"]
        assert res["m.name"] == ["Alice", "Bob"]
        assert res["r.value"] == [
            {(0, "paid"): 14},
            {(0, "paid"): 9, (1, "paid"): None, (2, "paid"): 40},
        ]
        assert res["average"] == [{"paid": 14.0}, {"paid": 16.333333333333332}]

I think this should not be allowed RETURN n.name, AVG(r.value) AS average, m.name, r.value. This should be achieved with another aggregation function called COLLECT

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions