hkjiang26 opened a new issue, #2512:
URL: https://github.com/apache/age/issues/2512

   **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:
   
   ```pgsql
   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**
   
   ```pgsql
   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
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to