Uploaded image for project: 'Spring Data Neo4j'
  1. Spring Data Neo4j
  2. DATAGRAPH-338

Distinct in Neo4j 1.9.M05 cypher query causes exception

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 2.2
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Neo4j 1.9.M05
      SDN 2.2

      Description

      Maybe I'm to quick and SDN will only support 1.9 when its officially released, but I already gave the Neo4j 1.9.M05 a try. Everything seems to be compatible, except one thing.

      The following cypher query runs fine:

      START entity=node:attach_content("content:*test*") 
      MATCH (entity)<-[:ATTACHES]-(c) 
      WHERE entity.visibility? ="VISIBLE" 
      RETURN c 
      ORDER BY id(c) DESCENDING

      while this one, with DISTINCT, causes an exception:

      START entity=node:attach_content("content:*test*") 
      MATCH (entity)<-[:ATTACHES]-(c) 
      WHERE entity.visibility? ="VISIBLE" 
      RETURN DISTINCT c 
      ORDER BY id(c) DESCENDING

      When there is no result, everything runs fine, but when there's one or multiple results, it fails:

      java.lang.RuntimeException: Cannot extract single value from Iterable with more than one elements.
      	at org.springframework.data.neo4j.conversion.DefaultConverter.extractSingle(DefaultConverter.java:60)
      	at org.springframework.data.neo4j.conversion.DefaultConverter.extractValue(DefaultConverter.java:51)
      	at org.springframework.data.neo4j.conversion.DefaultConverter.convert(DefaultConverter.java:40)
      	at org.springframework.data.neo4j.support.conversion.EntityResultConverter.convert(EntityResultConverter.java:99)
      	at org.springframework.data.neo4j.conversion.QueryResultBuilder$1.convert(QueryResultBuilder.java:102)
      	at org.springframework.data.neo4j.conversion.QueryResultBuilder$1.access$300(QueryResultBuilder.java:81)
      	at org.springframework.data.neo4j.conversion.QueryResultBuilder$1$1.underlyingObjectToObject(QueryResultBuilder.java:120)
      	at org.neo4j.helpers.collection.IteratorWrapper.next(IteratorWrapper.java:47)
      	at org.neo4j.helpers.collection.IteratorUtil.addToCollection(IteratorUtil.java:353)
      	at org.neo4j.helpers.collection.IteratorUtil.addToCollection(IteratorUtil.java:370)
      	at org.springframework.data.neo4j.conversion.ContainerConverter.toContainer(ContainerConverter.java:34)
      	at org.springframework.data.neo4j.conversion.QueryResultBuilder$1.as(QueryResultBuilder.java:127)
      	at org.springframework.data.neo4j.repository.AbstractGraphRepository.query(AbstractGraphRepository.java:442)
      	at org.springframework.data.neo4j.repository.AbstractGraphRepository.query(AbstractGraphRepository.java:453)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:597)
      	at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:333)
      	at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:318)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)

      I'm using a CypherDSLRepository to query a paged result.

        Activity

        Hide
        markglh Mark Harrison added a comment -

        @Timmy, No problem, glad I could help.

        Sorry I haven't provided a test case yet, I haven't forgotten - things have just been a little hectic around here.

        Mark.

        Show
        markglh Mark Harrison added a comment - @Timmy, No problem, glad I could help. Sorry I haven't provided a test case yet, I haven't forgotten - things have just been a little hectic around here. Mark.
        Hide
        tims83 Timmy Storms added a comment -

        Created a test case which illustrates the problem, see http://github.com/TimmyStorms/datagraph338. Run QueryTest with JUnit and behold the issue!

        Show
        tims83 Timmy Storms added a comment - Created a test case which illustrates the problem, see http://github.com/TimmyStorms/datagraph338 . Run QueryTest with JUnit and behold the issue!
        Hide
        markglh Mark Harrison added a comment - - edited

        Cheers for jumping in on that Tim! Hopefully Michael can get this nailed once and for all

        Show
        markglh Mark Harrison added a comment - - edited Cheers for jumping in on that Tim! Hopefully Michael can get this nailed once and for all
        Hide
        mhunger Michael Hunger added a comment -

        Timmy, I ran your test-case and it seems that the cypher results contain 1 column, but then actually 2 elements per row. And that's where SDN trips.

        Could you raise a Zendesk issue with your customer account to get it fixed in Cypher / Neo4j 1.9.2

        We can build a work around in SDN but that will be more expensive as it will have to include a filter for just allowing the 'official' columns for each row to be visible to SDN.

        Show
        mhunger Michael Hunger added a comment - Timmy, I ran your test-case and it seems that the cypher results contain 1 column, but then actually 2 elements per row. And that's where SDN trips. Could you raise a Zendesk issue with your customer account to get it fixed in Cypher / Neo4j 1.9.2 We can build a work around in SDN but that will be more expensive as it will have to include a filter for just allowing the 'official' columns for each row to be visible to SDN.
        Hide
        nmervaillie Nicolas Mervaillie added a comment -

        In order to give users a better vision of what’s happening on SDN, we are bulk closing several issues because they are no more relevant, or related to old and un-maintained SDN versions.
        We tried to keep the issues that are still relevant, like feature requests that are still absent from SDN. However, some may have been closed by error. If so, please feel free to reopen.

        Show
        nmervaillie Nicolas Mervaillie added a comment - In order to give users a better vision of what’s happening on SDN, we are bulk closing several issues because they are no more relevant, or related to old and un-maintained SDN versions. We tried to keep the issues that are still relevant, like feature requests that are still absent from SDN. However, some may have been closed by error. If so, please feel free to reopen.

          People

          • Assignee:
            mhunger Michael Hunger
            Reporter:
            tims83 Timmy Storms
            Last updater:
            Nicolas Mervaillie
          • Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: