skip to Main Content

I am trying to add support for the following query for an AGE project that converts Cypher queries to SQL:

MATCH p=({name: 'agens-graph'})-[{lang: 'java'}]->(m) RETURN *;

This successfully converts into the following:

SELECT * FROM cypher('test', $$ MATCH p=({name: 'agens-graph'})-[{lang: 'java'}]->(m) RETURN * $$) AS (v agtype);

However, this produces an error:

ERROR:  return row and column definition list do not match

Assuming I do not know the exact columns that will be produced with the RETURN *, is there a way to replace the AS (v agtype) to something else that will support the query (something like AS (* agtype))? Or is this not yet supported in AGE?

2

Answers


  1. As per the documentation of RETURN clause, even if you are using RETURN *, you need to define the number of columns to be returned by the cypher query and so any alike of * agtype is not yet supported. For example:

    SELECT *
    FROM cypher('graph_name', $$
    MATCH (a {name: 'A'})-[r]->(b)
    RETURN *
    $$) as (a agtype, b agtype, r agtype);
    

    Reference: RETURN clause

    Login or Signup to reply.
  2. SELECT *
    FROM cypher('test', $$ MATCH p=({name: 'agens-graph'})-[{lang: 'java'}]->(m) RETURN * $$)
      AS (data agtype);
    

    We have to define what we are getting back as return expects a column number but you can use a placeholder value to keep it dynamic. It is usually advised to know the exact number.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search