Predicate functions and user defined functions in Apache age

In this blog we will discuss some of the predicate functions and then user defined functions.

Predicate functions

Predicates are boolean functions that return true or false for a given set of input. They are most commonly used to filter out…


This content originally appeared on DEV Community and was authored by Talha Munir 🇵🇸

In this blog we will discuss some of the predicate functions and then user defined functions.

Predicate functions

Predicates are boolean functions that return true or false for a given set of input. They are most commonly used to filter out subgraphs in the WHERE part of a query.

Some of the predicate functions are explained below:

Exists():

Exists here returns true if the specified property is existing in the graphs, node and relationships.

Syntax:

exists(property)

It returns an agtype boolean value.

Query:

SELECT *
FROM cypher('graph_name', $$
     MATCH (n)
     WHERE exists(n.surname)
     RETURN n.first_name, n.last_name
$$) as (first_name agtype, last_name agtype);

Exists(path):

Exists(path) returns true if a path already exists there.

Syntax:

Exists(path)

Query:

SELECT *
FROM cypher('graph_name', $$
     MATCH (n)
     WHERE exists(n)-[]-(name: 'Willem Defoe')
     RETURN n.full_name
$$) as (full_name agtype);

User Defined functions:

In apache age users can add their custom functions to age. When we use cypher function calls we use default namespace of age catalog. A function can be used outside the name space and this can be done by adding namespace before the function name.

Syntax:

namespace_name.function_name

Query:

SELECT *
FROM cypher('graph_name', $$
RETURN pg_catalog.square(5)
$$ as (result agtype);

The above query will return square of the number 5.


This content originally appeared on DEV Community and was authored by Talha Munir 🇵🇸


Print Share Comment Cite Upload Translate Updates
APA

Talha Munir 🇵🇸 | Sciencx (2023-05-22T04:32:32+00:00) Predicate functions and user defined functions in Apache age. Retrieved from https://www.scien.cx/2023/05/22/predicate-functions-and-user-defined-functions-in-apache-age/

MLA
" » Predicate functions and user defined functions in Apache age." Talha Munir 🇵🇸 | Sciencx - Monday May 22, 2023, https://www.scien.cx/2023/05/22/predicate-functions-and-user-defined-functions-in-apache-age/
HARVARD
Talha Munir 🇵🇸 | Sciencx Monday May 22, 2023 » Predicate functions and user defined functions in Apache age., viewed ,<https://www.scien.cx/2023/05/22/predicate-functions-and-user-defined-functions-in-apache-age/>
VANCOUVER
Talha Munir 🇵🇸 | Sciencx - » Predicate functions and user defined functions in Apache age. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/05/22/predicate-functions-and-user-defined-functions-in-apache-age/
CHICAGO
" » Predicate functions and user defined functions in Apache age." Talha Munir 🇵🇸 | Sciencx - Accessed . https://www.scien.cx/2023/05/22/predicate-functions-and-user-defined-functions-in-apache-age/
IEEE
" » Predicate functions and user defined functions in Apache age." Talha Munir 🇵🇸 | Sciencx [Online]. Available: https://www.scien.cx/2023/05/22/predicate-functions-and-user-defined-functions-in-apache-age/. [Accessed: ]
rf:citation
» Predicate functions and user defined functions in Apache age | Talha Munir 🇵🇸 | Sciencx | https://www.scien.cx/2023/05/22/predicate-functions-and-user-defined-functions-in-apache-age/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.