age
age copied to clipboard
Should there be a proper error message when using RETURN * without any variable in scope ?
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 ?
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.
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.
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.
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
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.
I think that we should attempt to fix, or align, our messages with, say, Neo4j, where it is necessary or makes sense.
@MuhammadTahaNaveed Is this still an issue or can this be closed?
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.