GFQL Operator Reference#
This reference outlines the operators available in GFQL for constructing predicates in your graph queries. These operators are wrappers around Pandas/cuDF functions, allowing you to express complex filtering conditions intuitively. See the API reference documentation for more details on individual operators.
Operators#
The following table lists the available operators, their descriptions, and examples of how to use them in GFQL.
WHERE Operators (Cross-Reference)#
This page covers predicate functions used inside step filters like
n({...}) and e_forward({...}). WHERE operators are documented separately:
Same-path MATCH WHERE uses
compare(col(...), op, col(...))withopin==,!=,<,<=,>,>=.Row-pipeline WHERE uses
where_rows(expr="...")with comparators=,!=,<>,<,<=,>,>=.
See GFQL WHERE (Same-Path Constraints) (same-path constraints) and GFQL RETURN (Row Pipelines)
(MATCH ... RETURN row pipelines).
Numeric and Comparison Operators
Operator |
Description |
Example |
|---|---|---|
|
Greater than |
|
|
Less than |
|
|
Greater than or equal to |
|
|
Less than or equal to |
|
|
Equal to |
|
|
Not equal to |
|
|
Between |
|
Note
Null handling and temporal comparisons are separate:
Use
isna()/notna()for null-safe checks: -n({ "closed_at": isna() })-n({ "created_at": notna() })Use comparison operators for non-null values (including temporal columns): - DateTime:
n({ "created_at": gt(pd.Timestamp("2023-01-01 12:00:00")) })- Date:n({ "event_date": eq(date(2023, 6, 15)) })- Time:n({ "daily_time": between(time(9, 0), time(17, 0)) })
See Working with Dates and Times for datetime filtering examples.
Categorical Operators
Operator |
Description |
Example |
|---|---|---|
|
Value is in |
|
|
Marks duplicated values. |
|
String Operators
Operator |
Description |
Example |
|---|---|---|
|
String contains |
|
|
String starts with |
|
|
String ends with |
|
|
String matches regex |
|
|
String matches regex |
|
|
String is numeric. |
|
|
String is alphabetic. |
|
|
String is digit characters. |
|
|
String is lowercase. |
|
|
String is uppercase. |
|
|
String contains only whitespace. |
|
|
String is alphanumeric. |
|
|
String is decimal characters. |
|
|
String is title-cased. |
|
Null and NA Operators
Operator |
Description |
Example |
|---|---|---|
|
Value is NA/NaN. |
|
|
Value is not NA/NaN. |
|
|
Alias for |
|
|
Alias for |
|
Temporal Operators
Operator |
Description |
Example |
|---|---|---|
|
Date is the first day of the month. |
|
|
Date is the last day of the month. |
|
|
Date is the first day of the quarter. |
|
|
Date is the last day of the quarter. |
|
|
Date is the first day of the year. |
|
|
Date is the last day of the year. |
|
|
Date is in a leap year. |
|
Usage Examples#
Example 1: Filtering Nodes with Numeric Conditions
from graphistry import n, gt, lt
# Find nodes where age is greater than 18 and less than 30
g_filtered = g.chain([
n({ "age": gt(18) }),
n({ "age": lt(30) })
])
Example 2: Filtering Nodes by Category
from graphistry import n, is_in
# Find nodes of type 'person' or 'company'
g_filtered = g.chain([
n({ "type": is_in(["person", "company"]) })
])
Example 3: Filtering Edges with String Conditions
from graphistry import e_forward, contains
# Find edges where the relation contains 'friend'
g_filtered = g.chain([
e_forward({ "relation": contains("friend") })
])
Example 4: Combining Multiple Predicates
from graphistry import n, eq, gt
# Find 'person' nodes with age greater than 18
g_filtered = g.chain([
n({
"type": eq("person"),
"age": gt(18)
})
])
Example 5: Same-Path Constraint with WHERE
from graphistry import n, e_forward, col, compare
g_filtered = g.gfql(
[
n({"type": "account"}, name="a"),
e_forward(),
n({"type": "user"}, name="c"),
],
where=[compare(col("a", "owner_id"), "==", col("c", "owner_id"))],
)
Additional Notes#
Predicate Functions: Use predicate instances for filter conditions.
n({ "score": gt(50) })
For compound conditions (e.g.,
score > 50 AND score is even), use aquerystring instead:n(query="score > 50 and score % 2 == 0")
Note
Lambda functions in
filter_dict(e.g.,n({"score": lambda x: ...})) are no longer supported becausefilter_dictvalues must be JSON-serializable for the wire protocol and remote execution. Use predicates likegt(),between(), orquery=strings for compound conditions.Importing Operators: Remember to import the necessary functions.
from graphistry import n, e_forward, gt, contains
Combining Conditions: Use range predicates or
querystrings for complex expressions.# Range predicate n({ "age": between(19, 64) }) # Or equivalently with a query string n(query="age > 18 and age < 65")
Predicates Module: Operators are available in the graphistry.predicates module.