Joats
Joats

Reputation: 11

Amazon Neptune OpenCypher - What is the cause for "Operation terminated (internal error)" when using SET after MERGE?

I am running this simple query on an Amazon Neptune DB, using directly the Neptune API:

POST {{host}}/openCypher
Content-Type: application/json

{
    "query":"MERGE (t:Test {reference: $reference}) SET t.test=$test RETURN t",
    "parameters": {
        "reference": "test",
        "test": "100"
    }
}

But I get the following error as a response:

  "detailedMessage": "Operation terminated (internal error)",
  "code": "InternalFailureException",
  "message": "Operation terminated (internal error)"

What gives?

I have tried other examples setting test to different values. All of them worked, which makes the problem even stranger. See these below:

{     
"query":"MERGE (t:Test {reference: $reference}) SET t.test=$test RETURN t",     
"parameters": {         
   "reference": "test",         
   "test": "1"     
} 
{     
"query":"MERGE (t:Test {reference: $reference}) SET t.test=$test RETURN t",     
"parameters": {         
   "reference": "test",         
   "test": true     
} 
{     
"query":"MERGE (t:Test {reference: $reference}) SET t.test=$test RETURN t",     
"parameters": {         
   "reference": "test",         
   "test": false    
} 
{     
"query":"MERGE (t:Test {reference: $reference}) SET t.test=$test RETURN t",     
"parameters": {         
   "reference": "test",         
   "test": 1    
} 
{     
"query":"MERGE (t:Test {reference: $reference}) SET t.test=$test RETURN t",     
"parameters": {         
   "reference": "test",         
   "test": 100     
} 
{     
"query":"MERGE (t:Test {reference: $reference}) SET t.test=$test RETURN t",     
"parameters": {         
   "reference": "test",         
   "test": "test"    
} 

Upvotes: 1

Views: 194

Answers (2)

Joats
Joats

Reputation: 11

This bug has been fixed in version 1.3.2.1 of the Neptune Engine -https://docs.aws.amazon.com/neptune/latest/userguide/engine-releases-1.3.2.1.html

Fixed a bug where parameterized mutation queries throw an InternalFailureException when the parameter that was passed is not already present in the database.

Upvotes: 0

Taylor Riggan
Taylor Riggan

Reputation: 2769

That kind of query should work. How are you sending the request to Neptune?

I just tested in a Neptune Notebook:

params = {
    'reference': 'test',
    'test': '100'
}
%%oc -qp params

MERGE (t:Test {reference: $reference}) 
SET t.test=$test 
RETURN t
{'~id': 'fbaa1199-9f2b-41ef-bdfe-27776e04a0d00', 
'~entityType': 'node', 
'~labels': ['Test'], 
'~properties': {'reference': 'test', 'test': '100'}}

I also tried the same via the AWS CLI:

!aws neptunedata execute-open-cypher-query \
   --open-cypher-query "MERGE (t:Test {reference: \$reference}) SET t.test=\$test RETURN t" \
   --parameters "{\"reference\": \"test\", \"test\": \"100\"}" \
   --endpoint-url "https://mycluster.cluster-abcdeolo6phb.us-west-2.neptune.amazonaws.com:8182"
{
    "results": [
        {
            "t": {
                "~id": "fbaa1199-9f2b-41ef-bdfe-27776e04a0d00",
                "~entityType": "node",
                "~labels": [
                    "Test"
                ],
                "~properties": {
                    "reference": "test",
                    "test": "100"
                }
            }
        }
    ]
}

Or using the API directly:

awscurl -X POST https://mycluster.cluster-abcdeolo6phb.us-west-2.neptune.amazonaws.com:8182/opencypher \
    --service neptune-db \
    --region us-west-2 \
    -d '{ \
        "query":"MERGE (t:Test {reference: $reference}) SET t.test=$test RETURN t", \
        "parameters": { \
            "reference": "test", \
            "test": "100" \
        } \
    }'
{
  "results": [{
      "t": {
        "~id": "fbaa1199-9f2b-41ef-bdfe-27776e04a0d00",
        "~entityType": "node",
        "~labels": ["Test"],
        "~properties": {
          "reference": "test",
          "test": "100"
        }
      }
    }]
}

Upvotes: 0

Related Questions