| /* |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, |
| * software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| * KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations |
| * under the License. |
| */ |
| LOAD 'age'; |
| SET search_path TO ag_catalog; |
| SELECT create_graph('cypher_match'); |
| NOTICE: graph "cypher_match" has been created |
| create_graph |
| -------------- |
| |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$CREATE (:v)$$) AS (a agtype); |
| a |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$CREATE (:v {i: 0})$$) AS (a agtype); |
| a |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$CREATE (:v {i: 1})$$) AS (a agtype); |
| a |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$MATCH (n:v) RETURN n$$) AS (n agtype); |
| n |
| ----------------------------------------------------------------------- |
| {"id": 844424930131969, "label": "v", "properties": {}}::vertex |
| {"id": 844424930131970, "label": "v", "properties": {"i": 0}}::vertex |
| {"id": 844424930131971, "label": "v", "properties": {"i": 1}}::vertex |
| (3 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$MATCH (n:v) RETURN n.i$$) AS (i agtype); |
| i |
| --- |
| |
| 0 |
| 1 |
| (3 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (n:v) WHERE n.i > 0 |
| RETURN n.i |
| $$) AS (i agtype); |
| i |
| --- |
| 1 |
| (1 row) |
| |
| --Directed Paths |
| SELECT * FROM cypher('cypher_match', $$ |
| CREATE (:v1 {id:'initial'})-[:e1]->(:v1 {id:'middle'})-[:e1]->(:v1 {id:'end'}) |
| $$) AS (a agtype); |
| a |
| --- |
| (0 rows) |
| |
| --Undirected Path Tests |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH p=(:v1)-[:e1]-(:v1)-[:e1]-(:v1) RETURN p |
| $$) AS (a agtype); |
| a |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [{"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex, {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge, {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex, {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge, {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex]::path |
| [{"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex, {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge, {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex, {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge, {"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex]::path |
| (2 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH p=(a:v1)-[]-()-[]-() RETURN a |
| $$) AS (a agtype); |
| a |
| ---------------------------------------------------------------------------------- |
| {"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex |
| {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex |
| (2 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[]-()-[]-(a:v1) RETURN a |
| $$) AS (a agtype); |
| a |
| ---------------------------------------------------------------------------------- |
| {"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex |
| {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex |
| (2 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[]-(a:v1)-[]-() RETURN a |
| $$) AS (a agtype); |
| a |
| --------------------------------------------------------------------------------- |
| {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex |
| {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex |
| (2 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[b:e1]-()-[]-() RETURN b |
| $$) AS (a agtype); |
| a |
| --------------------------------------------------------------------------------------------------------------------------- |
| {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge |
| {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge |
| (2 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a:v1)-[]->(), ()-[]->(a) RETURN a |
| $$) AS (a agtype); |
| a |
| --------------------------------------------------------------------------------- |
| {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH p=()-[e]-() RETURN e |
| $$) AS (a agtype); |
| a |
| --------------------------------------------------------------------------------------------------------------------------- |
| {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge |
| {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge |
| {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge |
| {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge |
| (4 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (:v1)-[e]-() RETURN e |
| $$) AS (a agtype); |
| a |
| --------------------------------------------------------------------------------------------------------------------------- |
| {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge |
| {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge |
| {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge |
| {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge |
| (4 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (:v1)-[e]-(:v1) RETURN e |
| $$) AS (a agtype); |
| a |
| --------------------------------------------------------------------------------------------------------------------------- |
| {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge |
| {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge |
| {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge |
| {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge |
| (4 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[]-()-[e]-(:v1) RETURN e |
| $$) AS (a agtype); |
| a |
| --------------------------------------------------------------------------------------------------------------------------- |
| {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge |
| {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge |
| (2 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a)-[]-()-[]-(:v1) RETURN a |
| $$) AS (a agtype); |
| a |
| ---------------------------------------------------------------------------------- |
| {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex |
| {"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex |
| (2 rows) |
| |
| -- Right Path Test |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a:v1)-[:e1]->(b:v1)-[:e1]->(c:v1) RETURN a, b, c |
| $$) AS (a agtype, b agtype, c agtype); |
| a | b | c |
| ----------------------------------------------------------------------------------+---------------------------------------------------------------------------------+------------------------------------------------------------------------------ |
| {"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex | {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex | {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH p=(a:v1)-[]-()-[]->() RETURN a |
| $$) AS (a agtype); |
| a |
| ---------------------------------------------------------------------------------- |
| {"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH p=(a:v1)-[]->()-[]-() RETURN a |
| $$) AS (a agtype); |
| a |
| ---------------------------------------------------------------------------------- |
| {"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[]-()-[]->(a:v1) RETURN a |
| $$) AS (a agtype); |
| a |
| ------------------------------------------------------------------------------ |
| {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[]-(a:v1)-[]->() RETURN a |
| $$) AS (a agtype); |
| a |
| --------------------------------------------------------------------------------- |
| {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[b:e1]-()-[]->() RETURN b |
| $$) AS (a agtype); |
| a |
| --------------------------------------------------------------------------------------------------------------------------- |
| {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (:v1)-[e]->() RETURN e |
| $$) AS (a agtype); |
| a |
| --------------------------------------------------------------------------------------------------------------------------- |
| {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge |
| {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge |
| (2 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[e]->(:v1) RETURN e |
| $$) AS (a agtype); |
| a |
| --------------------------------------------------------------------------------------------------------------------------- |
| {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge |
| {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge |
| (2 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (:v1)-[e]->(:v1) RETURN e |
| $$) AS (a agtype); |
| a |
| --------------------------------------------------------------------------------------------------------------------------- |
| {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge |
| {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge |
| (2 rows) |
| |
| --Left Path Test |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a:v1)<-[:e1]-(b:v1)<-[:e1]-(c:v1) RETURN a, b, c |
| $$) AS (a agtype, b agtype, c agtype); |
| a | b | c |
| ------------------------------------------------------------------------------+---------------------------------------------------------------------------------+---------------------------------------------------------------------------------- |
| {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex | {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex | {"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH p=(a:v1)<-[]-()-[]-() RETURN a |
| $$) AS (a agtype); |
| a |
| ------------------------------------------------------------------------------ |
| {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH p=(a:v1)-[]-()<-[]-() RETURN a |
| $$) AS (a agtype); |
| a |
| ------------------------------------------------------------------------------ |
| {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()<-[]-()-[]-(a:v1) RETURN a |
| $$) AS (a agtype); |
| a |
| ---------------------------------------------------------------------------------- |
| {"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()<-[]-(a:v1)-[]-() RETURN a |
| $$) AS (a agtype); |
| a |
| --------------------------------------------------------------------------------- |
| {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()<-[b:e1]-()-[]-() RETURN b |
| $$) AS (a agtype); |
| a |
| --------------------------------------------------------------------------------------------------------------------------- |
| {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (:v1)<-[e]-(:v1) RETURN e |
| $$) AS (a agtype); |
| a |
| --------------------------------------------------------------------------------------------------------------------------- |
| {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge |
| {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge |
| (2 rows) |
| |
| --Divergent Path Tests |
| SELECT * FROM cypher('cypher_match', $$ |
| CREATE (:v2 {id:'initial'})<-[:e2]-(:v2 {id:'middle'})-[:e2]->(:v2 {id:'end'}) |
| $$) AS (a agtype); |
| a |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()<-[]-(n:v2)-[]->() |
| MATCH p=()-[]->(n) |
| RETURN p |
| $$) AS (i agtype); |
| i |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()<-[]-(n:v2)-[]->() |
| MATCH p=(n)-[]->() |
| RETURN p |
| $$) AS (i agtype); |
| i |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [{"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex, {"id": 1970324836974594, "label": "e2", "end_id": 1688849860263937, "start_id": 1688849860263938, "properties": {}}::edge, {"id": 1688849860263937, "label": "v2", "properties": {"id": "initial"}}::vertex]::path |
| [{"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex, {"id": 1970324836974593, "label": "e2", "end_id": 1688849860263939, "start_id": 1688849860263938, "properties": {}}::edge, {"id": 1688849860263939, "label": "v2", "properties": {"id": "end"}}::vertex]::path |
| [{"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex, {"id": 1970324836974594, "label": "e2", "end_id": 1688849860263937, "start_id": 1688849860263938, "properties": {}}::edge, {"id": 1688849860263937, "label": "v2", "properties": {"id": "initial"}}::vertex]::path |
| [{"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex, {"id": 1970324836974593, "label": "e2", "end_id": 1688849860263939, "start_id": 1688849860263938, "properties": {}}::edge, {"id": 1688849860263939, "label": "v2", "properties": {"id": "end"}}::vertex]::path |
| (4 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[]-(n:v2) |
| RETURN n |
| $$) AS (i agtype); |
| i |
| ---------------------------------------------------------------------------------- |
| {"id": 1688849860263939, "label": "v2", "properties": {"id": "end"}}::vertex |
| {"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex |
| {"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex |
| {"id": 1688849860263937, "label": "v2", "properties": {"id": "initial"}}::vertex |
| (4 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (:v2)<-[]-(:v2)-[]->(:v2) |
| MATCH p=()-[]->() |
| RETURN p |
| $$) AS (i agtype); |
| i |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [{"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex, {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge, {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex]::path |
| [{"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex, {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge, {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex]::path |
| [{"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex, {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge, {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex]::path |
| [{"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex, {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge, {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex]::path |
| [{"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex, {"id": 1970324836974594, "label": "e2", "end_id": 1688849860263937, "start_id": 1688849860263938, "properties": {}}::edge, {"id": 1688849860263937, "label": "v2", "properties": {"id": "initial"}}::vertex]::path |
| [{"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex, {"id": 1970324836974594, "label": "e2", "end_id": 1688849860263937, "start_id": 1688849860263938, "properties": {}}::edge, {"id": 1688849860263937, "label": "v2", "properties": {"id": "initial"}}::vertex]::path |
| [{"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex, {"id": 1970324836974593, "label": "e2", "end_id": 1688849860263939, "start_id": 1688849860263938, "properties": {}}::edge, {"id": 1688849860263939, "label": "v2", "properties": {"id": "end"}}::vertex]::path |
| [{"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex, {"id": 1970324836974593, "label": "e2", "end_id": 1688849860263939, "start_id": 1688849860263938, "properties": {}}::edge, {"id": 1688849860263939, "label": "v2", "properties": {"id": "end"}}::vertex]::path |
| (8 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()<-[]-(:v2)-[]->() |
| MATCH p=()-[]->() |
| RETURN p |
| $$) AS (i agtype); |
| i |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [{"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex, {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge, {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex]::path |
| [{"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex, {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge, {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex]::path |
| [{"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex, {"id": 1970324836974594, "label": "e2", "end_id": 1688849860263937, "start_id": 1688849860263938, "properties": {}}::edge, {"id": 1688849860263937, "label": "v2", "properties": {"id": "initial"}}::vertex]::path |
| [{"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex, {"id": 1970324836974593, "label": "e2", "end_id": 1688849860263939, "start_id": 1688849860263938, "properties": {}}::edge, {"id": 1688849860263939, "label": "v2", "properties": {"id": "end"}}::vertex]::path |
| [{"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex, {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge, {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex]::path |
| [{"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex, {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge, {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex]::path |
| [{"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex, {"id": 1970324836974594, "label": "e2", "end_id": 1688849860263937, "start_id": 1688849860263938, "properties": {}}::edge, {"id": 1688849860263937, "label": "v2", "properties": {"id": "initial"}}::vertex]::path |
| [{"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex, {"id": 1970324836974593, "label": "e2", "end_id": 1688849860263939, "start_id": 1688849860263938, "properties": {}}::edge, {"id": 1688849860263939, "label": "v2", "properties": {"id": "end"}}::vertex]::path |
| (8 rows) |
| |
| --Convergent Path Tests |
| SELECT * FROM cypher('cypher_match', $$ |
| CREATE (:v3 {id:'initial'})-[:e3]->(:v3 {id:'middle'})<-[:e3]-(:v3 {id:'end'}) |
| $$) AS (a agtype); |
| a |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[b:e1]->() |
| RETURN b |
| $$) AS (i agtype); |
| i |
| --------------------------------------------------------------------------------------------------------------------------- |
| {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge |
| {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge |
| (2 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (:v3)-[b:e3]->() |
| RETURN b |
| $$) AS (i agtype); |
| i |
| --------------------------------------------------------------------------------------------------------------------------- |
| {"id": 2533274790395906, "label": "e3", "end_id": 2251799813685250, "start_id": 2251799813685249, "properties": {}}::edge |
| {"id": 2533274790395905, "label": "e3", "end_id": 2251799813685250, "start_id": 2251799813685251, "properties": {}}::edge |
| (2 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[]->(n:v1)<-[]-() |
| MATCH p=(n)<-[]-() |
| RETURN p |
| $$) AS (i agtype); |
| i |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[]->(n:v1)<-[]-() |
| MATCH p=()-[]->(n) |
| RETURN p |
| $$) AS (i agtype); |
| i |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[]->(n:v1)<-[]-() |
| MATCH p=(n)-[]->() |
| RETURN p |
| $$) AS (i agtype); |
| i |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH con_path=(a)-[]->()<-[]-() |
| where a.id = 'initial' |
| RETURN con_path |
| $$) AS (con_path agtype); |
| con_path |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [{"id": 2251799813685249, "label": "v3", "properties": {"id": "initial"}}::vertex, {"id": 2533274790395906, "label": "e3", "end_id": 2251799813685250, "start_id": 2251799813685249, "properties": {}}::edge, {"id": 2251799813685250, "label": "v3", "properties": {"id": "middle"}}::vertex, {"id": 2533274790395905, "label": "e3", "end_id": 2251799813685250, "start_id": 2251799813685251, "properties": {}}::edge, {"id": 2251799813685251, "label": "v3", "properties": {"id": "end"}}::vertex]::path |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH div_path=(b)<-[]-()-[]->() |
| where b.id = 'initial' |
| RETURN div_path |
| $$) AS (div_path agtype); |
| div_path |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [{"id": 1688849860263937, "label": "v2", "properties": {"id": "initial"}}::vertex, {"id": 1970324836974594, "label": "e2", "end_id": 1688849860263937, "start_id": 1688849860263938, "properties": {}}::edge, {"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex, {"id": 1970324836974593, "label": "e2", "end_id": 1688849860263939, "start_id": 1688849860263938, "properties": {}}::edge, {"id": 1688849860263939, "label": "v2", "properties": {"id": "end"}}::vertex]::path |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a)-[]->(:v3)<-[]-(b) |
| where a.id = 'initial' |
| RETURN b |
| $$) AS (con_path agtype); |
| con_path |
| ------------------------------------------------------------------------------ |
| {"id": 2251799813685251, "label": "v3", "properties": {"id": "end"}}::vertex |
| (1 row) |
| |
| --Patterns |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a:v1), p=(a)-[]-()-[]-() |
| where a.id = 'initial' |
| RETURN p |
| $$) AS (p agtype); |
| p |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [{"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex, {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge, {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex, {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge, {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex]::path |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH con_path=(a)-[]->()<-[]-(), div_path=(b)<-[]-()-[]->() |
| where a.id = 'initial' |
| and b.id = 'initial' |
| RETURN con_path, div_path |
| $$) AS (con_path agtype, div_path agtype); |
| con_path | div_path |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [{"id": 2251799813685249, "label": "v3", "properties": {"id": "initial"}}::vertex, {"id": 2533274790395906, "label": "e3", "end_id": 2251799813685250, "start_id": 2251799813685249, "properties": {}}::edge, {"id": 2251799813685250, "label": "v3", "properties": {"id": "middle"}}::vertex, {"id": 2533274790395905, "label": "e3", "end_id": 2251799813685250, "start_id": 2251799813685251, "properties": {}}::edge, {"id": 2251799813685251, "label": "v3", "properties": {"id": "end"}}::vertex]::path | [{"id": 1688849860263937, "label": "v2", "properties": {"id": "initial"}}::vertex, {"id": 1970324836974594, "label": "e2", "end_id": 1688849860263937, "start_id": 1688849860263938, "properties": {}}::edge, {"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex, {"id": 1970324836974593, "label": "e2", "end_id": 1688849860263939, "start_id": 1688849860263938, "properties": {}}::edge, {"id": 1688849860263939, "label": "v2", "properties": {"id": "end"}}::vertex]::path |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a:v), p=()-[]->()-[]->() |
| RETURN a.i, p |
| $$) AS (i agtype, p agtype); |
| i | p |
| ---+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| | [{"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex, {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge, {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex, {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge, {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex]::path |
| 0 | [{"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex, {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge, {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex, {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge, {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex]::path |
| 1 | [{"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex, {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge, {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex, {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge, {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex]::path |
| (3 rows) |
| |
| --Multiple Match Clauses |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a:v1) |
| where a.id = 'initial' |
| MATCH p=(a)-[]-()-[]-() |
| RETURN p |
| $$) AS (p agtype); |
| p |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [{"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex, {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge, {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex, {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge, {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex]::path |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a:v) |
| MATCH p=()-[]->()-[]->() |
| RETURN a.i, p |
| $$) AS (i agtype, p agtype); |
| i | p |
| ---+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| | [{"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex, {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge, {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex, {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge, {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex]::path |
| 0 | [{"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex, {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge, {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex, {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge, {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex]::path |
| 1 | [{"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex, {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge, {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex, {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge, {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex]::path |
| (3 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a:v) |
| MATCH (b:v1)-[]-(c) |
| RETURN a.i, b.id, c.id |
| $$) AS (i agtype, b agtype, c agtype); |
| i | b | c |
| ---+-----------+----------- |
| | "end" | "middle" |
| 0 | "end" | "middle" |
| 1 | "end" | "middle" |
| | "middle" | "end" |
| 0 | "middle" | "end" |
| 1 | "middle" | "end" |
| | "middle" | "initial" |
| 0 | "middle" | "initial" |
| 1 | "middle" | "initial" |
| | "initial" | "middle" |
| 0 | "initial" | "middle" |
| 1 | "initial" | "middle" |
| (12 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a:v) |
| MATCH (:v1)-[]-(c) |
| RETURN a.i, c.id |
| $$) AS (i agtype, c agtype); |
| i | c |
| ---+----------- |
| | "middle" |
| 0 | "middle" |
| 1 | "middle" |
| | "end" |
| 0 | "end" |
| 1 | "end" |
| | "initial" |
| 0 | "initial" |
| 1 | "initial" |
| | "middle" |
| 0 | "middle" |
| 1 | "middle" |
| (12 rows) |
| |
| -- |
| -- Property constraints |
| -- |
| SELECT * FROM cypher('cypher_match', |
| $$CREATE ({string_key: "test", int_key: 1, float_key: 3.14, map_key: {key: "value"}, list_key: [1, 2, 3]}) $$) |
| AS (p agtype); |
| p |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', |
| $$CREATE ({lst: [1, NULL, 3.14, "string", {key: "value"}, []]}) $$) |
| AS (p agtype); |
| p |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', |
| $$MATCH (n {string_key: NULL}) RETURN n $$) |
| AS (n agtype); |
| n |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', |
| $$MATCH (n {string_key: "wrong value"}) RETURN n $$) |
| AS (n agtype); |
| n |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (n {string_key: "test", int_key: 1, float_key: 3.14, map_key: {key: "value"}, list_key: [1, 2, 3]}) |
| RETURN n $$) |
| AS (p agtype); |
| p |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| {"id": 281474976710657, "label": "", "properties": {"int_key": 1, "map_key": {"key": "value"}, "list_key": [1, 2, 3], "float_key": 3.14, "string_key": "test"}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', |
| $$MATCH (n {string_key: "test"}) RETURN n $$) |
| AS (p agtype); |
| p |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| {"id": 281474976710657, "label": "", "properties": {"int_key": 1, "map_key": {"key": "value"}, "list_key": [1, 2, 3], "float_key": 3.14, "string_key": "test"}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', |
| $$MATCH (n {lst: [1, NULL, 3.14, "string", {key: "value"}, []]}) RETURN n $$) |
| AS (p agtype); |
| p |
| ---------------------------------------------------------------------------------------------------------------------- |
| {"id": 281474976710658, "label": "", "properties": {"lst": [1, null, 3.14, "string", {"key": "value"}, []]}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', |
| $$MATCH (n {lst: [1, NULL, 3.14, "string", {key: "value"}, [], "extra value"]}) RETURN n $$) |
| AS (p agtype); |
| p |
| --- |
| (0 rows) |
| |
| -- |
| -- Prepared Statement Property Constraint |
| -- |
| PREPARE property_ps(agtype) AS SELECT * FROM cypher('cypher_match', |
| $$MATCH (n $props) RETURN n $$, $1) |
| AS (p agtype); |
| EXECUTE property_ps(agtype_build_map('props', |
| agtype_build_map('string_key', 'test'))); |
| p |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| {"id": 281474976710657, "label": "", "properties": {"int_key": 1, "map_key": {"key": "value"}, "list_key": [1, 2, 3], "float_key": 3.14, "string_key": "test"}}::vertex |
| (1 row) |
| |
| -- need a following RETURN clause (should fail) |
| SELECT * FROM cypher('cypher_match', $$MATCH (n:v)$$) AS (a agtype); |
| ERROR: syntax error at end of input |
| LINE 1: SELECT * FROM cypher('cypher_match', $$MATCH (n:v)$$) AS (a ... |
| ^ |
| --invalid variable reuse, these should fail |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a)-[]-()-[]-(a:v1) RETURN a |
| $$) AS (a agtype); |
| ERROR: multiple labels for variable 'a' are not supported |
| LINE 2: MATCH (a)-[]-()-[]-(a:v1) RETURN a |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a)-[]-(a:v2)-[]-(a) RETURN a |
| $$) AS (a agtype); |
| ERROR: multiple labels for variable 'a' are not supported |
| LINE 2: MATCH (a)-[]-(a:v2)-[]-(a) RETURN a |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a)-[]-(a:v1) RETURN a |
| $$) AS (a agtype); |
| ERROR: multiple labels for variable 'a' are not supported |
| LINE 2: MATCH (a)-[]-(a:v1) RETURN a |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a)-[]-(a)-[]-(a:v1) RETURN a |
| $$) AS (a agtype); |
| ERROR: multiple labels for variable 'a' are not supported |
| LINE 2: MATCH (a)-[]-(a)-[]-(a:v1) RETURN a |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a)-[]-(a)-[]-(a:invalid_label) RETURN a |
| $$) AS (a agtype); |
| ERROR: multiple labels for variable 'a' are not supported |
| LINE 2: MATCH (a)-[]-(a)-[]-(a:invalid_label) RETURN a |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a) MATCH (a:v1) RETURN a |
| $$) AS (a agtype); |
| ERROR: multiple labels for variable 'a' are not supported |
| LINE 2: MATCH (a) MATCH (a:v1) RETURN a |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a) MATCH (a:invalid_label) RETURN a |
| $$) AS (a agtype); |
| ERROR: multiple labels for variable 'a' are not supported |
| LINE 2: MATCH (a) MATCH (a:invalid_label) RETURN a |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a:v1)-[]-()-[a]-() RETURN a |
| $$) AS (a agtype); |
| ERROR: variable 'a' is for a vertex |
| LINE 2: MATCH (a:v1)-[]-()-[a]-() RETURN a |
| ^ |
| -- valid variable reuse for edge labels across clauses |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[r0]->() MATCH ()-[r0]->() RETURN r0 |
| $$) AS (r0 agtype); |
| r0 |
| --------------------------------------------------------------------------------------------------------------------------- |
| {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge |
| {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge |
| {"id": 1970324836974594, "label": "e2", "end_id": 1688849860263937, "start_id": 1688849860263938, "properties": {}}::edge |
| {"id": 1970324836974593, "label": "e2", "end_id": 1688849860263939, "start_id": 1688849860263938, "properties": {}}::edge |
| {"id": 2533274790395906, "label": "e3", "end_id": 2251799813685250, "start_id": 2251799813685249, "properties": {}}::edge |
| {"id": 2533274790395905, "label": "e3", "end_id": 2251799813685250, "start_id": 2251799813685251, "properties": {}}::edge |
| (6 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[r0:e1]->() MATCH ()-[r0:e1]->() RETURN r0 |
| $$) AS (r0 agtype); |
| r0 |
| --------------------------------------------------------------------------------------------------------------------------- |
| {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge |
| {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge |
| (2 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[r0:e2]->() MATCH ()-[r0:e2]->() RETURN r0 |
| $$) AS (r0 agtype); |
| r0 |
| --------------------------------------------------------------------------------------------------------------------------- |
| {"id": 1970324836974594, "label": "e2", "end_id": 1688849860263937, "start_id": 1688849860263938, "properties": {}}::edge |
| {"id": 1970324836974593, "label": "e2", "end_id": 1688849860263939, "start_id": 1688849860263938, "properties": {}}::edge |
| (2 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[r0:e1]->()-[r1]->() RETURN r0,r1 |
| $$) AS (r0 agtype, r1 agtype); |
| r0 | r1 |
| ---------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------- |
| {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge | {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH p0=()-[:e1]->() MATCH p1=()-[:e2]->() RETURN p1 |
| $$) AS (p1 agtype); |
| p1 |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [{"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex, {"id": 1970324836974594, "label": "e2", "end_id": 1688849860263937, "start_id": 1688849860263938, "properties": {}}::edge, {"id": 1688849860263937, "label": "v2", "properties": {"id": "initial"}}::vertex]::path |
| [{"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex, {"id": 1970324836974594, "label": "e2", "end_id": 1688849860263937, "start_id": 1688849860263938, "properties": {}}::edge, {"id": 1688849860263937, "label": "v2", "properties": {"id": "initial"}}::vertex]::path |
| [{"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex, {"id": 1970324836974593, "label": "e2", "end_id": 1688849860263939, "start_id": 1688849860263938, "properties": {}}::edge, {"id": 1688849860263939, "label": "v2", "properties": {"id": "end"}}::vertex]::path |
| [{"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex, {"id": 1970324836974593, "label": "e2", "end_id": 1688849860263939, "start_id": 1688849860263938, "properties": {}}::edge, {"id": 1688849860263939, "label": "v2", "properties": {"id": "end"}}::vertex]::path |
| (4 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[r0:e1]->()-[r1]->() MATCH ()-[r0:e1]->()-[r1]->() RETURN r0,r1 |
| $$) AS (r0 agtype, r1 agtype); |
| r0 | r1 |
| ---------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------- |
| {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge | {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[]->() MATCH ()-[r1:e2]->() RETURN r1 |
| $$) AS (r1 agtype); |
| r1 |
| --------------------------------------------------------------------------------------------------------------------------- |
| {"id": 1970324836974594, "label": "e2", "end_id": 1688849860263937, "start_id": 1688849860263938, "properties": {}}::edge |
| {"id": 1970324836974593, "label": "e2", "end_id": 1688849860263939, "start_id": 1688849860263938, "properties": {}}::edge |
| {"id": 1970324836974594, "label": "e2", "end_id": 1688849860263937, "start_id": 1688849860263938, "properties": {}}::edge |
| {"id": 1970324836974593, "label": "e2", "end_id": 1688849860263939, "start_id": 1688849860263938, "properties": {}}::edge |
| {"id": 1970324836974594, "label": "e2", "end_id": 1688849860263937, "start_id": 1688849860263938, "properties": {}}::edge |
| {"id": 1970324836974593, "label": "e2", "end_id": 1688849860263939, "start_id": 1688849860263938, "properties": {}}::edge |
| {"id": 1970324836974594, "label": "e2", "end_id": 1688849860263937, "start_id": 1688849860263938, "properties": {}}::edge |
| {"id": 1970324836974593, "label": "e2", "end_id": 1688849860263939, "start_id": 1688849860263938, "properties": {}}::edge |
| {"id": 1970324836974594, "label": "e2", "end_id": 1688849860263937, "start_id": 1688849860263938, "properties": {}}::edge |
| {"id": 1970324836974594, "label": "e2", "end_id": 1688849860263937, "start_id": 1688849860263938, "properties": {}}::edge |
| {"id": 1970324836974593, "label": "e2", "end_id": 1688849860263939, "start_id": 1688849860263938, "properties": {}}::edge |
| {"id": 1970324836974593, "label": "e2", "end_id": 1688849860263939, "start_id": 1688849860263938, "properties": {}}::edge |
| (12 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[r0:e1]->() MATCH ()-[r1:e2]->() RETURN r0,r1 |
| $$) AS (r0 agtype, r1 agtype); |
| r0 | r1 |
| ---------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------- |
| {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge | {"id": 1970324836974594, "label": "e2", "end_id": 1688849860263937, "start_id": 1688849860263938, "properties": {}}::edge |
| {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge | {"id": 1970324836974593, "label": "e2", "end_id": 1688849860263939, "start_id": 1688849860263938, "properties": {}}::edge |
| {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge | {"id": 1970324836974594, "label": "e2", "end_id": 1688849860263937, "start_id": 1688849860263938, "properties": {}}::edge |
| {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge | {"id": 1970324836974593, "label": "e2", "end_id": 1688849860263939, "start_id": 1688849860263938, "properties": {}}::edge |
| (4 rows) |
| |
| -- valid variable reuse for vertex labels across clauses |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (r1:invalid), (r1:invalid) return r1 |
| $$) AS (r1 agtype); |
| r1 |
| ---- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (r1), (r1) return r1 |
| $$) AS (r1 agtype); |
| r1 |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| {"id": 281474976710657, "label": "", "properties": {"int_key": 1, "map_key": {"key": "value"}, "list_key": [1, 2, 3], "float_key": 3.14, "string_key": "test"}}::vertex |
| {"id": 281474976710658, "label": "", "properties": {"lst": [1, null, 3.14, "string", {"key": "value"}, []]}}::vertex |
| {"id": 844424930131969, "label": "v", "properties": {}}::vertex |
| {"id": 844424930131970, "label": "v", "properties": {"i": 0}}::vertex |
| {"id": 844424930131971, "label": "v", "properties": {"i": 1}}::vertex |
| {"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex |
| {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex |
| {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex |
| {"id": 1688849860263937, "label": "v2", "properties": {"id": "initial"}}::vertex |
| {"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex |
| {"id": 1688849860263939, "label": "v2", "properties": {"id": "end"}}::vertex |
| {"id": 2251799813685249, "label": "v3", "properties": {"id": "initial"}}::vertex |
| {"id": 2251799813685250, "label": "v3", "properties": {"id": "middle"}}::vertex |
| {"id": 2251799813685251, "label": "v3", "properties": {"id": "end"}}::vertex |
| (14 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (r1:invalid), (r1) return r1 |
| $$) AS (r1 agtype); |
| r1 |
| ---- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (r1:invalid), (r1), (r1), (r1:invalid) return r1 |
| $$) AS (r1 agtype); |
| r1 |
| ---- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (r1:invalid)-[]->(r1)-[]->(r1:invalid)-[]->(r1) return r1 |
| $$) AS (r1 agtype); |
| r1 |
| ---- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (r1:invalid)-[]->()-[]->()-[]->(r1:invalid) return r1 |
| $$) AS (r1 agtype); |
| r1 |
| ---- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[r0:e1]->()-[r1]->() MATCH ()-[r0:e1]->()-[r0]->() RETURN r0 |
| $$) AS (r0 agtype); |
| r0 |
| ---- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[r0:e1]->() MATCH ()-[r0]->() RETURN r0 |
| $$) AS (r0 agtype); |
| r0 |
| --------------------------------------------------------------------------------------------------------------------------- |
| {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge |
| {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge |
| (2 rows) |
| |
| -- invalid variable reuse for vertex |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (r1:invalid)-[]->(r1)-[]->(r1)-[]->(r1:invalids) return r1 |
| $$) AS (r1 agtype); |
| ERROR: multiple labels for variable 'r1' are not supported |
| LINE 2: ... MATCH (r1:invalid)-[]->(r1)-[]->(r1)-[]->(r1:invalid... |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (r1:invalid)-[]->(r1)-[]->(r1)-[]->(r1)-[r1]->() return r1 |
| $$) AS (r1 agtype); |
| ERROR: variable 'r1' is for a vertex |
| LINE 2: ... MATCH (r1:invalid)-[]->(r1)-[]->(r1)-[]->(r1)-[r1]->() r... |
| ^ |
| -- invalid variable reuse for labels across clauses |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (r1:e1), (r1:e2) return r1 |
| $$) AS (r1 agtype); |
| ERROR: multiple labels for variable 'r1' are not supported |
| LINE 2: MATCH (r1:e1), (r1:e2) return r1 |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (r1:invalid), (r1:e2) return r1 |
| $$) AS (r1 agtype); |
| ERROR: multiple labels for variable 'r1' are not supported |
| LINE 2: MATCH (r1:invalid), (r1:e2) return r1 |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (r1:e1), (r1:invalid) return r1 |
| $$) AS (r1 agtype); |
| ERROR: multiple labels for variable 'r1' are not supported |
| LINE 2: MATCH (r1:e1), (r1:invalid) return r1 |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (r1:e1), (r1), (r1:invalid) return r1 |
| $$) AS (r1 agtype); |
| ERROR: multiple labels for variable 'r1' are not supported |
| LINE 2: MATCH (r1:e1), (r1), (r1:invalid) return r1 |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (r0)-[r0]->() MATCH ()-[]->() RETURN r0 |
| $$) AS (r0 agtype); |
| ERROR: variable 'r0' is for a vertex |
| LINE 2: MATCH (r0)-[r0]->() MATCH ()-[]->() RETURN r0 |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (r0)-[]->() MATCH ()-[r0]->() RETURN r0 |
| $$) AS (r0 agtype); |
| ERROR: variable 'r0' is for a vertex |
| LINE 2: MATCH (r0)-[]->() MATCH ()-[r0]->() RETURN r0 |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[r0]->() MATCH ()-[]->(r0) RETURN r0 |
| $$) AS (r0 agtype); |
| ERROR: variable 'r0' is for an edge |
| LINE 2: MATCH ()-[r0]->() MATCH ()-[]->(r0) RETURN r0 |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[r0:e1]->() MATCH ()-[r0:e2]->() RETURN r0 |
| $$) AS (r0 agtype); |
| ERROR: multiple labels for variable 'r0' are not supported |
| LINE 2: MATCH ()-[r0:e1]->() MATCH ()-[r0:e2]->() RETURN r0 |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[r0]->() MATCH ()-[r0:e2]->() RETURN r0 |
| $$) AS (r0 agtype); |
| ERROR: multiple labels for variable 'r0' are not supported |
| LINE 2: MATCH ()-[r0]->() MATCH ()-[r0:e2]->() RETURN r0 |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[r0:e1]->() MATCH ()-[r0:e2]->() RETURN r0 |
| $$) AS (r0 agtype); |
| ERROR: multiple labels for variable 'r0' are not supported |
| LINE 2: MATCH ()-[r0:e1]->() MATCH ()-[r0:e2]->() RETURN r0 |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[r0:e1]->()-[r0]->() MATCH ()-[r0:e2]->() RETURN r0 |
| $$) AS (r0 agtype); |
| ERROR: duplicate edge variable 'r0' within a clause |
| LINE 2: MATCH ()-[r0:e1]->()-[r0]->() MATCH ()-[r0:e2]->() R... |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[r0:e1]->()-[r1]->() MATCH ()-[r1:e1]->()-[r0]->() RETURN r0 |
| $$) AS (r0 agtype); |
| ERROR: multiple labels for variable 'r1' are not supported |
| LINE 2: MATCH ()-[r0:e1]->()-[r1]->() MATCH ()-[r1:e1]->()-[... |
| ^ |
| -- Labels that don't exist but do match |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (r0)-[r1:related]->() MATCH ()-[r1:related]->() RETURN r0 |
| $$) AS (r0 agtype); |
| r0 |
| ---- |
| (0 rows) |
| |
| -- Labels that don't exist and don't match |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (r0)-[r1]->() MATCH ()-[r1:related]->() RETURN r0 |
| $$) AS (r0 agtype); |
| ERROR: multiple labels for variable 'r1' are not supported |
| LINE 2: MATCH (r0)-[r1]->() MATCH ()-[r1:related]->() RETURN... |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (r0)-[r1:related]->() MATCH ()-[r1:relateds]->() RETURN r0 |
| $$) AS (r0 agtype); |
| ERROR: multiple labels for variable 'r1' are not supported |
| LINE 2: MATCH (r0)-[r1:related]->() MATCH ()-[r1:relateds]->... |
| ^ |
| --Valid variable reuse, although why would you want to do it this way? |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a:v1)-[]-()-[]-(a {id:'will_not_fail'}) RETURN a |
| $$) AS (a agtype); |
| a |
| --- |
| (0 rows) |
| |
| --Incorrect Labels |
| SELECT * FROM cypher('cypher_match', $$MATCH (n)-[:v]-() RETURN n$$) AS (n agtype); |
| n |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$MATCH (n)-[:emissing]-() RETURN n$$) AS (n agtype); |
| n |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$MATCH (n:e1)-[]-() RETURN n$$) AS (n agtype); |
| n |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$MATCH (n:vmissing)-[]-() RETURN n$$) AS (n agtype); |
| n |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$MATCH (:e1)-[r]-() RETURN r$$) AS (r agtype); |
| r |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$MATCH (:vmissing)-[r]-() RETURN r$$) AS (r agtype); |
| r |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$MATCH (n),(:e1) RETURN n$$) AS (n agtype); |
| n |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$MATCH (n),()-[:v]-() RETURN n$$) AS (n agtype); |
| n |
| --- |
| (0 rows) |
| |
| -- |
| -- Path of one vertex. This should select 14 |
| -- |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH p=() RETURN p |
| $$) AS (p agtype); |
| p |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [{"id": 281474976710657, "label": "", "properties": {"int_key": 1, "map_key": {"key": "value"}, "list_key": [1, 2, 3], "float_key": 3.14, "string_key": "test"}}::vertex]::path |
| [{"id": 281474976710658, "label": "", "properties": {"lst": [1, null, 3.14, "string", {"key": "value"}, []]}}::vertex]::path |
| [{"id": 844424930131969, "label": "v", "properties": {}}::vertex]::path |
| [{"id": 844424930131970, "label": "v", "properties": {"i": 0}}::vertex]::path |
| [{"id": 844424930131971, "label": "v", "properties": {"i": 1}}::vertex]::path |
| [{"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex]::path |
| [{"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex]::path |
| [{"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex]::path |
| [{"id": 1688849860263937, "label": "v2", "properties": {"id": "initial"}}::vertex]::path |
| [{"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex]::path |
| [{"id": 1688849860263939, "label": "v2", "properties": {"id": "end"}}::vertex]::path |
| [{"id": 2251799813685249, "label": "v3", "properties": {"id": "initial"}}::vertex]::path |
| [{"id": 2251799813685250, "label": "v3", "properties": {"id": "middle"}}::vertex]::path |
| [{"id": 2251799813685251, "label": "v3", "properties": {"id": "end"}}::vertex]::path |
| (14 rows) |
| |
| -- |
| -- MATCH with WHERE EXISTS(pattern) |
| -- |
| SELECT * FROM cypher('cypher_match', |
| $$MATCH (u)-[e]->(v) RETURN u, e, v $$) AS (u agtype, e agtype, v agtype); |
| u | e | v |
| ----------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------- |
| {"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex | {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge | {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex |
| {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex | {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge | {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex |
| {"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex | {"id": 1970324836974594, "label": "e2", "end_id": 1688849860263937, "start_id": 1688849860263938, "properties": {}}::edge | {"id": 1688849860263937, "label": "v2", "properties": {"id": "initial"}}::vertex |
| {"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex | {"id": 1970324836974593, "label": "e2", "end_id": 1688849860263939, "start_id": 1688849860263938, "properties": {}}::edge | {"id": 1688849860263939, "label": "v2", "properties": {"id": "end"}}::vertex |
| {"id": 2251799813685249, "label": "v3", "properties": {"id": "initial"}}::vertex | {"id": 2533274790395906, "label": "e3", "end_id": 2251799813685250, "start_id": 2251799813685249, "properties": {}}::edge | {"id": 2251799813685250, "label": "v3", "properties": {"id": "middle"}}::vertex |
| {"id": 2251799813685251, "label": "v3", "properties": {"id": "end"}}::vertex | {"id": 2533274790395905, "label": "e3", "end_id": 2251799813685250, "start_id": 2251799813685251, "properties": {}}::edge | {"id": 2251799813685250, "label": "v3", "properties": {"id": "middle"}}::vertex |
| (6 rows) |
| |
| SELECT * FROM cypher('cypher_match', |
| $$MATCH (u)-[e]->(v) WHERE EXISTS((u)-[e]->(v)) RETURN u, e, v $$) |
| AS (u agtype, e agtype, v agtype); |
| u | e | v |
| ----------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------- |
| {"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex | {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge | {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex |
| {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex | {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge | {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex |
| {"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex | {"id": 1970324836974594, "label": "e2", "end_id": 1688849860263937, "start_id": 1688849860263938, "properties": {}}::edge | {"id": 1688849860263937, "label": "v2", "properties": {"id": "initial"}}::vertex |
| {"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex | {"id": 1970324836974593, "label": "e2", "end_id": 1688849860263939, "start_id": 1688849860263938, "properties": {}}::edge | {"id": 1688849860263939, "label": "v2", "properties": {"id": "end"}}::vertex |
| {"id": 2251799813685249, "label": "v3", "properties": {"id": "initial"}}::vertex | {"id": 2533274790395906, "label": "e3", "end_id": 2251799813685250, "start_id": 2251799813685249, "properties": {}}::edge | {"id": 2251799813685250, "label": "v3", "properties": {"id": "middle"}}::vertex |
| {"id": 2251799813685251, "label": "v3", "properties": {"id": "end"}}::vertex | {"id": 2533274790395905, "label": "e3", "end_id": 2251799813685250, "start_id": 2251799813685251, "properties": {}}::edge | {"id": 2251799813685250, "label": "v3", "properties": {"id": "middle"}}::vertex |
| (6 rows) |
| |
| -- Property Constraint in EXISTS |
| SELECT * FROM cypher('cypher_match', |
| $$MATCH (u) WHERE EXISTS((u)-[]->({id: "middle"})) RETURN u $$) |
| AS (u agtype); |
| u |
| ---------------------------------------------------------------------------------- |
| {"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex |
| {"id": 2251799813685249, "label": "v3", "properties": {"id": "initial"}}::vertex |
| {"id": 2251799813685251, "label": "v3", "properties": {"id": "end"}}::vertex |
| (3 rows) |
| |
| SELECT * FROM cypher('cypher_match', |
| $$MATCH (u) WHERE EXISTS((u)-[]->({id: "not a valid id"})) RETURN u $$) |
| AS (u agtype); |
| u |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', |
| $$MATCH (u) WHERE EXISTS((u)-[]->({id: NULL})) RETURN u $$) |
| AS (u agtype); |
| u |
| --- |
| (0 rows) |
| |
| -- Exists checks for a loop. There shouldn't be any. |
| SELECT * FROM cypher('cypher_match', |
| $$MATCH (u)-[e]->(v) WHERE EXISTS((u)-[e]->(u)) RETURN u, e, v $$) |
| AS (u agtype, e agtype, v agtype); |
| u | e | v |
| ---+---+--- |
| (0 rows) |
| |
| -- Create a loop |
| SELECT * FROM cypher('cypher_match', $$ |
| CREATE (u:loop {id:'initial'})-[:self]->(u) |
| $$) AS (a agtype); |
| a |
| --- |
| (0 rows) |
| |
| -- dump paths |
| SELECT * FROM cypher('cypher_match', |
| $$MATCH (u)-[e]->(v) WHERE EXISTS((u)-[e]->(v)) RETURN u, e, v $$) |
| AS (u agtype, e agtype, v agtype); |
| u | e | v |
| ------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------ |
| {"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex | {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge | {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex |
| {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex | {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge | {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex |
| {"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex | {"id": 1970324836974594, "label": "e2", "end_id": 1688849860263937, "start_id": 1688849860263938, "properties": {}}::edge | {"id": 1688849860263937, "label": "v2", "properties": {"id": "initial"}}::vertex |
| {"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex | {"id": 1970324836974593, "label": "e2", "end_id": 1688849860263939, "start_id": 1688849860263938, "properties": {}}::edge | {"id": 1688849860263939, "label": "v2", "properties": {"id": "end"}}::vertex |
| {"id": 2251799813685249, "label": "v3", "properties": {"id": "initial"}}::vertex | {"id": 2533274790395906, "label": "e3", "end_id": 2251799813685250, "start_id": 2251799813685249, "properties": {}}::edge | {"id": 2251799813685250, "label": "v3", "properties": {"id": "middle"}}::vertex |
| {"id": 2251799813685251, "label": "v3", "properties": {"id": "end"}}::vertex | {"id": 2533274790395905, "label": "e3", "end_id": 2251799813685250, "start_id": 2251799813685251, "properties": {}}::edge | {"id": 2251799813685250, "label": "v3", "properties": {"id": "middle"}}::vertex |
| {"id": 2814749767106561, "label": "loop", "properties": {"id": "initial"}}::vertex | {"id": 3096224743817217, "label": "self", "end_id": 2814749767106561, "start_id": 2814749767106561, "properties": {}}::edge | {"id": 2814749767106561, "label": "loop", "properties": {"id": "initial"}}::vertex |
| (7 rows) |
| |
| -- Exists checks for a loop. There should be one. |
| SELECT * FROM cypher('cypher_match', |
| $$MATCH (u)-[e]->(v) WHERE EXISTS((u)-[e]->(u)) RETURN u, e, v $$) |
| AS (u agtype, e agtype, v agtype); |
| u | e | v |
| ------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------ |
| {"id": 2814749767106561, "label": "loop", "properties": {"id": "initial"}}::vertex | {"id": 3096224743817217, "label": "self", "end_id": 2814749767106561, "start_id": 2814749767106561, "properties": {}}::edge | {"id": 2814749767106561, "label": "loop", "properties": {"id": "initial"}}::vertex |
| (1 row) |
| |
| -- Exists checks for a loop. There should be one. |
| SELECT * FROM cypher('cypher_match', |
| $$MATCH (u)-[e]->(v) WHERE EXISTS((v)-[e]->(v)) RETURN u, e, v $$) |
| AS (u agtype, e agtype, v agtype); |
| u | e | v |
| ------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------ |
| {"id": 2814749767106561, "label": "loop", "properties": {"id": "initial"}}::vertex | {"id": 3096224743817217, "label": "self", "end_id": 2814749767106561, "start_id": 2814749767106561, "properties": {}}::edge | {"id": 2814749767106561, "label": "loop", "properties": {"id": "initial"}}::vertex |
| (1 row) |
| |
| -- Multiple exists |
| SELECT * FROM cypher('cypher_match', |
| $$MATCH (u)-[e]->(v) WHERE EXISTS((u)) AND EXISTS((v)) RETURN u, e, v $$) |
| AS (u agtype, e agtype, v agtype); |
| u | e | v |
| ------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------ |
| {"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex | {"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge | {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex |
| {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex | {"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge | {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex |
| {"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex | {"id": 1970324836974594, "label": "e2", "end_id": 1688849860263937, "start_id": 1688849860263938, "properties": {}}::edge | {"id": 1688849860263937, "label": "v2", "properties": {"id": "initial"}}::vertex |
| {"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex | {"id": 1970324836974593, "label": "e2", "end_id": 1688849860263939, "start_id": 1688849860263938, "properties": {}}::edge | {"id": 1688849860263939, "label": "v2", "properties": {"id": "end"}}::vertex |
| {"id": 2251799813685249, "label": "v3", "properties": {"id": "initial"}}::vertex | {"id": 2533274790395906, "label": "e3", "end_id": 2251799813685250, "start_id": 2251799813685249, "properties": {}}::edge | {"id": 2251799813685250, "label": "v3", "properties": {"id": "middle"}}::vertex |
| {"id": 2251799813685251, "label": "v3", "properties": {"id": "end"}}::vertex | {"id": 2533274790395905, "label": "e3", "end_id": 2251799813685250, "start_id": 2251799813685251, "properties": {}}::edge | {"id": 2251799813685250, "label": "v3", "properties": {"id": "middle"}}::vertex |
| {"id": 2814749767106561, "label": "loop", "properties": {"id": "initial"}}::vertex | {"id": 3096224743817217, "label": "self", "end_id": 2814749767106561, "start_id": 2814749767106561, "properties": {}}::edge | {"id": 2814749767106561, "label": "loop", "properties": {"id": "initial"}}::vertex |
| (7 rows) |
| |
| SELECT * FROM cypher('cypher_match', |
| $$MATCH (u)-[e]->(v) WHERE EXISTS((u)-[e]->(u)) AND EXISTS((v)-[e]->(v)) RETURN u, e, v $$) |
| AS (u agtype, e agtype, v agtype); |
| u | e | v |
| ------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------ |
| {"id": 2814749767106561, "label": "loop", "properties": {"id": "initial"}}::vertex | {"id": 3096224743817217, "label": "self", "end_id": 2814749767106561, "start_id": 2814749767106561, "properties": {}}::edge | {"id": 2814749767106561, "label": "loop", "properties": {"id": "initial"}}::vertex |
| (1 row) |
| |
| -- Return exists(pattern) |
| SELECT * FROM cypher('cypher_match', |
| $$MATCH (u) RETURN EXISTS((u)-[]->()) $$) |
| AS (exists agtype); |
| exists |
| -------- |
| false |
| false |
| false |
| false |
| false |
| true |
| true |
| false |
| false |
| true |
| false |
| true |
| false |
| true |
| true |
| (15 rows) |
| |
| SELECT * FROM cypher('cypher_match', |
| $$MATCH (u)-[e]->(v) RETURN EXISTS((u)-[e]->(v)-[e]->(u))$$) |
| AS (exists agtype); |
| exists |
| -------- |
| false |
| false |
| false |
| false |
| false |
| false |
| false |
| (7 rows) |
| |
| -- These should error |
| -- Bad pattern |
| SELECT * FROM cypher('cypher_match', |
| $$MATCH (u)-[e]->(v) WHERE EXISTS((u)) AND EXISTS([e]) AND EXISTS((v)) RETURN u, e, v $$) |
| AS (u agtype, e agtype, v agtype); |
| ERROR: syntax error at or near "[" |
| LINE 2: ...$$MATCH (u)-[e]->(v) WHERE EXISTS((u)) AND EXISTS([e]) AND E... |
| ^ |
| -- variable creation error |
| SELECT * FROM cypher('cypher_match', |
| $$MATCH (u)-[e]->(v) WHERE EXISTS((u)-[e]->(x)) RETURN u, e, v $$) |
| AS (u agtype, e agtype, v agtype); |
| ERROR: variable `x` does not exist |
| LINE 2: $$MATCH (u)-[e]->(v) WHERE EXISTS((u)-[e]->(x)) RETURN u, e... |
| ^ |
| -- path variable not allowed in EXISTS |
| SELECT * FROM cypher('cypher_match', |
| $$MATCH p=(u)-[e]->(v) RETURN EXISTS((p)) $$) |
| AS (exists agtype); |
| ERROR: a path variable 'p' is not allowed here |
| LINE 2: $$MATCH p=(u)-[e]->(v) RETURN EXISTS((p)) $$) |
| ^ |
| -- |
| -- Tests for EXISTS(property) |
| -- |
| -- dump all vertices |
| SELECT * FROM cypher('cypher_match', $$MATCH (u) RETURN u $$) AS (u agtype); |
| u |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| {"id": 281474976710657, "label": "", "properties": {"int_key": 1, "map_key": {"key": "value"}, "list_key": [1, 2, 3], "float_key": 3.14, "string_key": "test"}}::vertex |
| {"id": 281474976710658, "label": "", "properties": {"lst": [1, null, 3.14, "string", {"key": "value"}, []]}}::vertex |
| {"id": 844424930131969, "label": "v", "properties": {}}::vertex |
| {"id": 844424930131970, "label": "v", "properties": {"i": 0}}::vertex |
| {"id": 844424930131971, "label": "v", "properties": {"i": 1}}::vertex |
| {"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex |
| {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex |
| {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex |
| {"id": 1688849860263937, "label": "v2", "properties": {"id": "initial"}}::vertex |
| {"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex |
| {"id": 1688849860263939, "label": "v2", "properties": {"id": "end"}}::vertex |
| {"id": 2251799813685249, "label": "v3", "properties": {"id": "initial"}}::vertex |
| {"id": 2251799813685250, "label": "v3", "properties": {"id": "middle"}}::vertex |
| {"id": 2251799813685251, "label": "v3", "properties": {"id": "end"}}::vertex |
| {"id": 2814749767106561, "label": "loop", "properties": {"id": "initial"}}::vertex |
| (15 rows) |
| |
| -- select vertices with id as a property |
| SELECT * FROM cypher('cypher_match', |
| $$MATCH (u) WHERE EXISTS(u.id) RETURN u $$) |
| AS (u agtype); |
| u |
| ------------------------------------------------------------------------------------ |
| {"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex |
| {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex |
| {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex |
| {"id": 1688849860263937, "label": "v2", "properties": {"id": "initial"}}::vertex |
| {"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex |
| {"id": 1688849860263939, "label": "v2", "properties": {"id": "end"}}::vertex |
| {"id": 2251799813685249, "label": "v3", "properties": {"id": "initial"}}::vertex |
| {"id": 2251799813685250, "label": "v3", "properties": {"id": "middle"}}::vertex |
| {"id": 2251799813685251, "label": "v3", "properties": {"id": "end"}}::vertex |
| {"id": 2814749767106561, "label": "loop", "properties": {"id": "initial"}}::vertex |
| (10 rows) |
| |
| -- select vertices without id as a property |
| SELECT * FROM cypher('cypher_match', |
| $$MATCH (u) WHERE NOT EXISTS(u.id) RETURN u $$) |
| AS (u agtype); |
| u |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| {"id": 281474976710657, "label": "", "properties": {"int_key": 1, "map_key": {"key": "value"}, "list_key": [1, 2, 3], "float_key": 3.14, "string_key": "test"}}::vertex |
| {"id": 281474976710658, "label": "", "properties": {"lst": [1, null, 3.14, "string", {"key": "value"}, []]}}::vertex |
| {"id": 844424930131969, "label": "v", "properties": {}}::vertex |
| {"id": 844424930131970, "label": "v", "properties": {"i": 0}}::vertex |
| {"id": 844424930131971, "label": "v", "properties": {"i": 1}}::vertex |
| (5 rows) |
| |
| -- select vertices without id as a property but with a property i |
| SELECT * FROM cypher('cypher_match', |
| $$MATCH (u) WHERE NOT EXISTS(u.id) AND EXISTS(u.i) RETURN u $$) |
| AS (u agtype); |
| u |
| ----------------------------------------------------------------------- |
| {"id": 844424930131970, "label": "v", "properties": {"i": 0}}::vertex |
| {"id": 844424930131971, "label": "v", "properties": {"i": 1}}::vertex |
| (2 rows) |
| |
| -- select vertices with id as a property and have a self loop |
| SELECT * FROM cypher('cypher_match', |
| $$MATCH (u) WHERE EXISTS(u.id) AND EXISTS((u)-[]->(u)) RETURN u$$) |
| AS (u agtype); |
| u |
| ------------------------------------------------------------------------------------ |
| {"id": 2814749767106561, "label": "loop", "properties": {"id": "initial"}}::vertex |
| (1 row) |
| |
| -- Return exists(property) |
| SELECT * FROM cypher('cypher_match', |
| $$MATCH (u) RETURN EXISTS(u.id), properties(u) $$) |
| AS (exists agtype, properties agtype); |
| exists | properties |
| --------+------------------------------------------------------------------------------------------------------------- |
| false | {"int_key": 1, "map_key": {"key": "value"}, "list_key": [1, 2, 3], "float_key": 3.14, "string_key": "test"} |
| false | {"lst": [1, null, 3.14, "string", {"key": "value"}, []]} |
| false | {} |
| false | {"i": 0} |
| false | {"i": 1} |
| true | {"id": "initial"} |
| true | {"id": "middle"} |
| true | {"id": "end"} |
| true | {"id": "initial"} |
| true | {"id": "middle"} |
| true | {"id": "end"} |
| true | {"id": "initial"} |
| true | {"id": "middle"} |
| true | {"id": "end"} |
| true | {"id": "initial"} |
| (15 rows) |
| |
| SELECT * FROM cypher('cypher_match', |
| $$MATCH (u) RETURN EXISTS(u.name), properties(u) $$) |
| AS (exists agtype, properties agtype); |
| exists | properties |
| --------+------------------------------------------------------------------------------------------------------------- |
| false | {"int_key": 1, "map_key": {"key": "value"}, "list_key": [1, 2, 3], "float_key": 3.14, "string_key": "test"} |
| false | {"lst": [1, null, 3.14, "string", {"key": "value"}, []]} |
| false | {} |
| false | {"i": 0} |
| false | {"i": 1} |
| false | {"id": "initial"} |
| false | {"id": "middle"} |
| false | {"id": "end"} |
| false | {"id": "initial"} |
| false | {"id": "middle"} |
| false | {"id": "end"} |
| false | {"id": "initial"} |
| false | {"id": "middle"} |
| false | {"id": "end"} |
| false | {"id": "initial"} |
| (15 rows) |
| |
| -- should give an error |
| SELECT * FROM cypher('cypher_match', |
| $$MATCH (u) WHERE EXISTS(u) RETURN u$$) |
| AS (u agtype); |
| ERROR: syntax error at or near ")" |
| LINE 2: $$MATCH (u) WHERE EXISTS(u) RETURN u$$) |
| ^ |
| -- |
| -- MATCH with WHERE isEmpty(property) |
| -- |
| SELECT create_graph('for_isEmpty'); |
| NOTICE: graph "for_isEmpty" has been created |
| create_graph |
| -------------- |
| |
| (1 row) |
| |
| -- Create vertices |
| SELECT * FROM cypher('for_isEmpty', |
| $$CREATE (u:for_pred {id:1, type: "empty", list: [], map: {}, string: ""}), |
| (v:for_pred {id:2, type: "filled", list: [1], map: {a:1}, string: "a"}), |
| (w:for_pred)$$) |
| AS (a agtype); |
| a |
| --- |
| (0 rows) |
| |
| -- Match vertices with empty properties |
| SELECT * FROM cypher('for_isEmpty', |
| $$MATCH (u:for_pred) WHERE isEmpty(u.list) RETURN properties(u) $$) |
| AS (u agtype); |
| u |
| ----------------------------------------------------------------- |
| {"id": 1, "map": {}, "list": [], "type": "empty", "string": ""} |
| (1 row) |
| |
| SELECT * FROM cypher('for_isEmpty', |
| $$MATCH (u:for_pred) WHERE isEmpty(u.map) RETURN properties(u) $$) |
| AS (u agtype); |
| u |
| ----------------------------------------------------------------- |
| {"id": 1, "map": {}, "list": [], "type": "empty", "string": ""} |
| (1 row) |
| |
| SELECT * FROM cypher('for_isEmpty', |
| $$MATCH (u:for_pred) WHERE isEmpty(u.string) RETURN properties(u) $$) |
| AS (u agtype); |
| u |
| ----------------------------------------------------------------- |
| {"id": 1, "map": {}, "list": [], "type": "empty", "string": ""} |
| (1 row) |
| |
| -- Match vertices with non-empty properties |
| SELECT * FROM cypher('for_isEmpty', |
| $$MATCH (u:for_pred) WHERE NOT isEmpty(u.list) RETURN properties(u) $$) |
| AS (u agtype); |
| u |
| -------------------------------------------------------------------------- |
| {"id": 2, "map": {"a": 1}, "list": [1], "type": "filled", "string": "a"} |
| (1 row) |
| |
| SELECT * FROM cypher('for_isEmpty', |
| $$MATCH (u:for_pred) WHERE NOT isEmpty(u.map) RETURN properties(u) $$) |
| AS (u agtype); |
| u |
| -------------------------------------------------------------------------- |
| {"id": 2, "map": {"a": 1}, "list": [1], "type": "filled", "string": "a"} |
| (1 row) |
| |
| SELECT * FROM cypher('for_isEmpty', |
| $$MATCH (u:for_pred) WHERE NOT isEmpty(u.string) RETURN properties(u) $$) |
| AS (u agtype); |
| u |
| -------------------------------------------------------------------------- |
| {"id": 2, "map": {"a": 1}, "list": [1], "type": "filled", "string": "a"} |
| (1 row) |
| |
| -- Match vertices with no properties |
| SELECT * FROM cypher('for_isEmpty', |
| $$MATCH (u:for_pred) WHERE isEmpty(properties(u)) RETURN properties(u) $$) |
| AS (u agtype); |
| u |
| ---- |
| {} |
| (1 row) |
| |
| -- Match vertices with properties |
| SELECT * FROM cypher('for_isEmpty', |
| $$MATCH (u:for_pred) WHERE NOT isEmpty(properties(u)) RETURN properties(u) $$) |
| AS (u agtype); |
| u |
| -------------------------------------------------------------------------- |
| {"id": 1, "map": {}, "list": [], "type": "empty", "string": ""} |
| {"id": 2, "map": {"a": 1}, "list": [1], "type": "filled", "string": "a"} |
| (2 rows) |
| |
| -- Match vertices with null property (should return nothing since WHERE null) |
| SELECT * FROM cypher('for_isEmpty', |
| $$MATCH (u:for_pred) WHERE isEmpty(u.tree) RETURN properties(u) $$) |
| AS (u agtype); |
| u |
| --- |
| (0 rows) |
| |
| -- Match and Return bool |
| SELECT * FROM cypher('for_isEmpty', |
| $$MATCH (u:for_pred) WHERE isEmpty(u.list) RETURN isEmpty(u.list), u.type $$) |
| AS (b agtype, type agtype); |
| b | type |
| ------+--------- |
| true | "empty" |
| (1 row) |
| |
| SELECT * FROM cypher('for_isEmpty', |
| $$MATCH (u:for_pred) WHERE NOT isEmpty(u.list) RETURN isEmpty(u.list), u.type $$) |
| AS (b agtype, type agtype); |
| b | type |
| -------+---------- |
| false | "filled" |
| (1 row) |
| |
| -- Return null on null |
| SELECT * FROM cypher('for_isEmpty', |
| $$MATCH (u:for_pred) RETURN isEmpty(u.tree) $$) |
| AS (b agtype); |
| b |
| --- |
| |
| |
| |
| (3 rows) |
| |
| -- Should give an error |
| SELECT * FROM cypher('for_isEmpty', |
| $$MATCH (u:for_pred) WHERE isEmpty(u) RETURN properties(u) $$) |
| AS (u agtype); |
| ERROR: isEmpty() unsupported argument, expected a List, Map, or String |
| SELECT * FROM cypher('for_isEmpty', |
| $$MATCH (u:for_pred) WHERE isEmpty(1) RETURN properties(u) $$) |
| AS (u agtype); |
| ERROR: isEmpty() unsupported argument, expected a List, Map, or String |
| SELECT * FROM cypher('for_isEmpty', |
| $$MATCH (u:for_pred) WHERE isEmpty(1,2,3) RETURN properties(u) $$) |
| AS (u agtype); |
| ERROR: function ag_catalog.age_isempty(agtype, agtype, agtype) does not exist |
| LINE 2: $$MATCH (u:for_pred) WHERE isEmpty(1,2,3) RETURN properties... |
| ^ |
| HINT: No function matches the given name and argument types. You might need to add explicit type casts. |
| SELECT * FROM cypher('for_isEmpty', |
| $$MATCH (u:for_pred) WHERE isEmpty() RETURN properties(u) $$) |
| AS (u agtype); |
| ERROR: function ag_catalog.age_isempty() does not exist |
| LINE 2: $$MATCH (u:for_pred) WHERE isEmpty() RETURN properties(u) $... |
| ^ |
| HINT: No function matches the given name and argument types. You might need to add explicit type casts. |
| -- clean up |
| SELECT drop_graph('for_isEmpty', true); |
| NOTICE: drop cascades to 3 other objects |
| DETAIL: drop cascades to table "for_isEmpty"._ag_label_vertex |
| drop cascades to table "for_isEmpty"._ag_label_edge |
| drop cascades to table "for_isEmpty".for_pred |
| NOTICE: graph "for_isEmpty" has been dropped |
| drop_graph |
| ------------ |
| |
| (1 row) |
| |
| -- |
| --Distinct |
| -- |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (u) |
| RETURN DISTINCT u.id |
| $$) AS (i agtype) ORDER BY i; |
| i |
| ----------- |
| "end" |
| "initial" |
| "middle" |
| |
| (4 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| CREATE (u:duplicate)-[:dup_edge {id:1 }]->(:other_v) |
| $$) AS (a agtype); |
| a |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (u:duplicate) |
| CREATE (u)-[:dup_edge {id:2 }]->(:other_v) |
| $$) AS (a agtype); |
| a |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (u:duplicate)-[]-(:other_v) |
| RETURN DISTINCT u |
| $$) AS (i agtype); |
| i |
| -------------------------------------------------------------------------- |
| {"id": 3377699720527873, "label": "duplicate", "properties": {}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH p=(:duplicate)-[]-(:other_v) |
| RETURN DISTINCT p |
| $$) AS (i agtype) ORDER BY i; |
| i |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [{"id": 3377699720527873, "label": "duplicate", "properties": {}}::vertex, {"id": 3659174697238529, "label": "dup_edge", "end_id": 3940649673949185, "start_id": 3377699720527873, "properties": {"id": 1}}::edge, {"id": 3940649673949185, "label": "other_v", "properties": {}}::vertex]::path |
| [{"id": 3377699720527873, "label": "duplicate", "properties": {}}::vertex, {"id": 3659174697238530, "label": "dup_edge", "end_id": 3940649673949186, "start_id": 3377699720527873, "properties": {"id": 2}}::edge, {"id": 3940649673949186, "label": "other_v", "properties": {}}::vertex]::path |
| (2 rows) |
| |
| -- |
| -- Limit |
| -- |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (u) |
| RETURN u |
| $$) AS (i agtype); |
| i |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| {"id": 281474976710657, "label": "", "properties": {"int_key": 1, "map_key": {"key": "value"}, "list_key": [1, 2, 3], "float_key": 3.14, "string_key": "test"}}::vertex |
| {"id": 281474976710658, "label": "", "properties": {"lst": [1, null, 3.14, "string", {"key": "value"}, []]}}::vertex |
| {"id": 844424930131969, "label": "v", "properties": {}}::vertex |
| {"id": 844424930131970, "label": "v", "properties": {"i": 0}}::vertex |
| {"id": 844424930131971, "label": "v", "properties": {"i": 1}}::vertex |
| {"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex |
| {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex |
| {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex |
| {"id": 1688849860263937, "label": "v2", "properties": {"id": "initial"}}::vertex |
| {"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex |
| {"id": 1688849860263939, "label": "v2", "properties": {"id": "end"}}::vertex |
| {"id": 2251799813685249, "label": "v3", "properties": {"id": "initial"}}::vertex |
| {"id": 2251799813685250, "label": "v3", "properties": {"id": "middle"}}::vertex |
| {"id": 2251799813685251, "label": "v3", "properties": {"id": "end"}}::vertex |
| {"id": 2814749767106561, "label": "loop", "properties": {"id": "initial"}}::vertex |
| {"id": 3377699720527873, "label": "duplicate", "properties": {}}::vertex |
| {"id": 3940649673949185, "label": "other_v", "properties": {}}::vertex |
| {"id": 3940649673949186, "label": "other_v", "properties": {}}::vertex |
| (18 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (u) |
| RETURN u LIMIT 3 |
| $$) AS (i agtype); |
| i |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| {"id": 281474976710657, "label": "", "properties": {"int_key": 1, "map_key": {"key": "value"}, "list_key": [1, 2, 3], "float_key": 3.14, "string_key": "test"}}::vertex |
| {"id": 281474976710658, "label": "", "properties": {"lst": [1, null, 3.14, "string", {"key": "value"}, []]}}::vertex |
| {"id": 844424930131969, "label": "v", "properties": {}}::vertex |
| (3 rows) |
| |
| -- |
| -- Skip |
| -- |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (u) |
| RETURN u SKIP 7 |
| $$) AS (i agtype); |
| i |
| ------------------------------------------------------------------------------------ |
| {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex |
| {"id": 1688849860263937, "label": "v2", "properties": {"id": "initial"}}::vertex |
| {"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex |
| {"id": 1688849860263939, "label": "v2", "properties": {"id": "end"}}::vertex |
| {"id": 2251799813685249, "label": "v3", "properties": {"id": "initial"}}::vertex |
| {"id": 2251799813685250, "label": "v3", "properties": {"id": "middle"}}::vertex |
| {"id": 2251799813685251, "label": "v3", "properties": {"id": "end"}}::vertex |
| {"id": 2814749767106561, "label": "loop", "properties": {"id": "initial"}}::vertex |
| {"id": 3377699720527873, "label": "duplicate", "properties": {}}::vertex |
| {"id": 3940649673949185, "label": "other_v", "properties": {}}::vertex |
| {"id": 3940649673949186, "label": "other_v", "properties": {}}::vertex |
| (11 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (u) |
| RETURN u SKIP 7 LIMIT 3 |
| $$) AS (i agtype); |
| i |
| ---------------------------------------------------------------------------------- |
| {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex |
| {"id": 1688849860263937, "label": "v2", "properties": {"id": "initial"}}::vertex |
| {"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex |
| (3 rows) |
| |
| -- |
| -- Optional Match |
| -- |
| SELECT * FROM cypher('cypher_match', $$ |
| CREATE (:opt_match_v {name: 'someone'})-[:opt_match_e]->(:opt_match_v {name: 'somebody'}), |
| (:opt_match_v {name: 'anybody'})-[:opt_match_e]->(:opt_match_v {name: 'nobody'}) |
| $$) AS (u agtype); |
| u |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (u:opt_match_v) |
| OPTIONAL MATCH (u)-[m]-(l) |
| RETURN u.name as u, type(m), l.name as l |
| ORDER BY u, m, l |
| $$) AS (u agtype, m agtype, l agtype); |
| u | m | l |
| ------------+---------------+------------ |
| "someone" | "opt_match_e" | "somebody" |
| "somebody" | "opt_match_e" | "someone" |
| "anybody" | "opt_match_e" | "nobody" |
| "nobody" | "opt_match_e" | "anybody" |
| (4 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| OPTIONAL MATCH (n:opt_match_v)-[r]->(p), (m:opt_match_v)-[s]->(q) |
| WHERE id(n) <> id(m) |
| RETURN n.name as n, type(r) AS r, p.name as p, |
| m.name AS m, type(s) AS s, q.name AS q |
| ORDER BY n, p, m, q |
| $$) AS (n agtype, r agtype, p agtype, m agtype, s agtype, q agtype); |
| n | r | p | m | s | q |
| -----------+---------------+------------+-----------+---------------+------------ |
| "someone" | "opt_match_e" | "somebody" | "anybody" | "opt_match_e" | "nobody" |
| "anybody" | "opt_match_e" | "nobody" | "someone" | "opt_match_e" | "somebody" |
| (2 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (n:opt_match_v), (m:opt_match_v) |
| WHERE id(n) <> id(m) |
| OPTIONAL MATCH (n)-[r]->(p), (m)-[s]->(q) |
| RETURN n.name AS n, type(r) AS r, p.name AS p, |
| m.name AS m, type(s) AS s, q.name AS q |
| ORDER BY n, p, m, q |
| $$) AS (n agtype, r agtype, p agtype, m agtype, s agtype, q agtype); |
| n | r | p | m | s | q |
| ------------+---------------+------------+------------+---------------+------------ |
| "someone" | "opt_match_e" | "somebody" | "anybody" | "opt_match_e" | "nobody" |
| "someone" | | | "somebody" | | |
| "someone" | | | "nobody" | | |
| "somebody" | | | "someone" | | |
| "somebody" | | | "anybody" | | |
| "somebody" | | | "nobody" | | |
| "anybody" | "opt_match_e" | "nobody" | "someone" | "opt_match_e" | "somebody" |
| "anybody" | | | "somebody" | | |
| "anybody" | | | "nobody" | | |
| "nobody" | | | "someone" | | |
| "nobody" | | | "somebody" | | |
| "nobody" | | | "anybody" | | |
| (12 rows) |
| |
| -- Tests to catch match following optional match logic |
| -- this syntax is invalid in cypher |
| SELECT * FROM cypher('cypher_match', $$ |
| OPTIONAL MATCH (n) |
| MATCH (m) |
| RETURN n,m |
| $$) AS (n agtype, m agtype); |
| ERROR: MATCH cannot follow OPTIONAL MATCH |
| LINE 1: SELECT * FROM cypher('cypher_match', $$ |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (n) |
| OPTIONAL MATCH (m) |
| MATCH (o) |
| RETURN n,m |
| $$) AS (n agtype, m agtype); |
| ERROR: MATCH cannot follow OPTIONAL MATCH |
| LINE 1: SELECT * FROM cypher('cypher_match', $$ |
| ^ |
| -- |
| -- Tests retrieving Var from some parent's cpstate during transformation |
| -- |
| SELECT create_graph('test_retrieve_var'); |
| NOTICE: graph "test_retrieve_var" has been created |
| create_graph |
| -------------- |
| |
| (1 row) |
| |
| SELECT * FROM cypher('test_retrieve_var', $$ CREATE (:A)-[:incs]->(:C) $$) as (a agtype); |
| a |
| --- |
| (0 rows) |
| |
| -- Tests with node Var |
| -- both queries should return the same result |
| -- first query does not retrieve any variable from any parent's cpstate |
| -- second query retrieves variable 'a', inside WHERE, from parent's parent's cpstate |
| SELECT * FROM cypher('test_retrieve_var', $$ |
| MATCH (a:A) WITH a |
| OPTIONAL MATCH (a)-[:incs]->(c) |
| WHERE EXISTS((c)<-[:incs]-()) |
| RETURN a, c |
| $$) AS (a agtype, c agtype); |
| a | c |
| -----------------------------------------------------------------+------------------------------------------------------------------ |
| {"id": 844424930131969, "label": "A", "properties": {}}::vertex | {"id": 1407374883553281, "label": "C", "properties": {}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('test_retrieve_var', $$ |
| MATCH (a:A) WITH a |
| OPTIONAL MATCH (a)-[:incs]->(c) |
| WHERE EXISTS((c)<-[:incs]-(a)) |
| RETURN a, c |
| $$) AS (a agtype, c agtype); |
| a | c |
| -----------------------------------------------------------------+------------------------------------------------------------------ |
| {"id": 844424930131969, "label": "A", "properties": {}}::vertex | {"id": 1407374883553281, "label": "C", "properties": {}}::vertex |
| (1 row) |
| |
| -- Tests with edge Var |
| -- both queries should return the same result |
| -- first query does not retrieve any variable from any parent's cpstate |
| -- second query retrieves variable 'r', inside WHERE, from parent's parent's cpstate |
| SELECT * FROM cypher('test_retrieve_var', $$ |
| MATCH (a:A)-[r:incs]->() WITH a, r |
| OPTIONAL MATCH (a)-[r]->(c) |
| WHERE EXISTS(()<-[]-(c)) |
| RETURN a, r |
| $$) AS (a agtype, r agtype); |
| a | r |
| -----------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------- |
| {"id": 844424930131969, "label": "A", "properties": {}}::vertex | {"id": 1125899906842625, "label": "incs", "end_id": 1407374883553281, "start_id": 844424930131969, "properties": {}}::edge |
| (1 row) |
| |
| SELECT * FROM cypher('test_retrieve_var', $$ |
| MATCH (a:A)-[r:incs]->() WITH a, r |
| OPTIONAL MATCH (a)-[r]->(c) |
| WHERE EXISTS((:A)<-[]-(c)) |
| RETURN a, r |
| $$) AS (a agtype, r agtype); |
| a | r |
| -----------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------- |
| {"id": 844424930131969, "label": "A", "properties": {}}::vertex | {"id": 1125899906842625, "label": "incs", "end_id": 1407374883553281, "start_id": 844424930131969, "properties": {}}::edge |
| (1 row) |
| |
| SELECT * FROM cypher('test_retrieve_var', $$ |
| MATCH (a:A)-[r:incs]->() WITH a, r |
| OPTIONAL MATCH (a)-[r]->(c) |
| WHERE EXISTS((c)<-[]-(:A)) |
| RETURN a, r |
| $$) AS (a agtype, r agtype); |
| a | r |
| -----------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------- |
| {"id": 844424930131969, "label": "A", "properties": {}}::vertex | {"id": 1125899906842625, "label": "incs", "end_id": 1407374883553281, "start_id": 844424930131969, "properties": {}}::edge |
| (1 row) |
| |
| SELECT * FROM cypher('test_retrieve_var', $$ |
| MATCH (a:A)-[r:incs]->() WITH a, r |
| OPTIONAL MATCH (a)-[r]->(c) |
| WHERE EXISTS((:C)<-[]-(:A)) |
| RETURN a, r |
| $$) AS (a agtype, r agtype); |
| a | r |
| -----------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------- |
| {"id": 844424930131969, "label": "A", "properties": {}}::vertex | {"id": 1125899906842625, "label": "incs", "end_id": 1407374883553281, "start_id": 844424930131969, "properties": {}}::edge |
| (1 row) |
| |
| SELECT * FROM cypher('test_retrieve_var', $$ |
| MATCH (a:A)-[r:incs]->() WITH a, r |
| OPTIONAL MATCH (a)-[r]->(c) |
| WHERE EXISTS(()<-[r]-(c)) |
| RETURN a, r |
| $$) AS (a agtype, r agtype); |
| a | r |
| -----------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------- |
| {"id": 844424930131969, "label": "A", "properties": {}}::vertex | {"id": 1125899906842625, "label": "incs", "end_id": 1407374883553281, "start_id": 844424930131969, "properties": {}}::edge |
| (1 row) |
| |
| -- |
| -- JIRA: AGE2-544 |
| -- |
| -- Clean up |
| SELECT DISTINCT * FROM cypher('cypher_match', $$ |
| MATCH (u) DETACH DELETE (u) |
| $$) AS (i agtype); |
| i |
| --- |
| (0 rows) |
| |
| -- Prepare |
| SELECT * FROM cypher('cypher_match', $$ |
| CREATE (u {name: "orphan"}) |
| CREATE (u1 {name: "F"})-[u2:e1]->(u3 {name: "T"}) |
| RETURN u1, u2, u3 |
| $$) as (u1 agtype, u2 agtype, u3 agtype); |
| u1 | u2 | u3 |
| ---------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------- |
| {"id": 281474976710660, "label": "", "properties": {"name": "F"}}::vertex | {"id": 1407374883553283, "label": "e1", "end_id": 281474976710661, "start_id": 281474976710660, "properties": {}}::edge | {"id": 281474976710661, "label": "", "properties": {"name": "T"}}::vertex |
| (1 row) |
| |
| -- Querying NOT EXISTS syntax |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (f),(t) |
| WHERE NOT EXISTS((f)-[]->(t)) |
| RETURN f.name, t.name |
| $$) as (f agtype, t agtype); |
| f | t |
| ----------+---------- |
| "orphan" | "orphan" |
| "orphan" | "F" |
| "orphan" | "T" |
| "F" | "orphan" |
| "F" | "F" |
| "T" | "orphan" |
| "T" | "F" |
| "T" | "T" |
| (8 rows) |
| |
| -- Querying EXISTS syntax |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (f),(t) |
| WHERE EXISTS((f)-[]->(t)) |
| RETURN f.name, t.name |
| $$) as (f agtype, t agtype); |
| f | t |
| -----+----- |
| "F" | "T" |
| (1 row) |
| |
| -- Querying ALL |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (f),(t) |
| WHERE NOT EXISTS((f)-[]->(t)) or true |
| RETURN f.name, t.name |
| $$) as (f agtype, t agtype); |
| f | t |
| ----------+---------- |
| "orphan" | "orphan" |
| "orphan" | "F" |
| "orphan" | "T" |
| "F" | "orphan" |
| "F" | "F" |
| "F" | "T" |
| "T" | "orphan" |
| "T" | "F" |
| "T" | "T" |
| (9 rows) |
| |
| -- Querying ALL |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (f),(t) |
| RETURN f.name, t.name |
| $$) as (f agtype, t agtype); |
| f | t |
| ----------+---------- |
| "orphan" | "orphan" |
| "orphan" | "F" |
| "orphan" | "T" |
| "F" | "orphan" |
| "F" | "F" |
| "F" | "T" |
| "T" | "orphan" |
| "T" | "F" |
| "T" | "T" |
| (9 rows) |
| |
| -- |
| -- Constraints and WHERE clause together |
| -- |
| SELECT * FROM cypher('cypher_match', $$ |
| CREATE ({i: 1, j: 2, k: 3}), ({i: 1, j: 3}), ({i:2, k: 3}) |
| $$) as (a agtype); |
| a |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (n {j: 2}) |
| WHERE n.i = 1 |
| RETURN n |
| $$) as (n agtype); |
| n |
| -------------------------------------------------------------------------------------- |
| {"id": 281474976710662, "label": "", "properties": {"i": 1, "j": 2, "k": 3}}::vertex |
| (1 row) |
| |
| -- |
| -- Regression tests to check previous clause variable refs |
| -- |
| -- set up initial state and show what we're working with |
| SELECT * FROM cypher('cypher_match', $$ |
| CREATE (a {age: 4}) RETURN a $$) as (a agtype); |
| a |
| ------------------------------------------------------------------------ |
| {"id": 281474976710665, "label": "", "properties": {"age": 4}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| CREATE (b {age: 6}) RETURN b $$) as (b agtype); |
| b |
| ------------------------------------------------------------------------ |
| {"id": 281474976710666, "label": "", "properties": {"age": 6}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a) RETURN a $$) as (a agtype); |
| a |
| -------------------------------------------------------------------------------------- |
| {"id": 281474976710659, "label": "", "properties": {"name": "orphan"}}::vertex |
| {"id": 281474976710660, "label": "", "properties": {"name": "F"}}::vertex |
| {"id": 281474976710661, "label": "", "properties": {"name": "T"}}::vertex |
| {"id": 281474976710662, "label": "", "properties": {"i": 1, "j": 2, "k": 3}}::vertex |
| {"id": 281474976710663, "label": "", "properties": {"i": 1, "j": 3}}::vertex |
| {"id": 281474976710664, "label": "", "properties": {"i": 2, "k": 3}}::vertex |
| {"id": 281474976710665, "label": "", "properties": {"age": 4}}::vertex |
| {"id": 281474976710666, "label": "", "properties": {"age": 6}}::vertex |
| (8 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a) WHERE EXISTS(a.name) RETURN a $$) as (a agtype); |
| a |
| -------------------------------------------------------------------------------- |
| {"id": 281474976710659, "label": "", "properties": {"name": "orphan"}}::vertex |
| {"id": 281474976710660, "label": "", "properties": {"name": "F"}}::vertex |
| {"id": 281474976710661, "label": "", "properties": {"name": "T"}}::vertex |
| (3 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a) WHERE EXISTS(a.name) SET a.age = 4 RETURN a $$) as (a agtype); |
| a |
| ------------------------------------------------------------------------------------------ |
| {"id": 281474976710659, "label": "", "properties": {"age": 4, "name": "orphan"}}::vertex |
| {"id": 281474976710660, "label": "", "properties": {"age": 4, "name": "F"}}::vertex |
| {"id": 281474976710661, "label": "", "properties": {"age": 4, "name": "T"}}::vertex |
| (3 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a),(b) WHERE a.age = 4 AND a.name = "T" AND b.age = 6 |
| RETURN a,b $$) as (a agtype, b agtype); |
| a | b |
| -------------------------------------------------------------------------------------+------------------------------------------------------------------------ |
| {"id": 281474976710661, "label": "", "properties": {"age": 4, "name": "T"}}::vertex | {"id": 281474976710666, "label": "", "properties": {"age": 6}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a),(b) WHERE a.age = 4 AND a.name = "T" AND b.age = 6 CREATE |
| (a)-[:knows {relationship: "friends", years: 3}]->(b) $$) as (r agtype); |
| r |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a),(b) WHERE a.age = 4 AND a.name = "orphan" AND b.age = 6 CREATE |
| (a)-[:knows {relationship: "enemies", years: 4}]->(b) $$) as (r agtype); |
| r |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a)-[r]-(b) RETURN r ORDER BY r DESC $$) as (r agtype); |
| r |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| {"id": 4785074604081154, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710659, "properties": {"years": 4, "relationship": "enemies"}}::edge |
| {"id": 4785074604081154, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710659, "properties": {"years": 4, "relationship": "enemies"}}::edge |
| {"id": 4785074604081153, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710661, "properties": {"years": 3, "relationship": "friends"}}::edge |
| {"id": 4785074604081153, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710661, "properties": {"years": 3, "relationship": "friends"}}::edge |
| {"id": 1407374883553283, "label": "e1", "end_id": 281474976710661, "start_id": 281474976710660, "properties": {}}::edge |
| {"id": 1407374883553283, "label": "e1", "end_id": 281474976710661, "start_id": 281474976710660, "properties": {}}::edge |
| (6 rows) |
| |
| -- check reuse of 'a' clause-to-clause - vertices |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a {age:4}) RETURN a $$) as (a agtype); |
| a |
| ------------------------------------------------------------------------------------------ |
| {"id": 281474976710665, "label": "", "properties": {"age": 4}}::vertex |
| {"id": 281474976710659, "label": "", "properties": {"age": 4, "name": "orphan"}}::vertex |
| {"id": 281474976710660, "label": "", "properties": {"age": 4, "name": "F"}}::vertex |
| {"id": 281474976710661, "label": "", "properties": {"age": 4, "name": "T"}}::vertex |
| (4 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a) MATCH (a {age:4}) RETURN a $$) as (a agtype); |
| a |
| ------------------------------------------------------------------------------------------ |
| {"id": 281474976710665, "label": "", "properties": {"age": 4}}::vertex |
| {"id": 281474976710659, "label": "", "properties": {"age": 4, "name": "orphan"}}::vertex |
| {"id": 281474976710660, "label": "", "properties": {"age": 4, "name": "F"}}::vertex |
| {"id": 281474976710661, "label": "", "properties": {"age": 4, "name": "T"}}::vertex |
| (4 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a {age:4, name: "orphan"}) RETURN a $$) as (a agtype); |
| a |
| ------------------------------------------------------------------------------------------ |
| {"id": 281474976710659, "label": "", "properties": {"age": 4, "name": "orphan"}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a) MATCH (a {age:4}) MATCH (a {name: "orphan"}) RETURN a $$) as (a agtype); |
| a |
| ------------------------------------------------------------------------------------------ |
| {"id": 281474976710659, "label": "", "properties": {"age": 4, "name": "orphan"}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a {age:4}) MATCH (a {name: "orphan"}) RETURN a $$) as (a agtype); |
| a |
| ------------------------------------------------------------------------------------------ |
| {"id": 281474976710659, "label": "", "properties": {"age": 4, "name": "orphan"}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a) MATCH (a {age:4}) MATCH (a {name: "orphan"}) SET a.age = 3 RETURN a $$) as (a agtype); |
| a |
| ------------------------------------------------------------------------------------------ |
| {"id": 281474976710659, "label": "", "properties": {"age": 3, "name": "orphan"}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a) MATCH (a {age:3}) MATCH (a {name: "orphan"}) RETURN a $$) as (a agtype); |
| a |
| ------------------------------------------------------------------------------------------ |
| {"id": 281474976710659, "label": "", "properties": {"age": 3, "name": "orphan"}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a {name: "orphan"}) MATCH (a {age:3}) RETURN a $$) as (a agtype); |
| a |
| ------------------------------------------------------------------------------------------ |
| {"id": 281474976710659, "label": "", "properties": {"age": 3, "name": "orphan"}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a) WHERE EXISTS(a.age) AND EXISTS(a.name) RETURN a $$) as (a agtype); |
| a |
| ------------------------------------------------------------------------------------------ |
| {"id": 281474976710660, "label": "", "properties": {"age": 4, "name": "F"}}::vertex |
| {"id": 281474976710661, "label": "", "properties": {"age": 4, "name": "T"}}::vertex |
| {"id": 281474976710659, "label": "", "properties": {"age": 3, "name": "orphan"}}::vertex |
| (3 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH (a) WHERE EXISTS(a.age) AND NOT EXISTS(a.name) RETURN a $$) as (a agtype); |
| a |
| ------------------------------------------------------------------------ |
| {"id": 281474976710665, "label": "", "properties": {"age": 4}}::vertex |
| {"id": 281474976710666, "label": "", "properties": {"age": 6}}::vertex |
| (2 rows) |
| |
| -- check reuse of 'r' clause-to-clause - edges |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[r]-() RETURN r ORDER BY r DESC $$) as (r agtype); |
| r |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| {"id": 4785074604081154, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710659, "properties": {"years": 4, "relationship": "enemies"}}::edge |
| {"id": 4785074604081154, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710659, "properties": {"years": 4, "relationship": "enemies"}}::edge |
| {"id": 4785074604081153, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710661, "properties": {"years": 3, "relationship": "friends"}}::edge |
| {"id": 4785074604081153, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710661, "properties": {"years": 3, "relationship": "friends"}}::edge |
| {"id": 1407374883553283, "label": "e1", "end_id": 281474976710661, "start_id": 281474976710660, "properties": {}}::edge |
| {"id": 1407374883553283, "label": "e1", "end_id": 281474976710661, "start_id": 281474976710660, "properties": {}}::edge |
| (6 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[r]-() MATCH ()-[r {relationship: "friends"}]-() RETURN r $$) as (r agtype); |
| r |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| {"id": 4785074604081153, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710661, "properties": {"years": 3, "relationship": "friends"}}::edge |
| {"id": 4785074604081153, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710661, "properties": {"years": 3, "relationship": "friends"}}::edge |
| {"id": 4785074604081153, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710661, "properties": {"years": 3, "relationship": "friends"}}::edge |
| {"id": 4785074604081153, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710661, "properties": {"years": 3, "relationship": "friends"}}::edge |
| (4 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[r {years:3, relationship: "friends"}]-() RETURN r $$) as (r agtype); |
| r |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| {"id": 4785074604081153, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710661, "properties": {"years": 3, "relationship": "friends"}}::edge |
| {"id": 4785074604081153, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710661, "properties": {"years": 3, "relationship": "friends"}}::edge |
| (2 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[r {years:3}]-() MATCH ()-[r {relationship: "friends"}]-() RETURN r $$) as (r agtype); |
| r |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| {"id": 4785074604081153, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710661, "properties": {"years": 3, "relationship": "friends"}}::edge |
| {"id": 4785074604081153, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710661, "properties": {"years": 3, "relationship": "friends"}}::edge |
| {"id": 4785074604081153, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710661, "properties": {"years": 3, "relationship": "friends"}}::edge |
| {"id": 4785074604081153, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710661, "properties": {"years": 3, "relationship": "friends"}}::edge |
| (4 rows) |
| |
| --mismatch year #, should return nothing |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[r {years:2}]-() MATCH ()-[r {relationship: "friends"}]-() RETURN r $$) as (r agtype); |
| r |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[r {relationship:"enemies"}]-() MATCH ()-[r {years:4}]-() RETURN r $$) as (r agtype); |
| r |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| {"id": 4785074604081154, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710659, "properties": {"years": 4, "relationship": "enemies"}}::edge |
| {"id": 4785074604081154, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710659, "properties": {"years": 4, "relationship": "enemies"}}::edge |
| {"id": 4785074604081154, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710659, "properties": {"years": 4, "relationship": "enemies"}}::edge |
| {"id": 4785074604081154, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710659, "properties": {"years": 4, "relationship": "enemies"}}::edge |
| (4 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ |
| MATCH ()-[r {relationship:"enemies"}]-() MATCH ()-[r {relationship:"friends"}]-() RETURN r $$) as (r agtype); |
| r |
| --- |
| (0 rows) |
| |
| -- check reuse within clause - vertices |
| SELECT * FROM cypher('cypher_match', $$ CREATE (u {name: "Dave"})-[:knows]->({name: "John"})-[:knows]->(u) RETURN u $$) as (u agtype); |
| u |
| ------------------------------------------------------------------------------ |
| {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ MATCH p=(u)-[]-()-[]-(u) RETURN p $$)as (p agtype); |
| p |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [{"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex, {"id": 4785074604081155, "label": "knows", "end_id": 281474976710667, "start_id": 281474976710668, "properties": {}}::edge, {"id": 281474976710668, "label": "", "properties": {"name": "John"}}::vertex, {"id": 4785074604081156, "label": "knows", "end_id": 281474976710668, "start_id": 281474976710667, "properties": {}}::edge, {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex]::path |
| [{"id": 281474976710668, "label": "", "properties": {"name": "John"}}::vertex, {"id": 4785074604081155, "label": "knows", "end_id": 281474976710667, "start_id": 281474976710668, "properties": {}}::edge, {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex, {"id": 4785074604081156, "label": "knows", "end_id": 281474976710668, "start_id": 281474976710667, "properties": {}}::edge, {"id": 281474976710668, "label": "", "properties": {"name": "John"}}::vertex]::path |
| [{"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex, {"id": 4785074604081156, "label": "knows", "end_id": 281474976710668, "start_id": 281474976710667, "properties": {}}::edge, {"id": 281474976710668, "label": "", "properties": {"name": "John"}}::vertex, {"id": 4785074604081155, "label": "knows", "end_id": 281474976710667, "start_id": 281474976710668, "properties": {}}::edge, {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex]::path |
| [{"id": 281474976710668, "label": "", "properties": {"name": "John"}}::vertex, {"id": 4785074604081156, "label": "knows", "end_id": 281474976710668, "start_id": 281474976710667, "properties": {}}::edge, {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex, {"id": 4785074604081155, "label": "knows", "end_id": 281474976710667, "start_id": 281474976710668, "properties": {}}::edge, {"id": 281474976710668, "label": "", "properties": {"name": "John"}}::vertex]::path |
| (4 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ MATCH p=(u)-[]->()-[]->(u) RETURN p $$)as (p agtype); |
| p |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [{"id": 281474976710668, "label": "", "properties": {"name": "John"}}::vertex, {"id": 4785074604081155, "label": "knows", "end_id": 281474976710667, "start_id": 281474976710668, "properties": {}}::edge, {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex, {"id": 4785074604081156, "label": "knows", "end_id": 281474976710668, "start_id": 281474976710667, "properties": {}}::edge, {"id": 281474976710668, "label": "", "properties": {"name": "John"}}::vertex]::path |
| [{"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex, {"id": 4785074604081156, "label": "knows", "end_id": 281474976710668, "start_id": 281474976710667, "properties": {}}::edge, {"id": 281474976710668, "label": "", "properties": {"name": "John"}}::vertex, {"id": 4785074604081155, "label": "knows", "end_id": 281474976710667, "start_id": 281474976710668, "properties": {}}::edge, {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex]::path |
| (2 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ MATCH p=(a)-[]->()-[]->(a {name: "Dave"}) RETURN p $$)as (p agtype); |
| p |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [{"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex, {"id": 4785074604081156, "label": "knows", "end_id": 281474976710668, "start_id": 281474976710667, "properties": {}}::edge, {"id": 281474976710668, "label": "", "properties": {"name": "John"}}::vertex, {"id": 4785074604081155, "label": "knows", "end_id": 281474976710667, "start_id": 281474976710668, "properties": {}}::edge, {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex]::path |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ MATCH p=(a)-[]->()-[]->(a {name: "John"}) RETURN p $$)as (p agtype); |
| p |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [{"id": 281474976710668, "label": "", "properties": {"name": "John"}}::vertex, {"id": 4785074604081155, "label": "knows", "end_id": 281474976710667, "start_id": 281474976710668, "properties": {}}::edge, {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex, {"id": 4785074604081156, "label": "knows", "end_id": 281474976710668, "start_id": 281474976710667, "properties": {}}::edge, {"id": 281474976710668, "label": "", "properties": {"name": "John"}}::vertex]::path |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ MATCH p=(a {name: "Dave"})-[]->()-[]->(a {name: "Dave"}) RETURN p $$)as (p agtype); |
| p |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [{"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex, {"id": 4785074604081156, "label": "knows", "end_id": 281474976710668, "start_id": 281474976710667, "properties": {}}::edge, {"id": 281474976710668, "label": "", "properties": {"name": "John"}}::vertex, {"id": 4785074604081155, "label": "knows", "end_id": 281474976710667, "start_id": 281474976710668, "properties": {}}::edge, {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex]::path |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ MATCH p=(a {name: "John"})-[]->()-[]->(a {name: "John"}) RETURN p $$)as (p agtype); |
| p |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [{"id": 281474976710668, "label": "", "properties": {"name": "John"}}::vertex, {"id": 4785074604081155, "label": "knows", "end_id": 281474976710667, "start_id": 281474976710668, "properties": {}}::edge, {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex, {"id": 4785074604081156, "label": "knows", "end_id": 281474976710668, "start_id": 281474976710667, "properties": {}}::edge, {"id": 281474976710668, "label": "", "properties": {"name": "John"}}::vertex]::path |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ MATCH p=(a {name: "Dave"})-[]->()-[]->(a) RETURN p $$)as (p agtype); |
| p |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [{"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex, {"id": 4785074604081156, "label": "knows", "end_id": 281474976710668, "start_id": 281474976710667, "properties": {}}::edge, {"id": 281474976710668, "label": "", "properties": {"name": "John"}}::vertex, {"id": 4785074604081155, "label": "knows", "end_id": 281474976710667, "start_id": 281474976710668, "properties": {}}::edge, {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex]::path |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ MATCH p=(a {name: "John"})-[]->()-[]->(a) RETURN p $$)as (p agtype); |
| p |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [{"id": 281474976710668, "label": "", "properties": {"name": "John"}}::vertex, {"id": 4785074604081155, "label": "knows", "end_id": 281474976710667, "start_id": 281474976710668, "properties": {}}::edge, {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex, {"id": 4785074604081156, "label": "knows", "end_id": 281474976710668, "start_id": 281474976710667, "properties": {}}::edge, {"id": 281474976710668, "label": "", "properties": {"name": "John"}}::vertex]::path |
| (1 row) |
| |
| -- these are illegal and should fail |
| SELECT * FROM cypher('cypher_match', $$ MATCH p=(a)-[b]->()-[b:knows]->(a) RETURN p $$)as (p agtype); |
| ERROR: duplicate edge variable 'b' within a clause |
| LINE 1: ...ROM cypher('cypher_match', $$ MATCH p=(a)-[b]->()-[b:knows]-... |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ MATCH p=(a)-[b]->()-[b]->(a) RETURN p $$)as (p agtype); |
| ERROR: duplicate edge variable 'b' within a clause |
| LINE 1: ...ROM cypher('cypher_match', $$ MATCH p=(a)-[b]->()-[b]->(a) R... |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ MATCH p=(a)-[b:knows]->()-[b:knows]->(a) RETURN p $$)as (p agtype); |
| ERROR: duplicate edge variable 'b' within a clause |
| LINE 1: ...pher('cypher_match', $$ MATCH p=(a)-[b:knows]->()-[b:knows]-... |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ MATCH p=(a)-[b:knows]->()-[b]->(a) RETURN p $$)as (p agtype); |
| ERROR: duplicate edge variable 'b' within a clause |
| LINE 1: ...pher('cypher_match', $$ MATCH p=(a)-[b:knows]->()-[b]->(a) R... |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ MATCH p=(p) RETURN p $$)as (p agtype); |
| ERROR: variable "p" is for a path |
| LINE 1: SELECT * FROM cypher('cypher_match', $$ MATCH p=(p) RETURN p... |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ MATCH p=(p)-[]->() RETURN p $$)as (p agtype); |
| ERROR: variable "p" is for a path |
| LINE 1: SELECT * FROM cypher('cypher_match', $$ MATCH p=(p)-[]->() R... |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ MATCH p=()-[p]->() RETURN p $$)as (p agtype); |
| ERROR: variable "p" is for a path |
| LINE 1: ...ELECT * FROM cypher('cypher_match', $$ MATCH p=()-[p]->() RE... |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ MATCH p=() MATCH (p) RETURN p $$)as (p agtype); |
| ERROR: variable 'p' is for a path |
| LINE 1: ... FROM cypher('cypher_match', $$ MATCH p=() MATCH (p) RETURN ... |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ MATCH p=() MATCH (p)-[]->() RETURN p $$)as (p agtype); |
| ERROR: variable 'p' is for a path |
| LINE 1: ... FROM cypher('cypher_match', $$ MATCH p=() MATCH (p)-[]->() ... |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ MATCH p=() MATCH ()-[p]->() RETURN p $$)as (p agtype); |
| ERROR: variable 'p' is for a path |
| LINE 1: ...ROM cypher('cypher_match', $$ MATCH p=() MATCH ()-[p]->() RE... |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ MATCH (p) MATCH p=() RETURN p $$)as (p agtype); |
| ERROR: variable "p" already exists |
| LINE 1: ... * FROM cypher('cypher_match', $$ MATCH (p) MATCH p=() RETUR... |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ MATCH ()-[p]->() MATCH p=() RETURN p $$)as (p agtype); |
| ERROR: variable "p" already exists |
| LINE 1: ... cypher('cypher_match', $$ MATCH ()-[p]->() MATCH p=() RETUR... |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ MATCH ()-[p *]-()-[p]-() RETURN 0 $$)as (p agtype); |
| ERROR: variable 'p' is for a VLE edge |
| LINE 1: ... FROM cypher('cypher_match', $$ MATCH ()-[p *]-()-[p]-() RET... |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ CREATE (p) WITH p MATCH p=() RETURN p $$)as (p agtype); |
| ERROR: variable "p" already exists |
| LINE 1: ...cypher('cypher_match', $$ CREATE (p) WITH p MATCH p=() RETUR... |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ CREATE p=() WITH p MATCH (p) RETURN p $$)as (p agtype); |
| ERROR: variable 'p' already exists |
| LINE 1: ...pher('cypher_match', $$ CREATE p=() WITH p MATCH (p) RETURN ... |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ CREATE ()-[p:knows]->() WITH p MATCH p=() RETURN p $$)as (p agtype); |
| ERROR: variable "p" already exists |
| LINE 1: ...r_match', $$ CREATE ()-[p:knows]->() WITH p MATCH p=() RETUR... |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ CREATE p=() WITH p MATCH ()-[p]->() RETURN p $$)as (p agtype); |
| ERROR: variable 'p' already exists |
| LINE 1: ...er('cypher_match', $$ CREATE p=() WITH p MATCH ()-[p]->() RE... |
| ^ |
| -- |
| -- Default alias check (issue #883) |
| -- |
| SELECT * FROM cypher('cypher_match', $$ MATCH (_) RETURN _ $$) as (a agtype); |
| a |
| ------------------------------------------------------------------------------------------ |
| {"id": 281474976710662, "label": "", "properties": {"i": 1, "j": 2, "k": 3}}::vertex |
| {"id": 281474976710663, "label": "", "properties": {"i": 1, "j": 3}}::vertex |
| {"id": 281474976710664, "label": "", "properties": {"i": 2, "k": 3}}::vertex |
| {"id": 281474976710665, "label": "", "properties": {"age": 4}}::vertex |
| {"id": 281474976710666, "label": "", "properties": {"age": 6}}::vertex |
| {"id": 281474976710660, "label": "", "properties": {"age": 4, "name": "F"}}::vertex |
| {"id": 281474976710661, "label": "", "properties": {"age": 4, "name": "T"}}::vertex |
| {"id": 281474976710659, "label": "", "properties": {"age": 3, "name": "orphan"}}::vertex |
| {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex |
| {"id": 281474976710668, "label": "", "properties": {"name": "John"}}::vertex |
| (10 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ MATCH () MATCH (_{name: "Dave"}) RETURN 0 $$) as (a agtype); |
| a |
| --- |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| (10 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ MATCH () MATCH (_{name: "Dave"}) RETURN _ $$) as (a agtype); |
| a |
| ------------------------------------------------------------------------------ |
| {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex |
| {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex |
| {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex |
| {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex |
| {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex |
| {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex |
| {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex |
| {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex |
| {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex |
| {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex |
| (10 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ MATCH (my_age_default_{name: "Dave"}) RETURN my_age_default_$$) as (a agtype); |
| a |
| ------------------------------------------------------------------------------ |
| {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$ MATCH () MATCH (my_age_default_{name: "Dave"}) RETURN my_age_default_$$) as (a agtype); |
| a |
| ------------------------------------------------------------------------------ |
| {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex |
| {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex |
| {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex |
| {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex |
| {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex |
| {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex |
| {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex |
| {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex |
| {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex |
| {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex |
| (10 rows) |
| |
| -- these should fail as they are prefixed with _age_default_ which is only for internal use |
| SELECT * FROM cypher('cypher_match', $$ MATCH (_age_default_) RETURN _age_default_ $$) as (a agtype); |
| ERROR: _age_default_ is only for internal use |
| LINE 1: SELECT * FROM cypher('cypher_match', $$ MATCH (_age_default_... |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ MATCH (_age_default_a) RETURN _age_default_a $$) as (a agtype); |
| ERROR: _age_default_ is only for internal use |
| LINE 1: SELECT * FROM cypher('cypher_match', $$ MATCH (_age_default_... |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ MATCH (_age_default_whatever) RETURN 0 $$) as (a agtype); |
| ERROR: _age_default_ is only for internal use |
| LINE 1: SELECT * FROM cypher('cypher_match', $$ MATCH (_age_default_... |
| ^ |
| -- issue 876 |
| SELECT * FROM cypher('cypher_match', $$ MATCH ({name: "Dave"}) MATCH ({name: "Dave"}) MATCH ({name: "Dave"}) RETURN 0 $$) as (a agtype); |
| a |
| --- |
| 0 |
| (1 row) |
| |
| SELECT * FROM cypher('cypher_match', $$MATCH ({n0:0}) MATCH ()-[]->() MATCH ({n1:0})-[]-() RETURN 0 AS n2$$) as (a agtype); |
| a |
| --- |
| (0 rows) |
| |
| -- |
| -- self referencing property constraints (issue #898) |
| -- |
| SELECT * FROM cypher('cypher_match', $$ MATCH (a {name:a.name}) RETURN a $$) as (a agtype); |
| a |
| ------------------------------------------------------------------------------------------ |
| {"id": 281474976710660, "label": "", "properties": {"age": 4, "name": "F"}}::vertex |
| {"id": 281474976710661, "label": "", "properties": {"age": 4, "name": "T"}}::vertex |
| {"id": 281474976710659, "label": "", "properties": {"age": 3, "name": "orphan"}}::vertex |
| {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex |
| {"id": 281474976710668, "label": "", "properties": {"name": "John"}}::vertex |
| (5 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ MATCH (a {name:a.name, age:a.age}) RETURN a $$) as (a agtype); |
| a |
| ------------------------------------------------------------------------------------------ |
| {"id": 281474976710660, "label": "", "properties": {"age": 4, "name": "F"}}::vertex |
| {"id": 281474976710661, "label": "", "properties": {"age": 4, "name": "T"}}::vertex |
| {"id": 281474976710659, "label": "", "properties": {"age": 3, "name": "orphan"}}::vertex |
| (3 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ MATCH (a {name:a.name}) MATCH (a {age:a.age}) RETURN a $$) as (a agtype); |
| a |
| ------------------------------------------------------------------------------------------ |
| {"id": 281474976710660, "label": "", "properties": {"age": 4, "name": "F"}}::vertex |
| {"id": 281474976710661, "label": "", "properties": {"age": 4, "name": "T"}}::vertex |
| {"id": 281474976710659, "label": "", "properties": {"age": 3, "name": "orphan"}}::vertex |
| (3 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ MATCH p=(a)-[u {relationship: u.relationship}]->(b) RETURN p $$) as (a agtype); |
| a |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [{"id": 281474976710661, "label": "", "properties": {"age": 4, "name": "T"}}::vertex, {"id": 4785074604081153, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710661, "properties": {"years": 3, "relationship": "friends"}}::edge, {"id": 281474976710666, "label": "", "properties": {"age": 6}}::vertex]::path |
| [{"id": 281474976710659, "label": "", "properties": {"age": 3, "name": "orphan"}}::vertex, {"id": 4785074604081154, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710659, "properties": {"years": 4, "relationship": "enemies"}}::edge, {"id": 281474976710666, "label": "", "properties": {"age": 6}}::vertex]::path |
| (2 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ MATCH p=(a)-[u {relationship: u.relationship, years: u.years}]->(b) RETURN p $$) as (a agtype); |
| a |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [{"id": 281474976710661, "label": "", "properties": {"age": 4, "name": "T"}}::vertex, {"id": 4785074604081153, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710661, "properties": {"years": 3, "relationship": "friends"}}::edge, {"id": 281474976710666, "label": "", "properties": {"age": 6}}::vertex]::path |
| [{"id": 281474976710659, "label": "", "properties": {"age": 3, "name": "orphan"}}::vertex, {"id": 4785074604081154, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710659, "properties": {"years": 4, "relationship": "enemies"}}::edge, {"id": 281474976710666, "label": "", "properties": {"age": 6}}::vertex]::path |
| (2 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ MATCH p=(a {name:a.name})-[u {relationship: u.relationship}]->(b {age:b.age}) RETURN p $$) as (a agtype); |
| a |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [{"id": 281474976710661, "label": "", "properties": {"age": 4, "name": "T"}}::vertex, {"id": 4785074604081153, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710661, "properties": {"years": 3, "relationship": "friends"}}::edge, {"id": 281474976710666, "label": "", "properties": {"age": 6}}::vertex]::path |
| [{"id": 281474976710659, "label": "", "properties": {"age": 3, "name": "orphan"}}::vertex, {"id": 4785074604081154, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710659, "properties": {"years": 4, "relationship": "enemies"}}::edge, {"id": 281474976710666, "label": "", "properties": {"age": 6}}::vertex]::path |
| (2 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ CREATE () WITH * MATCH (x{n0:x.n1}) RETURN 0 $$) as (a agtype); |
| a |
| --- |
| (0 rows) |
| |
| -- these should fail due to multiple labels for a variable |
| SELECT * FROM cypher('cypher_match', $$ MATCH p=(x)-[]->(x:R) RETURN p, x $$) AS (p agtype, x agtype); |
| ERROR: multiple labels for variable 'x' are not supported |
| LINE 1: ...* FROM cypher('cypher_match', $$ MATCH p=(x)-[]->(x:R) RETUR... |
| ^ |
| SELECT * FROM cypher('cypher_match', $$ MATCH p=(x:r)-[]->(x:R) RETURN p, x $$) AS (p agtype, x agtype); |
| ERROR: multiple labels for variable 'x' are not supported |
| LINE 1: ...FROM cypher('cypher_match', $$ MATCH p=(x:r)-[]->(x:R) RETUR... |
| ^ |
| -- |
| -- Test age.enable_containment configuration parameter |
| -- |
| -- Test queries are run before and after switching off this parameter. |
| -- When on, the containment operator should be used to filter properties. |
| -- When off, the access operator should be used. |
| -- |
| SELECT create_graph('test_enable_containment'); |
| NOTICE: graph "test_enable_containment" has been created |
| create_graph |
| -------------- |
| |
| (1 row) |
| |
| SELECT * FROM cypher('test_enable_containment', |
| $$ |
| CREATE (x:Customer { |
| name: 'Bob', |
| school: { |
| name: 'XYZ College', |
| program: { |
| major: 'Psyc', |
| degree: 'BSc' |
| } |
| }, |
| phone: [ 123456789, 987654321, 456987123 ], |
| addr: [ |
| {city: 'Vancouver', street: 30}, |
| {city: 'Toronto', street: 40} |
| ] |
| }) |
| RETURN x |
| $$) as (a agtype); |
| a |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| {"id": 844424930131969, "label": "Customer", "properties": {"addr": [{"city": "Vancouver", "street": 30}, {"city": "Toronto", "street": 40}], "name": "Bob", "phone": [123456789, 987654321, 456987123], "school": {"name": "XYZ College", "program": {"major": "Psyc", "degree": "BSc"}}}}::vertex |
| (1 row) |
| |
| -- With enable_containment on |
| SET age.enable_containment = on; |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {addr:[{city:'Toronto'}]}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 1 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {addr:[{city:'Toronto'}, {city: 'Vancouver'}]}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 1 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {addr:[{city:'Alberta'}]}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 0 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {school:{program:{major:'Psyc'}}}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 1 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {name:'Bob',school:{program:{degree:'BSc'}}}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 1 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {school:{program:{major:'Cs'}}}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 0 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {name:'Bob',school:{program:{degree:'PHd'}}}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 0 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {phone:[987654321]}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 1 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {phone:[654765876]}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 0 |
| (1 row) |
| |
| SELECT * FROM cypher('test_enable_containment', $$ EXPLAIN (COSTS OFF) MATCH (x:Customer {school:{name:'XYZ',program:{degree:'BSc'}},phone:[987654321],parents:{}}) RETURN x $$) as (a agtype); |
| QUERY PLAN |
| ------------------------------------------------------------------------------------------------------------------------------------ |
| Seq Scan on "Customer" x |
| Filter: (properties @> '{"phone": [987654321], "school": {"name": "XYZ", "program": {"degree": "BSc"}}, "parents": {}}'::agtype) |
| (2 rows) |
| |
| -- Previous set of queries, with enable_containment off |
| SET age.enable_containment = off; |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {addr:[{city:'Toronto'}]}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 1 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {addr:[{city:'Toronto'}, {city: 'Vancouver'}]}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 1 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {addr:[{city:'Alberta'}]}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 0 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {school:{program:{major:'Psyc'}}}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 1 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {name:'Bob',school:{program:{degree:'BSc'}}}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 1 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {school:{program:{major:'Cs'}}}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 0 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {name:'Bob',school:{program:{degree:'PHd'}}}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 0 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {phone:[987654321]}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 1 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {phone:[654765876]}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 0 |
| (1 row) |
| |
| SELECT * FROM cypher('test_enable_containment', $$ EXPLAIN (COSTS OFF) MATCH (x:Customer {school:{name:'XYZ',program:{degree:'BSc'}},phone:[987654321],parents:{}}) RETURN x $$) as (a agtype); |
| QUERY PLAN |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Seq Scan on "Customer" x |
| Filter: ((agtype_access_operator(VARIADIC ARRAY[properties, '"school"'::agtype, '"name"'::agtype]) = '"XYZ"'::agtype) AND (agtype_access_operator(VARIADIC ARRAY[properties, '"school"'::agtype, '"program"'::agtype, '"degree"'::agtype]) = '"BSc"'::agtype) AND (agtype_access_operator(VARIADIC ARRAY[properties, '"phone"'::agtype]) @> '[987654321]'::agtype) AND (agtype_access_operator(VARIADIC ARRAY[properties, '"parents"'::agtype]) @> '{}'::agtype)) |
| (2 rows) |
| |
| -- |
| -- Issue 945 |
| -- |
| SELECT create_graph('issue_945'); |
| NOTICE: graph "issue_945" has been created |
| create_graph |
| -------------- |
| |
| (1 row) |
| |
| SELECT * FROM cypher('issue_945', $$ |
| CREATE (a:Part {part_num: '123'}), |
| (b:Part {part_num: '345'}), |
| (c:Part {part_num: '456'}), |
| (d:Part {part_num: '789'}) |
| $$) as (result agtype); |
| result |
| -------- |
| (0 rows) |
| |
| -- should match 4 |
| SELECT * FROM cypher('issue_945', $$ |
| MATCH (a:Part) RETURN a |
| $$) as (result agtype); |
| result |
| ------------------------------------------------------------------------------------- |
| {"id": 844424930131969, "label": "Part", "properties": {"part_num": "123"}}::vertex |
| {"id": 844424930131970, "label": "Part", "properties": {"part_num": "345"}}::vertex |
| {"id": 844424930131971, "label": "Part", "properties": {"part_num": "456"}}::vertex |
| {"id": 844424930131972, "label": "Part", "properties": {"part_num": "789"}}::vertex |
| (4 rows) |
| |
| -- each should return 4 |
| SELECT * FROM cypher('issue_945', $$ MATCH (:Part) RETURN count(*) $$) as (result agtype); |
| result |
| -------- |
| 4 |
| (1 row) |
| |
| SELECT * FROM cypher('issue_945', $$ MATCH (a:Part) RETURN count(*) $$) as (result agtype); |
| result |
| -------- |
| 4 |
| (1 row) |
| |
| -- each should return 4 rows of 0 |
| SELECT * FROM cypher('issue_945', $$ MATCH (:Part) RETURN 0 $$) as (result agtype); |
| result |
| -------- |
| 0 |
| 0 |
| 0 |
| 0 |
| (4 rows) |
| |
| SELECT * FROM cypher('issue_945', $$ MATCH (a:Part) RETURN 0 $$) as (result agtype); |
| result |
| -------- |
| 0 |
| 0 |
| 0 |
| 0 |
| (4 rows) |
| |
| -- each should return 16 rows of 0 |
| SELECT * FROM cypher('issue_945', $$ MATCH (:Part) MATCH (:Part) RETURN 0 $$) as (result agtype); |
| result |
| -------- |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| (16 rows) |
| |
| SELECT * FROM cypher('issue_945', $$ MATCH (a:Part) MATCH (:Part) RETURN 0 $$) as (result agtype); |
| result |
| -------- |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| (16 rows) |
| |
| SELECT * FROM cypher('issue_945', $$ MATCH (:Part) MATCH (b:Part) RETURN 0 $$) as (result agtype); |
| result |
| -------- |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| (16 rows) |
| |
| SELECT * FROM cypher('issue_945', $$ MATCH (a:Part) MATCH (b:Part) RETURN 0 $$) as (result agtype); |
| result |
| -------- |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| (16 rows) |
| |
| -- each should return a count of 16 |
| SELECT * FROM cypher('issue_945', $$ MATCH (:Part) MATCH (:Part) RETURN count(*) $$) as (result agtype); |
| result |
| -------- |
| 16 |
| (1 row) |
| |
| SELECT * FROM cypher('issue_945', $$ MATCH (a:Part) MATCH (:Part) RETURN count(*) $$) as (result agtype); |
| result |
| -------- |
| 16 |
| (1 row) |
| |
| SELECT * FROM cypher('issue_945', $$ MATCH (:Part) MATCH (b:Part) RETURN count(*) $$) as (result agtype); |
| result |
| -------- |
| 16 |
| (1 row) |
| |
| SELECT * FROM cypher('issue_945', $$ MATCH (a:Part) MATCH (b:Part) RETURN count(*) $$) as (result agtype); |
| result |
| -------- |
| 16 |
| (1 row) |
| |
| -- |
| -- Issue 1045 |
| -- |
| SELECT * FROM cypher('cypher_match', $$ MATCH p=()-[*]->() RETURN length(p) $$) as (length agtype); |
| length |
| -------- |
| 1 |
| 2 |
| 1 |
| 1 |
| 1 |
| 2 |
| 1 |
| 2 |
| (8 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ MATCH p=()-[*]->() WHERE length(p) > 1 RETURN length(p) $$) as (length agtype); |
| length |
| -------- |
| 2 |
| 2 |
| 2 |
| (3 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ MATCH p=()-[*]->() WHERE size(nodes(p)) = 3 RETURN nodes(p)[0] $$) as (nodes agtype); |
| nodes |
| ----------------------------------------------------------------------------------------------------- |
| {"id": 281474976710660, "label": "_ag_label_vertex", "properties": {"age": 4, "name": "F"}}::vertex |
| {"id": 281474976710667, "label": "_ag_label_vertex", "properties": {"name": "Dave"}}::vertex |
| {"id": 281474976710668, "label": "_ag_label_vertex", "properties": {"name": "John"}}::vertex |
| (3 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ MATCH (n {name:'Dave'}) MATCH p=()-[*]->() WHERE nodes(p)[0] = n RETURN length(p) $$) as (length agtype); |
| length |
| -------- |
| 1 |
| 2 |
| (2 rows) |
| |
| SELECT * FROM cypher('cypher_match', $$ MATCH p1=(n {name:'Dave'})-[]->() MATCH p2=()-[*]->() WHERE p2=p1 RETURN p2=p1 $$) as (path agtype); |
| path |
| ------ |
| true |
| (1 row) |
| |
| -- |
| -- Issue 1399 EXISTS leads to an error if a relation label does not exists as database table |
| -- |
| SELECT create_graph('issue_1399'); |
| NOTICE: graph "issue_1399" has been created |
| create_graph |
| -------------- |
| |
| (1 row) |
| |
| -- this is an empty graph so these should return 0 |
| SELECT * FROM cypher('issue_1399', $$ |
| MATCH (foo) |
| WHERE EXISTS((foo)-[]->()) |
| RETURN foo |
| $$) as (c agtype); |
| c |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('issue_1399', $$ |
| MATCH (foo) |
| WHERE NOT EXISTS((foo)-[]->()) |
| RETURN foo |
| $$) as (c agtype); |
| c |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('issue_1399', $$ |
| MATCH (foo) |
| WHERE EXISTS((foo)-[:BAR]->()) |
| RETURN foo |
| $$) as (c agtype); |
| c |
| --- |
| (0 rows) |
| |
| SELECT * FROM cypher('issue_1399', $$ |
| MATCH (foo) |
| WHERE NOT EXISTS((foo)-[:BAR]->()) |
| RETURN foo |
| $$) as (c agtype); |
| c |
| --- |
| (0 rows) |
| |
| -- this is an empty graph so these should return false |
| SELECT * FROM cypher('issue_1399', $$ |
| MATCH (foo) |
| WHERE EXISTS((foo)-[]->()) |
| RETURN count(foo) > 0 |
| $$) as (c agtype); |
| c |
| ------- |
| false |
| (1 row) |
| |
| SELECT * FROM cypher('issue_1399', $$ |
| MATCH (foo) |
| WHERE NOT EXISTS((foo)-[]->()) |
| RETURN count(foo) > 0 |
| $$) as (c agtype); |
| c |
| ------- |
| false |
| (1 row) |
| |
| SELECT * FROM cypher('issue_1399', $$ |
| MATCH (foo) |
| WHERE EXISTS((foo)-[:BAR]->()) |
| RETURN count(foo) > 0 |
| $$) as (c agtype); |
| c |
| ------- |
| false |
| (1 row) |
| |
| SELECT * FROM cypher('issue_1399', $$ |
| MATCH (foo) |
| WHERE NOT EXISTS((foo)-[:BAR]->()) |
| RETURN count(foo) > 0 |
| $$) as (c agtype); |
| c |
| ------- |
| false |
| (1 row) |
| |
| -- create 1 path |
| SELECT * FROM cypher('issue_1399', $$ |
| CREATE (foo)-[:BAR]->() RETURN foo |
| $$) as (c agtype); |
| c |
| ---------------------------------------------------------------- |
| {"id": 281474976710657, "label": "", "properties": {}}::vertex |
| (1 row) |
| |
| -- these should each return 1 row as it is a directed edge and |
| -- only one vertex can match. |
| SELECT * FROM cypher('issue_1399', $$ |
| MATCH (foo) |
| WHERE EXISTS((foo)-[]->()) |
| RETURN foo |
| $$) as (c agtype); |
| c |
| ---------------------------------------------------------------- |
| {"id": 281474976710657, "label": "", "properties": {}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('issue_1399', $$ |
| MATCH (foo) |
| WHERE NOT EXISTS((foo)-[]->()) |
| RETURN foo |
| $$) as (c agtype); |
| c |
| ---------------------------------------------------------------- |
| {"id": 281474976710658, "label": "", "properties": {}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('issue_1399', $$ |
| MATCH (foo) |
| WHERE EXISTS((foo)-[:BAR]->()) |
| RETURN foo |
| $$) as (c agtype); |
| c |
| ---------------------------------------------------------------- |
| {"id": 281474976710657, "label": "", "properties": {}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('issue_1399', $$ |
| MATCH (foo) |
| WHERE NOT EXISTS((foo)-[:BAR]->()) |
| RETURN foo |
| $$) as (c agtype); |
| c |
| ---------------------------------------------------------------- |
| {"id": 281474976710658, "label": "", "properties": {}}::vertex |
| (1 row) |
| |
| -- this should return 0 rows as it can't exist - that path isn't in BAR2 |
| SELECT * FROM cypher('issue_1399', $$ |
| MATCH (foo) |
| WHERE EXISTS((foo)-[:BAR2]->()) |
| RETURN foo |
| $$) as (c agtype); |
| c |
| --- |
| (0 rows) |
| |
| -- this should return 2 rows as they all exist |
| SELECT * FROM cypher('issue_1399', $$ |
| MATCH (foo) |
| WHERE NOT EXISTS((foo)-[:BAR2]->()) |
| RETURN foo |
| $$) as (c agtype); |
| c |
| ---------------------------------------------------------------- |
| {"id": 281474976710657, "label": "", "properties": {}}::vertex |
| {"id": 281474976710658, "label": "", "properties": {}}::vertex |
| (2 rows) |
| |
| -- Issue 1393 EXISTS doesn't see previous clauses' variables |
| SELECT FROM create_graph('issue_1393'); |
| NOTICE: graph "issue_1393" has been created |
| -- |
| (1 row) |
| |
| SELECT * FROM cypher('issue_1393', $$ |
| CREATE (n1:Object) RETURN n1 |
| $$) AS (n1 agtype); |
| n1 |
| ---------------------------------------------------------------------- |
| {"id": 844424930131969, "label": "Object", "properties": {}}::vertex |
| (1 row) |
| |
| -- vertex cases |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object) MATCH (n2:Object) WHERE EXISTS((n1)-[]->(n2)) RETURN n1,n2 |
| $$) AS (n1 agtype, n2 agtype); |
| n1 | n2 |
| ----+---- |
| (0 rows) |
| |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object) MATCH (n2:Object) WHERE EXISTS((n1:Object)-[]->(n2:Object)) RETURN n1,n2 |
| $$) AS (n1 agtype, n2 agtype); |
| n1 | n2 |
| ----+---- |
| (0 rows) |
| |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object) MATCH (n2:Object) WHERE NOT EXISTS((n1)-[]->(n2)) RETURN n1,n2 |
| $$) AS (n1 agtype, n2 agtype); |
| n1 | n2 |
| ----------------------------------------------------------------------+---------------------------------------------------------------------- |
| {"id": 844424930131969, "label": "Object", "properties": {}}::vertex | {"id": 844424930131969, "label": "Object", "properties": {}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object) MATCH (n2:Object) WHERE NOT EXISTS((n1:Object)-[]->(n2:Object)) RETURN n1,n2 |
| $$) AS (n1 agtype, n2 agtype); |
| n1 | n2 |
| ----------------------------------------------------------------------+---------------------------------------------------------------------- |
| {"id": 844424930131969, "label": "Object", "properties": {}}::vertex | {"id": 844424930131969, "label": "Object", "properties": {}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object) MATCH (n2:Object) WHERE EXISTS((n1)-[]->()) RETURN n1,n2 |
| $$) AS (n1 agtype, n2 agtype); |
| n1 | n2 |
| ----+---- |
| (0 rows) |
| |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object) MATCH (n2:Object) WHERE NOT EXISTS((n1)-[]->()) RETURN n1,n2 |
| $$) AS (n1 agtype, n2 agtype); |
| n1 | n2 |
| ----------------------------------------------------------------------+---------------------------------------------------------------------- |
| {"id": 844424930131969, "label": "Object", "properties": {}}::vertex | {"id": 844424930131969, "label": "Object", "properties": {}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('issue_1393', $$ |
| CREATE (n1:Object)-[e:knows]->(n2:Object) RETURN n1, e, n2 |
| $$) AS (n1 agtype, e agtype, n2 agtype); |
| n1 | e | n2 |
| ----------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------- |
| {"id": 844424930131970, "label": "Object", "properties": {}}::vertex | {"id": 1125899906842625, "label": "knows", "end_id": 844424930131971, "start_id": 844424930131970, "properties": {}}::edge | {"id": 844424930131971, "label": "Object", "properties": {}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object) MATCH (n2:Object) WHERE EXISTS((n1)-[]->(n2)) RETURN n1,n2 |
| $$) AS (n1 agtype, n2 agtype); |
| n1 | n2 |
| ----------------------------------------------------------------------+---------------------------------------------------------------------- |
| {"id": 844424930131970, "label": "Object", "properties": {}}::vertex | {"id": 844424930131971, "label": "Object", "properties": {}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object) MATCH (n2:Object) WHERE EXISTS((n1:Object)-[]->(n2:Object)) RETURN n1,n2 |
| $$) AS (n1 agtype, n2 agtype); |
| n1 | n2 |
| ----------------------------------------------------------------------+---------------------------------------------------------------------- |
| {"id": 844424930131970, "label": "Object", "properties": {}}::vertex | {"id": 844424930131971, "label": "Object", "properties": {}}::vertex |
| (1 row) |
| |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object) MATCH (n2:Object) WHERE NOT EXISTS((n1)-[]->(n2)) RETURN n1,n2 |
| $$) AS (n1 agtype, n2 agtype); |
| n1 | n2 |
| ----------------------------------------------------------------------+---------------------------------------------------------------------- |
| {"id": 844424930131969, "label": "Object", "properties": {}}::vertex | {"id": 844424930131969, "label": "Object", "properties": {}}::vertex |
| {"id": 844424930131969, "label": "Object", "properties": {}}::vertex | {"id": 844424930131970, "label": "Object", "properties": {}}::vertex |
| {"id": 844424930131969, "label": "Object", "properties": {}}::vertex | {"id": 844424930131971, "label": "Object", "properties": {}}::vertex |
| {"id": 844424930131970, "label": "Object", "properties": {}}::vertex | {"id": 844424930131969, "label": "Object", "properties": {}}::vertex |
| {"id": 844424930131970, "label": "Object", "properties": {}}::vertex | {"id": 844424930131970, "label": "Object", "properties": {}}::vertex |
| {"id": 844424930131971, "label": "Object", "properties": {}}::vertex | {"id": 844424930131969, "label": "Object", "properties": {}}::vertex |
| {"id": 844424930131971, "label": "Object", "properties": {}}::vertex | {"id": 844424930131970, "label": "Object", "properties": {}}::vertex |
| {"id": 844424930131971, "label": "Object", "properties": {}}::vertex | {"id": 844424930131971, "label": "Object", "properties": {}}::vertex |
| (8 rows) |
| |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object) MATCH (n2:Object) WHERE NOT EXISTS((n1:Object)-[]->(n2:Object)) RETURN n1,n2 |
| $$) AS (n1 agtype, n2 agtype); |
| n1 | n2 |
| ----------------------------------------------------------------------+---------------------------------------------------------------------- |
| {"id": 844424930131969, "label": "Object", "properties": {}}::vertex | {"id": 844424930131969, "label": "Object", "properties": {}}::vertex |
| {"id": 844424930131969, "label": "Object", "properties": {}}::vertex | {"id": 844424930131970, "label": "Object", "properties": {}}::vertex |
| {"id": 844424930131969, "label": "Object", "properties": {}}::vertex | {"id": 844424930131971, "label": "Object", "properties": {}}::vertex |
| {"id": 844424930131970, "label": "Object", "properties": {}}::vertex | {"id": 844424930131969, "label": "Object", "properties": {}}::vertex |
| {"id": 844424930131970, "label": "Object", "properties": {}}::vertex | {"id": 844424930131970, "label": "Object", "properties": {}}::vertex |
| {"id": 844424930131971, "label": "Object", "properties": {}}::vertex | {"id": 844424930131969, "label": "Object", "properties": {}}::vertex |
| {"id": 844424930131971, "label": "Object", "properties": {}}::vertex | {"id": 844424930131970, "label": "Object", "properties": {}}::vertex |
| {"id": 844424930131971, "label": "Object", "properties": {}}::vertex | {"id": 844424930131971, "label": "Object", "properties": {}}::vertex |
| (8 rows) |
| |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object) MATCH (n2:Object) WHERE EXISTS((n1)-[]->()) RETURN n1,n2 |
| $$) AS (n1 agtype, n2 agtype); |
| n1 | n2 |
| ----------------------------------------------------------------------+---------------------------------------------------------------------- |
| {"id": 844424930131970, "label": "Object", "properties": {}}::vertex | {"id": 844424930131969, "label": "Object", "properties": {}}::vertex |
| {"id": 844424930131970, "label": "Object", "properties": {}}::vertex | {"id": 844424930131970, "label": "Object", "properties": {}}::vertex |
| {"id": 844424930131970, "label": "Object", "properties": {}}::vertex | {"id": 844424930131971, "label": "Object", "properties": {}}::vertex |
| (3 rows) |
| |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object) MATCH (n2:Object) WHERE NOT EXISTS((n1)-[]->()) RETURN n1,n2 |
| $$) AS (n1 agtype, n2 agtype); |
| n1 | n2 |
| ----------------------------------------------------------------------+---------------------------------------------------------------------- |
| {"id": 844424930131969, "label": "Object", "properties": {}}::vertex | {"id": 844424930131969, "label": "Object", "properties": {}}::vertex |
| {"id": 844424930131971, "label": "Object", "properties": {}}::vertex | {"id": 844424930131969, "label": "Object", "properties": {}}::vertex |
| {"id": 844424930131969, "label": "Object", "properties": {}}::vertex | {"id": 844424930131970, "label": "Object", "properties": {}}::vertex |
| {"id": 844424930131971, "label": "Object", "properties": {}}::vertex | {"id": 844424930131970, "label": "Object", "properties": {}}::vertex |
| {"id": 844424930131969, "label": "Object", "properties": {}}::vertex | {"id": 844424930131971, "label": "Object", "properties": {}}::vertex |
| {"id": 844424930131971, "label": "Object", "properties": {}}::vertex | {"id": 844424930131971, "label": "Object", "properties": {}}::vertex |
| (6 rows) |
| |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object) MATCH (n2:Object) WHERE EXISTS((n1:Object)-[]->()) RETURN n1,n2 |
| $$) AS (n1 agtype, n2 agtype); |
| n1 | n2 |
| ----------------------------------------------------------------------+---------------------------------------------------------------------- |
| {"id": 844424930131970, "label": "Object", "properties": {}}::vertex | {"id": 844424930131969, "label": "Object", "properties": {}}::vertex |
| {"id": 844424930131970, "label": "Object", "properties": {}}::vertex | {"id": 844424930131970, "label": "Object", "properties": {}}::vertex |
| {"id": 844424930131970, "label": "Object", "properties": {}}::vertex | {"id": 844424930131971, "label": "Object", "properties": {}}::vertex |
| (3 rows) |
| |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object) MATCH (n2:Object) WHERE NOT EXISTS((n1:Object)-[]->()) RETURN n1,n2 |
| $$) AS (n1 agtype, n2 agtype); |
| n1 | n2 |
| ----------------------------------------------------------------------+---------------------------------------------------------------------- |
| {"id": 844424930131969, "label": "Object", "properties": {}}::vertex | {"id": 844424930131969, "label": "Object", "properties": {}}::vertex |
| {"id": 844424930131971, "label": "Object", "properties": {}}::vertex | {"id": 844424930131969, "label": "Object", "properties": {}}::vertex |
| {"id": 844424930131969, "label": "Object", "properties": {}}::vertex | {"id": 844424930131970, "label": "Object", "properties": {}}::vertex |
| {"id": 844424930131971, "label": "Object", "properties": {}}::vertex | {"id": 844424930131970, "label": "Object", "properties": {}}::vertex |
| {"id": 844424930131969, "label": "Object", "properties": {}}::vertex | {"id": 844424930131971, "label": "Object", "properties": {}}::vertex |
| {"id": 844424930131971, "label": "Object", "properties": {}}::vertex | {"id": 844424930131971, "label": "Object", "properties": {}}::vertex |
| (6 rows) |
| |
| -- should error |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object) MATCH (n2:Object) WHERE EXISTS((n1:object)-[]->()) RETURN n1,n2 |
| $$) AS (n1 agtype, n2 agtype); |
| ERROR: multiple labels for variable 'n1' are not supported |
| LINE 2: ...MATCH (n1:Object) MATCH (n2:Object) WHERE EXISTS((n1:object)... |
| ^ |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object) MATCH (n2:Object) WHERE NOT EXISTS((n1:object)-[]->()) RETURN n1,n2 |
| $$) AS (n1 agtype, n2 agtype); |
| ERROR: multiple labels for variable 'n1' are not supported |
| LINE 2: ...H (n1:Object) MATCH (n2:Object) WHERE NOT EXISTS((n1:object)... |
| ^ |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object) MATCH (n2:Object) WHERE NOT EXISTS((n1)-[e]->()) RETURN n1,n2,e |
| $$) AS (n1 agtype, n2 agtype, e agtype); |
| ERROR: variable `e` does not exist |
| LINE 2: ...1:Object) MATCH (n2:Object) WHERE NOT EXISTS((n1)-[e]->()) R... |
| ^ |
| -- edge cases |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object)-[e1:knows]->() MATCH (n2:Object) WHERE EXISTS((n1)-[e1]->(n2)) RETURN e1 |
| $$) AS (e1 agtype); |
| e1 |
| ---------------------------------------------------------------------------------------------------------------------------- |
| {"id": 1125899906842625, "label": "knows", "end_id": 844424930131971, "start_id": 844424930131970, "properties": {}}::edge |
| (1 row) |
| |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object)-[e1:knows]->() MATCH (n2:Object) WHERE EXISTS((n1:Object)-[e1:knows]->(n2:Object)) RETURN e1 |
| $$) AS (e1 agtype); |
| e1 |
| ---------------------------------------------------------------------------------------------------------------------------- |
| {"id": 1125899906842625, "label": "knows", "end_id": 844424930131971, "start_id": 844424930131970, "properties": {}}::edge |
| (1 row) |
| |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object)-[e1:knows]->() MATCH (n2:Object) WHERE NOT EXISTS((n1)-[e1]->(n2)) RETURN e1 |
| $$) AS (e1 agtype); |
| e1 |
| ---------------------------------------------------------------------------------------------------------------------------- |
| {"id": 1125899906842625, "label": "knows", "end_id": 844424930131971, "start_id": 844424930131970, "properties": {}}::edge |
| {"id": 1125899906842625, "label": "knows", "end_id": 844424930131971, "start_id": 844424930131970, "properties": {}}::edge |
| (2 rows) |
| |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object)-[e1:knows]->() MATCH (n2:Object) WHERE NOT EXISTS((n1:Object)-[e1:knows]->(n2:Object)) RETURN e1 |
| $$) AS (e1 agtype); |
| e1 |
| ---------------------------------------------------------------------------------------------------------------------------- |
| {"id": 1125899906842625, "label": "knows", "end_id": 844424930131971, "start_id": 844424930131970, "properties": {}}::edge |
| {"id": 1125899906842625, "label": "knows", "end_id": 844424930131971, "start_id": 844424930131970, "properties": {}}::edge |
| (2 rows) |
| |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object)-[e1:knows]->() MATCH (n2:Object) WHERE EXISTS((n1)-[e1]->()) RETURN e1 |
| $$) AS (e1 agtype); |
| e1 |
| ---------------------------------------------------------------------------------------------------------------------------- |
| {"id": 1125899906842625, "label": "knows", "end_id": 844424930131971, "start_id": 844424930131970, "properties": {}}::edge |
| {"id": 1125899906842625, "label": "knows", "end_id": 844424930131971, "start_id": 844424930131970, "properties": {}}::edge |
| {"id": 1125899906842625, "label": "knows", "end_id": 844424930131971, "start_id": 844424930131970, "properties": {}}::edge |
| (3 rows) |
| |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object)-[e1:knows]->() MATCH (n2:Object) WHERE EXISTS((n1:Object)-[e1:knows]->(n2:Object)) RETURN e1 |
| $$) AS (e1 agtype); |
| e1 |
| ---------------------------------------------------------------------------------------------------------------------------- |
| {"id": 1125899906842625, "label": "knows", "end_id": 844424930131971, "start_id": 844424930131970, "properties": {}}::edge |
| (1 row) |
| |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object)-[e1:knows]->() MATCH (n2:Object) WHERE NOT EXISTS((n1)-[e1]->()) RETURN e1 |
| $$) AS (e1 agtype); |
| e1 |
| ---- |
| (0 rows) |
| |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object)-[e1:knows]->() MATCH (n2:Object) WHERE NOT EXISTS((n1:Object)-[e1:knows]->(n2:Object)) RETURN e1 |
| $$) AS (e1 agtype); |
| e1 |
| ---------------------------------------------------------------------------------------------------------------------------- |
| {"id": 1125899906842625, "label": "knows", "end_id": 844424930131971, "start_id": 844424930131970, "properties": {}}::edge |
| {"id": 1125899906842625, "label": "knows", "end_id": 844424930131971, "start_id": 844424930131970, "properties": {}}::edge |
| (2 rows) |
| |
| -- should error |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object)-[e1:knows]->() MATCH (n2:Object) WHERE EXISTS((n1:Object)-[e1:Knows]->(n2:Object)) RETURN e1 |
| $$) AS (e1 agtype); |
| ERROR: multiple labels for variable 'e1' are not supported |
| LINE 2: ...s]->() MATCH (n2:Object) WHERE EXISTS((n1:Object)-[e1:Knows]... |
| ^ |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object)-[e1:knows]->() MATCH (n2:Object) WHERE NOT EXISTS((n1:Object)-[e1:Knows]->(n2:Object)) RETURN e1 |
| $$) AS (e1 agtype); |
| ERROR: multiple labels for variable 'e1' are not supported |
| LINE 2: ...() MATCH (n2:Object) WHERE NOT EXISTS((n1:Object)-[e1:Knows]... |
| ^ |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object)-[e1:knows]->() MATCH (n2:Object) WHERE EXISTS((e1:Object)-[e1:Knows]->(n2:Object)) RETURN e1 |
| $$) AS (e1 agtype); |
| ERROR: variable 'e1' is for an edge |
| LINE 2: ...t)-[e1:knows]->() MATCH (n2:Object) WHERE EXISTS((e1:Object)... |
| ^ |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object)-[e1:knows]->() MATCH (n2:Object) WHERE NOT EXISTS((n1:Object)-[e1:knows]->(e1)) RETURN e1 |
| $$) AS (e1 agtype); |
| ERROR: variable 'e1' is for an edge |
| LINE 2: ...Object) WHERE NOT EXISTS((n1:Object)-[e1:knows]->(e1)) RETUR... |
| ^ |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object)-[e1:knows]->() MATCH (n2:Object) WHERE NOT EXISTS((n1:Object)-[e1:knows]->(e2)) RETURN e1 |
| $$) AS (e1 agtype); |
| ERROR: variable `e2` does not exist |
| LINE 2: ...Object) WHERE NOT EXISTS((n1:Object)-[e1:knows]->(e2)) RETUR... |
| ^ |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH p=(n1:Object)-[e1:knows]->() MATCH (n2:Object) WHERE EXISTS((n1:Object)-[p]->(e2)) RETURN e1 |
| $$) AS (e1 agtype); |
| ERROR: variable 'p' is for a path |
| LINE 2: ...s]->() MATCH (n2:Object) WHERE EXISTS((n1:Object)-[p]->(e2))... |
| ^ |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH p=(n1)-[e1]->() MATCH (n2) WHERE EXISTS((n1)-[p]->(e2)) RETURN p |
| $$) AS (e1 agtype); |
| ERROR: variable 'p' is for a path |
| LINE 2: ...ATCH p=(n1)-[e1]->() MATCH (n2) WHERE EXISTS((n1)-[p]->(e2))... |
| ^ |
| -- long cases |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1) MATCH (n2) MATCH (n1)-[e1]->() MATCH (n2)<-[e2]-(n1) MATCH (n3) |
| WHERE EXISTS((n3)-[e1]->(n2)) RETURN n1,n2,n3,e1 |
| $$) AS (n1 agtype, n2 agtype, n3 agtype, e1 agtype); |
| n1 | n2 | n3 | e1 |
| ----------------------------------------------------------------------+----------------------------------------------------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------- |
| {"id": 844424930131970, "label": "Object", "properties": {}}::vertex | {"id": 844424930131971, "label": "Object", "properties": {}}::vertex | {"id": 844424930131970, "label": "Object", "properties": {}}::vertex | {"id": 1125899906842625, "label": "knows", "end_id": 844424930131971, "start_id": 844424930131970, "properties": {}}::edge |
| (1 row) |
| |
| SELECT * FROM cypher('issue_1393', $$ |
| MATCH (n1:Object) MATCH (n2:Object) MATCH (n1)-[e1:knows]->() MATCH (n2)<-[e2:knows]-(n1) MATCH (n3:Object) |
| WHERE EXISTS((n3:Object)-[e1:knows]->(n2:Object)) RETURN n1,n2,n3,e1 |
| $$) AS (n1 agtype, n2 agtype, n3 agtype, e1 agtype); |
| n1 | n2 | n3 | e1 |
| ----------------------------------------------------------------------+----------------------------------------------------------------------+----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------- |
| {"id": 844424930131970, "label": "Object", "properties": {}}::vertex | {"id": 844424930131971, "label": "Object", "properties": {}}::vertex | {"id": 844424930131970, "label": "Object", "properties": {}}::vertex | {"id": 1125899906842625, "label": "knows", "end_id": 844424930131971, "start_id": 844424930131970, "properties": {}}::edge |
| (1 row) |
| |
| -- |
| -- Issue 1461 |
| -- |
| -- Using the test_enable_containment graph for these tests |
| SELECT * FROM cypher('test_enable_containment', $$ CREATE p=(:Customer)-[:bought {store:'Amazon', addr:{city: 'Vancouver', street: 30}}]->(y:Product) RETURN p $$) as (a agtype); |
| a |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [{"id": 844424930131970, "label": "Customer", "properties": {}}::vertex, {"id": 1125899906842625, "label": "bought", "end_id": 1407374883553281, "start_id": 844424930131970, "properties": {"addr": {"city": "Vancouver", "street": 30}, "store": "Amazon"}}::edge, {"id": 1407374883553281, "label": "Product", "properties": {}}::vertex]::path |
| (1 row) |
| |
| -- With enable_containment on |
| SET age.enable_containment = on; |
| -- Should return 0 |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer ={addr:[{city:'Toronto'}]}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 0 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer ={school:{program:{major:'Psyc'}}}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 0 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer ={name:'Bob',school:{program:{degree:'BSc'}}}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 0 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer ={school:{program:{major:'Cs'}}}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 0 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer ={name:'Bob',school:{program:{degree:'PHd'}}}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 0 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer ={phone:[987654321]}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 0 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer ={phone:[654765876]}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 0 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x)-[:bought ={store: 'Amazon', addr:{city: 'Vancouver'}}]->() RETURN x $$) as (a agtype); |
| count |
| ------- |
| 0 |
| (1 row) |
| |
| -- Should return 1 |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer ={addr: [{city: 'Vancouver', street: 30},{city: 'Toronto', street: 40}]}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 1 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer ={school: { name: 'XYZ College',program: { major: 'Psyc', degree: 'BSc'}}}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 1 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer ={phone: [ 123456789, 987654321, 456987123 ]}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 1 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer ={school: { name: 'XYZ College',program: { major: 'Psyc', degree: 'BSc'} },phone: [ 123456789, 987654321, 456987123 ]}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 1 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH p=(x:Customer)-[:bought ={store: 'Amazon'}]->() RETURN p $$) as (a agtype); |
| count |
| ------- |
| 1 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH p=(x:Customer)-[:bought ={store: 'Amazon', addr:{city: 'Vancouver', street: 30}}]->() RETURN p $$) as (a agtype); |
| count |
| ------- |
| 1 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH p=(x:Customer)-[:bought {store: 'Amazon', addr:{city: 'Vancouver'}}]->() RETURN p $$) as (a agtype); |
| count |
| ------- |
| 1 |
| (1 row) |
| |
| SELECT * FROM cypher('test_enable_containment', $$ EXPLAIN (costs off) MATCH (x:Customer)-[:bought ={store: 'Amazon', addr:{city: 'Vancouver', street: 30}}]->(y:Product) RETURN 0 $$) as (a agtype); |
| QUERY PLAN |
| ------------------------------------------------------------------------------------------------------------------------------- |
| Hash Join |
| Hash Cond: (y.id = _age_default_alias_0.end_id) |
| -> Seq Scan on "Product" y |
| -> Hash |
| -> Hash Join |
| Hash Cond: (x.id = _age_default_alias_0.start_id) |
| -> Seq Scan on "Customer" x |
| -> Hash |
| -> Seq Scan on bought _age_default_alias_0 |
| Filter: (properties @>> '{"addr": {"city": "Vancouver", "street": 30}, "store": "Amazon"}'::agtype) |
| (10 rows) |
| |
| SELECT * FROM cypher('test_enable_containment', $$ EXPLAIN (costs off) MATCH (x:Customer ={school: { name: 'XYZ College',program: { major: 'Psyc', degree: 'BSc'} },phone: [ 123456789, 987654321, 456987123 ]}) RETURN 0 $$) as (a agtype); |
| QUERY PLAN |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Seq Scan on "Customer" x |
| Filter: (properties @>> '{"phone": [123456789, 987654321, 456987123], "school": {"name": "XYZ College", "program": {"major": "Psyc", "degree": "BSc"}}}'::agtype) |
| (2 rows) |
| |
| -- With enable_containment off |
| SET age.enable_containment = off; |
| -- Should return 0 |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer ={addr:[{city:'Toronto'}]}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 0 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer ={school:{program:{major:'Psyc'}}}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 0 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer ={name:'Bob',school:{program:{degree:'BSc'}}}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 0 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer ={school:{program:{major:'Cs'}}}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 0 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer ={name:'Bob',school:{program:{degree:'PHd'}}}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 0 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer ={phone:[987654321]}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 0 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer ={phone:[654765876]}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 0 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x)-[:bought ={store: 'Amazon', addr:{city: 'Vancouver'}}]->() RETURN x $$) as (a agtype); |
| count |
| ------- |
| 0 |
| (1 row) |
| |
| -- Should return 1 |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer ={addr: [{city: 'Vancouver', street: 30},{city: 'Toronto', street: 40}]}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 1 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer ={school: { name: 'XYZ College',program: { major: 'Psyc', degree: 'BSc'}}}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 1 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer ={phone: [ 123456789, 987654321, 456987123 ]}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 1 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer ={school: { name: 'XYZ College',program: { major: 'Psyc', degree: 'BSc'} },phone: [ 123456789, 987654321, 456987123 ]}) RETURN x $$) as (a agtype); |
| count |
| ------- |
| 1 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH p=(x:Customer)-[:bought ={store: 'Amazon'}]->() RETURN p $$) as (a agtype); |
| count |
| ------- |
| 1 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH p=(x:Customer)-[:bought ={store: 'Amazon', addr:{city: 'Vancouver', street: 30}}]->() RETURN p $$) as (a agtype); |
| count |
| ------- |
| 1 |
| (1 row) |
| |
| SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH p=(x:Customer)-[:bought {store: 'Amazon', addr:{city: 'Vancouver'}}]->() RETURN p $$) as (a agtype); |
| count |
| ------- |
| 1 |
| (1 row) |
| |
| SELECT * FROM cypher('test_enable_containment', $$ EXPLAIN (costs off) MATCH (x:Customer)-[:bought ={store: 'Amazon', addr:{city: 'Vancouver', street: 30}}]->(y:Product) RETURN 0 $$) as (a agtype); |
| QUERY PLAN |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Hash Join |
| Hash Cond: (y.id = _age_default_alias_0.end_id) |
| -> Seq Scan on "Product" y |
| -> Hash |
| -> Hash Join |
| Hash Cond: (x.id = _age_default_alias_0.start_id) |
| -> Seq Scan on "Customer" x |
| -> Hash |
| -> Seq Scan on bought _age_default_alias_0 |
| Filter: ((agtype_access_operator(VARIADIC ARRAY[properties, '"store"'::agtype]) = '"Amazon"'::agtype) AND (agtype_access_operator(VARIADIC ARRAY[properties, '"addr"'::agtype]) = '{"city": "Vancouver", "street": 30}'::agtype)) |
| (10 rows) |
| |
| SELECT * FROM cypher('test_enable_containment', $$ EXPLAIN (costs off) MATCH (x:Customer ={school: { name: 'XYZ College',program: { major: 'Psyc', degree: 'BSc'} },phone: [ 123456789, 987654321, 456987123 ]}) RETURN 0 $$) as (a agtype); |
| QUERY PLAN |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Seq Scan on "Customer" x |
| Filter: ((agtype_access_operator(VARIADIC ARRAY[properties, '"school"'::agtype]) = '{"name": "XYZ College", "program": {"major": "Psyc", "degree": "BSc"}}'::agtype) AND (agtype_access_operator(VARIADIC ARRAY[properties, '"phone"'::agtype]) = '[123456789, 987654321, 456987123]'::agtype)) |
| (2 rows) |
| |
| -- |
| -- Clean up |
| -- |
| SELECT drop_graph('cypher_match', true); |
| NOTICE: drop cascades to 17 other objects |
| DETAIL: drop cascades to table cypher_match._ag_label_vertex |
| drop cascades to table cypher_match._ag_label_edge |
| drop cascades to table cypher_match.v |
| drop cascades to table cypher_match.v1 |
| drop cascades to table cypher_match.e1 |
| drop cascades to table cypher_match.v2 |
| drop cascades to table cypher_match.e2 |
| drop cascades to table cypher_match.v3 |
| drop cascades to table cypher_match.e3 |
| drop cascades to table cypher_match.loop |
| drop cascades to table cypher_match.self |
| drop cascades to table cypher_match.duplicate |
| drop cascades to table cypher_match.dup_edge |
| drop cascades to table cypher_match.other_v |
| drop cascades to table cypher_match.opt_match_v |
| drop cascades to table cypher_match.opt_match_e |
| drop cascades to table cypher_match.knows |
| NOTICE: graph "cypher_match" has been dropped |
| drop_graph |
| ------------ |
| |
| (1 row) |
| |
| SELECT drop_graph('test_retrieve_var', true); |
| NOTICE: drop cascades to 5 other objects |
| DETAIL: drop cascades to table test_retrieve_var._ag_label_vertex |
| drop cascades to table test_retrieve_var._ag_label_edge |
| drop cascades to table test_retrieve_var."A" |
| drop cascades to table test_retrieve_var.incs |
| drop cascades to table test_retrieve_var."C" |
| NOTICE: graph "test_retrieve_var" has been dropped |
| drop_graph |
| ------------ |
| |
| (1 row) |
| |
| SELECT drop_graph('test_enable_containment', true); |
| NOTICE: drop cascades to 5 other objects |
| DETAIL: drop cascades to table test_enable_containment._ag_label_vertex |
| drop cascades to table test_enable_containment._ag_label_edge |
| drop cascades to table test_enable_containment."Customer" |
| drop cascades to table test_enable_containment.bought |
| drop cascades to table test_enable_containment."Product" |
| NOTICE: graph "test_enable_containment" has been dropped |
| drop_graph |
| ------------ |
| |
| (1 row) |
| |
| SELECT drop_graph('issue_945', true); |
| NOTICE: drop cascades to 3 other objects |
| DETAIL: drop cascades to table issue_945._ag_label_vertex |
| drop cascades to table issue_945._ag_label_edge |
| drop cascades to table issue_945."Part" |
| NOTICE: graph "issue_945" has been dropped |
| drop_graph |
| ------------ |
| |
| (1 row) |
| |
| SELECT drop_graph('issue_1399', true); |
| NOTICE: drop cascades to 3 other objects |
| DETAIL: drop cascades to table issue_1399._ag_label_vertex |
| drop cascades to table issue_1399._ag_label_edge |
| drop cascades to table issue_1399."BAR" |
| NOTICE: graph "issue_1399" has been dropped |
| drop_graph |
| ------------ |
| |
| (1 row) |
| |
| SELECT drop_graph('issue_1393', true); |
| NOTICE: drop cascades to 4 other objects |
| DETAIL: drop cascades to table issue_1393._ag_label_vertex |
| drop cascades to table issue_1393._ag_label_edge |
| drop cascades to table issue_1393."Object" |
| drop cascades to table issue_1393.knows |
| NOTICE: graph "issue_1393" has been dropped |
| drop_graph |
| ------------ |
| |
| (1 row) |
| |
| -- |
| -- End |
| -- |