Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The apoc.custom.declareProcedure throws exception "Query results do not match requested output" with some queries #2605

Closed
vga91 opened this issue Mar 4, 2022 · 3 comments · Fixed by #3146

Comments

@vga91
Copy link
Collaborator

vga91 commented Mar 4, 2022

How to Reproduce the Problem

See https://community.neo4j.com/t/apoc-custom-declareprocedure-always-throws-exception-corresponding-cypher-code-works/52004

Versions

  • OS: Mac OSX
  • Neo4j: 4.3
  • Neo4j-Apoc: 4.3.0.5
@vga91 vga91 changed the title apoc.custom.declareProcedure throws The apoc.custom.declareProcedure throws exception "Query results do not match requested output" with some queries Mar 4, 2022
@ralphavalon
Copy link

Hi,

After upgrading from APOC 4.4.0.3 to APOC 4.4.0.6, I started to see this same error.

Here's how to reproduce it:

version: '3'
services:
  neo4j:
    image: neo4j:4.4.7
    hostname: neo4j
    ports:
      - "7474:7474"
      - "7687:7687"
    environment:
      - NEO4J_AUTH=neo4j/test
      - NEO4J_dbms_logs_debug_level=DEBUG
      - NEO4JLABS_PLUGINS=["apoc"]
      - NEO4J_dbms_security_procedures_whitelist=apoc.*
      - NEO4J_dbms_security_procedures_unrestricted=apoc.*

Then, just login into http://localhost:7474/browser and run:

CALL apoc.custom.declareProcedure('exampleTest(exampleId::STRING) ::(value::STRING)',
'MATCH (:ExampleNode)
 OPTIONAL MATCH (o:OtherExampleNode {identifier:$exampleId})
 RETURN o.identifier as value
 UNION ALL
 MATCH (n:ExampleNode)
 OPTIONAL MATCH (o:OtherExampleNode {identifier:$exampleId})
 RETURN o.identifier as value
');

It was tested with:

Neo4j: 4.4.7
APOC: 4.4.0.6

Obviously, the procedure is just an example, since the original one was way larger and with a lot of WHERE conditions, so I removed everything I could until I have a minimal reproducible example.

@psygnoser
Copy link

Here's an even simpler example of two variants of basically the same procedure declaration, of which one works and the other one doesn't:

Variant 0:

 CALL apoc.custom.declareProcedure(
    "test() :: (abc::INT)",
    "
    call {
        with 1 as abc return abc
        union all
        with 2 as abc return abc
    }
    return abc
    "
);

RESULT: Failure - Failed to invoke procedure apoc.custom.declareProcedure: Caused by: java.lang.RuntimeException: Query results do not match requested output.

Variant 1:

 CALL apoc.custom.declareProcedure(
    "test() :: (abc::INT)",
    "
    call {
        with 1 as a return a
        union all
        with 2 as a return a
    }
    return a as abc
    "
);

RESULT: Success

Tested with:
Neo4j: 4.4.7
APOC: 4.4.0.4, 4.4.0.7

Note that both of the examples above work normally with APOC: 4.4.0.3

@hlvtc
Copy link

hlvtc commented Aug 19, 2022

We are not able to upgrade from APOC 4.4.0.3 due to the reported issue. Creation of some of our custom procedures fails . Steps to reproduce were described by @ralphavalon above:

Here's how to reproduce it:

version: '3'
services:
  neo4j:
    image: neo4j:4.4.10
    hostname: neo4j
    ports:
      - "7474:7474"
      - "7687:7687"
    environment:
      - NEO4J_AUTH=neo4j/test
      - NEO4J_dbms_logs_debug_level=DEBUG
      - NEO4JLABS_PLUGINS=["apoc"]
      - NEO4J_dbms_security_procedures_whitelist=apoc.*
      - NEO4J_dbms_security_procedures_unrestricted=apoc.*

Then, just login into http://localhost:7474/browser and run:

CALL apoc.custom.declareProcedure('exampleTest(exampleId::STRING) ::(value::STRING)',
'MATCH (:ExampleNode)
 OPTIONAL MATCH (o:OtherExampleNode {identifier:$exampleId})
 RETURN o.identifier as value
 UNION ALL
 MATCH (n:ExampleNode)
 OPTIONAL MATCH (o:OtherExampleNode {identifier:$exampleId})
 RETURN o.identifier as value
');

The result:

Failed to invoke procedure `apoc.custom.declareProcedure`: Caused by: java.lang.RuntimeException: Query results do not match requested output.

Last tested with:

Neo4j: 4.4.10
APOC: 4.4.0.8

vga91 added a commit to vga91/neo4j-apoc-procedures that referenced this issue Aug 23, 2022
…eption "Query results do not match requested output" with some queries
vga91 added a commit to vga91/neo4j-apoc-procedures that referenced this issue Aug 23, 2022
…eption "Query results do not match requested output" with some queries
vga91 added a commit that referenced this issue Aug 25, 2022
… results do not match requested output" with some queries (#3146)
vga91 added a commit to vga91/neo4j-apoc-procedures that referenced this issue Aug 25, 2022
…eption "Query results do not match requested output" with some queries (neo4j-contrib#3146)
vga91 added a commit that referenced this issue Aug 25, 2022
… results do not match requested output" with some queries (#3146)
vga91 added a commit that referenced this issue Sep 5, 2022
… results do not match requested output" with some queries (#3146)
vga91 added a commit that referenced this issue Sep 5, 2022
… results do not match requested output" with some queries (#3146) (#3148)
vga91 added a commit that referenced this issue Sep 26, 2022
… results do not match requested output" with some queries (#3146)
vga91 added a commit that referenced this issue Dec 14, 2022
… results do not match requested output" with some queries (#3146) (#3149)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants