age icon indicating copy to clipboard operation
age copied to clipboard

Should there be a proper error message when using RETURN * without any variable in scope ?

Open MuhammadTahaNaveed opened this issue 2 years ago • 8 comments

For the question above, neo4j returns the following error

MATCH () RETURN *
ERROR: RETURN * is not allowed when there are no variables in scope

But age generates

ERROR:  return row and column definition list do not match

Should we also generate a proper error message in transformation stage catching this invalid use ?

MuhammadTahaNaveed avatar Jul 13 '23 08:07 MuhammadTahaNaveed

Displaying proper error messages indicating a specific problem is helpful in debugging the code and solving the issue easily and efficiently. Since it enhances the user experience a proper error message indicating the main reason why it occurred should be displayed for the said command.

talhahahae avatar Jul 13 '23 08:07 talhahahae

I suppose the complete query that you have run and has caused the error is as below.

SELECT * FROM cypher('graph', $$
    MATCH ()
    RETURN *                                                                  
$$) AS (v agtype);

The error is not because of the RETURN clause. It is because of the mismatch of number of columns returned by the cypher query (MATCH()) and the number of columns defined in the column definition list (v agtype). The match() clause return no column while there is one column defined in column definition list (v agtype). There is mismatch of column therefore you have encountered the error.

Basically in age there is a function by the name of analyze_cypher_and_coerce which is responsible for comparing the number of columns defined in the column definition list with the number of columns returned by the analyzed query. If the number of columns do not match then it will throw the error 'row and column definition list do not match'. So according to the cause of the error this error message make sense.

The following query also cause the same error:

SELECT * FROM cypher('emp_graph', $$
    MATCH (v:employee)
    RETURN v.name                                                                  
$$) AS (v agtype, x agtype);

Error messages are always generalized.

RahimullahShaheen avatar Jul 13 '23 12:07 RahimullahShaheen

There are other places where error messages are not proper. For example, when age_load tries loading vertices into a non-existing label, it throws 'label id must between x and y,' instead of saying 'label does not exist'.

I think a project can be created to rewrite some of these error messages from end users point of view.

rafsun42 avatar Jul 13 '23 15:07 rafsun42

It's a good idea to rewrite some error messages in AGE. I have also encountered issues while coding and debugging agtype.c. Some errors need to be more detailed and descriptive to provide better guidance for troubleshooting and resolving problems effectively.

When I tried to use the function that I developed toFloatList() I wasted a lot of time trying to solve erros in the code, but the error was in the cypher query

M4rcxs avatar Jul 19 '23 23:07 M4rcxs

The error: "Return row and column definition list do not match." occurs when the number of values returned does not match the expected output defined by the RETURN clause. Hence it's appropriate for that query.

However, there are other cases in AGE where generating specific errors would help users easily understand the cause of errors. Hence, I think there should be a project for that.

titoausten avatar Jul 20 '23 08:07 titoausten

I think that we should attempt to fix, or align, our messages with, say, Neo4j, where it is necessary or makes sense.

jrgemignani avatar Jul 21 '23 00:07 jrgemignani

@MuhammadTahaNaveed Is this still an issue or can this be closed?

jrgemignani avatar Apr 17 '24 21:04 jrgemignani

This issue is stale because it has been open 60 days with no activity. Remove "Abondoned" label or comment or this will be closed in 14 days.

github-actions[bot] avatar Jun 17 '24 00:06 github-actions[bot]