Skip to content

Commit

Permalink
Add path extraction(#>, #>>)operators to agtype (apache#1224)
Browse files Browse the repository at this point in the history
Original work was done by Josh Innis for issue#282.

The changes included in this PR are as follows:

- Implement the path extraction operators for agtype, similar
  to the one in postgres where this operator works with jsonb operands
- Allow using these operators inside cypher queries
- Added regression tests
  • Loading branch information
Zainab-Saad committed Sep 19, 2023
1 parent 10903b9 commit dc82449
Show file tree
Hide file tree
Showing 8 changed files with 1,287 additions and 13 deletions.
30 changes: 30 additions & 0 deletions age--1.4.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2924,6 +2924,36 @@ CREATE OPERATOR ->> (
FUNCTION = ag_catalog.agtype_array_element_text
);

CREATE FUNCTION ag_catalog.agtype_extract_path(agtype, agtype)
RETURNS agtype
LANGUAGE c
IMMUTABLE
RETURNS NULL ON NULL INPUT
PARALLEL SAFE
AS 'MODULE_PATHNAME';

-- return the extracted path as agtype
CREATE OPERATOR #> (
LEFTARG = agtype,
RIGHTARG = agtype,
FUNCTION = ag_catalog.agtype_extract_path
);

CREATE FUNCTION ag_catalog.agtype_extract_path_text(agtype, agtype)
RETURNS text
LANGUAGE c
IMMUTABLE
RETURNS NULL ON NULL INPUT
PARALLEL SAFE
AS 'MODULE_PATHNAME';

-- return the extracted path as text
CREATE OPERATOR #>> (
LEFTARG = agtype,
RIGHTARG = agtype,
FUNCTION = ag_catalog.agtype_extract_path_text
);

--
-- Contains operators @> <@
--
Expand Down
Loading

0 comments on commit dc82449

Please sign in to comment.