Bug description
Writing a Cypher query that unions a boolean expression with a constant literal — e.g. RETURN true IS NOT NULL AS x UNION RETURN true AS x — makes AGE generate a PostgreSQL UNION whose branch types do not match: the boolean expression is compiled to a native boolean, while the constant branch remains agtype. PostgreSQL rejects the whole query at parse time with error 42804 UNION types boolean and agtype cannot be matched. The statement is valid Cypher (it returns true in Neo4j) and is rejected before producing any result.
Access method
- Command line via
psql, inside the official Docker container apache/age:1.8.0
Data setup
No data is required — the error reproduces on an empty graph. Only the graph itself must exist:
CREATE EXTENSION IF NOT EXISTS age;
LOAD 'age';
SET search_path = ag_catalog, "$user", public;
SELECT create_graph('graph_test');
Configuration
- None beyond the stock AGE extension. No additional modules (no PostGIS, etc.), default
search_path handling as shown above.
Command that triggers the error
SELECT * FROM cypher('graph_test', $$ RETURN true IS NOT NULL AS x UNION RETURN true AS x $$) AS (a agtype);
ERROR: UNION types boolean and agtype cannot be matched
LINE 1: ... true IS NOT NULL AS x UNION RETURN true AS x
^
The same error also occurs:
- with other boolean-only expressions in place of
true IS NOT NULL, e.g. RETURN NOT true AS x UNION RETURN true AS x, RETURN true IN [true] AS x UNION RETURN true AS x, RETURN true AND false AS x UNION RETURN true AS x;
- with an unparenthesized comparison in one branch, e.g.
RETURN 1 = 1 AS x UNION RETURN true AS x;
- regardless of which branch holds the boolean expression, e.g.
RETURN true AS x UNION RETURN true IS NOT NULL AS x (message: UNION types agtype and boolean cannot be matched);
- without aliases, e.g.
RETURN true IS NOT NULL UNION RETURN true.
Only unions whose branches are all agtype already work, e.g. RETURN true AS x UNION RETURN true AS x. The inferred branch type depends on expression shape rather than on the Cypher result type:
RETURN (1 = 1) AS x UNION RETURN true AS x succeeds,
- while the same comparison without parentheses (
RETURN 1 = 1 AS x UNION RETURN true AS x) fails.
Environment
- Version: 1.8.0 (official
apache/age:1.8.0 Docker image)
- PostgreSQL: 18.1 (Debian 18.1-1.pgdg13+2), x86_64
Bug description
Writing a Cypher query that unions a boolean expression with a constant literal — e.g.
RETURN true IS NOT NULL AS x UNION RETURN true AS x— makes AGE generate a PostgreSQL UNION whose branch types do not match: the boolean expression is compiled to a nativeboolean, while the constant branch remainsagtype. PostgreSQL rejects the whole query at parse time with error 42804UNION types boolean and agtype cannot be matched. The statement is valid Cypher (it returnstruein Neo4j) and is rejected before producing any result.Access method
psql, inside the official Docker containerapache/age:1.8.0Data setup
No data is required — the error reproduces on an empty graph. Only the graph itself must exist:
Configuration
search_pathhandling as shown above.Command that triggers the error
The same error also occurs:
true IS NOT NULL, e.g.RETURN NOT true AS x UNION RETURN true AS x,RETURN true IN [true] AS x UNION RETURN true AS x,RETURN true AND false AS x UNION RETURN true AS x;RETURN 1 = 1 AS x UNION RETURN true AS x;RETURN true AS x UNION RETURN true IS NOT NULL AS x(message:UNION types agtype and boolean cannot be matched);RETURN true IS NOT NULL UNION RETURN true.Only unions whose branches are all
agtypealready work, e.g.RETURN true AS x UNION RETURN true AS x. The inferred branch type depends on expression shape rather than on the Cypher result type:RETURN (1 = 1) AS x UNION RETURN true AS xsucceeds,RETURN 1 = 1 AS x UNION RETURN true AS x) fails.Environment
apache/age:1.8.0Docker image)