This is an automated email from the ASF dual-hosted git repository.

dehowef pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-age.git


The following commit(s) were added to refs/heads/master by this push:
     new 2eae974  Add cast assignment for SKIP and LIMIT clauses
2eae974 is described below

commit 2eae974be1aab2f35c675b1fbb641a1800ea7171
Author: Dehowe Feng <[email protected]>
AuthorDate: Tue Apr 13 11:15:12 2021 -0700

    Add cast assignment for SKIP and LIMIT clauses
    
    Added a cast assignment to fix SKIP and LIMIT clauses. Before, they
    were passed agtype when they needed an int type.
    
    Wrote regression tests for SKIP and LIMIT clauses.
---
 age--0.4.0.sql                    |  3 +-
 regress/expected/cypher_match.out | 73 +++++++++++++++++++++++++++++++++++++++
 regress/sql/cypher_match.sql      | 25 ++++++++++++++
 3 files changed, 100 insertions(+), 1 deletion(-)

diff --git a/age--0.4.0.sql b/age--0.4.0.sql
index 895d7d5..fe50462 100644
--- a/age--0.4.0.sql
+++ b/age--0.4.0.sql
@@ -2545,7 +2545,8 @@ PARALLEL SAFE
 AS 'MODULE_PATHNAME';
 
 CREATE CAST (agtype AS bigint)
-WITH FUNCTION ag_catalog.agtype_to_int8(variadic "any");
+WITH FUNCTION ag_catalog.agtype_to_int8(variadic "any")
+AS ASSIGNMENT;
 
 -- agtype -> int4
 CREATE FUNCTION ag_catalog.agtype_to_int4(variadic "any")
diff --git a/regress/expected/cypher_match.out 
b/regress/expected/cypher_match.out
index f9055b1..fae6d67 100644
--- a/regress/expected/cypher_match.out
+++ b/regress/expected/cypher_match.out
@@ -817,6 +817,79 @@ $$) AS (i agtype);
 (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)
+
+--
 -- Clean up
 --
 SELECT drop_graph('cypher_match', true);
diff --git a/regress/sql/cypher_match.sql b/regress/sql/cypher_match.sql
index 3211f70..377dc40 100644
--- a/regress/sql/cypher_match.sql
+++ b/regress/sql/cypher_match.sql
@@ -430,6 +430,31 @@ SELECT * FROM cypher('cypher_match', $$
        RETURN DISTINCT p
 $$) AS (i agtype);
 
+--
+-- Limit
+--
+SELECT * FROM cypher('cypher_match', $$
+       MATCH (u)
+       RETURN u
+$$) AS (i agtype);
+
+SELECT * FROM cypher('cypher_match', $$
+       MATCH (u)
+       RETURN u LIMIT 3
+$$) AS (i agtype);
+
+--
+-- Skip
+--
+SELECT * FROM cypher('cypher_match', $$
+       MATCH (u)
+       RETURN u SKIP 7
+$$) AS (i agtype);
+
+SELECT * FROM cypher('cypher_match', $$
+       MATCH (u)
+       RETURN u SKIP 7 LIMIT 3
+$$) AS (i agtype);
 
 --
 -- Clean up

Reply via email to