Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-2494

SQL2: AssertionError on multiple joins with isChildNode

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 4.4.0.Final
    • 4.1.0.Final
    • Query
    • None
    • Hide

      Execute the SQL2 query on the cars-system-view.xml test data:

      SELECT parent.[jcr:path], child1.[jcr:name], desc.[jcr:name] FROM [nt:unstructured] AS parent
      LEFT OUTER JOIN [nt:unstructured] AS child1 ON ISCHILDNODE(child1,parent) 
      INNER JOIN [nt:unstructured] AS desc on ISCHILDNODE(desc, child1) 
      LEFT OUTER JOIN [nt:unstructured] AS child2 ON ISCHILDNODE(child2,parent)
      WHERE ISCHILDNODE(parent,'/') 
      AND NAME(child2) = 'Hybrid' 
      AND NAME(desc) LIKE 'Nissan%'
      
      Show
      Execute the SQL2 query on the cars-system-view.xml test data: SELECT parent.[jcr: path ], child1.[jcr: name ], desc .[jcr: name ] FROM [nt:unstructured] AS parent LEFT OUTER JOIN [nt:unstructured] AS child1 ON ISCHILDNODE(child1,parent) INNER JOIN [nt:unstructured] AS desc on ISCHILDNODE( desc , child1) LEFT OUTER JOIN [nt:unstructured] AS child2 ON ISCHILDNODE(child2,parent) WHERE ISCHILDNODE(parent, '/' ) AND NAME (child2) = 'Hybrid' AND NAME ( desc ) LIKE 'Nissan%'

    Description

      With particularly complex SQL2 queries (see example below), an assertion fails in ScanningQueryEngine:

      java.lang.AssertionError
      	at org.modeshape.jcr.query.engine.ScanningQueryEngine.createNodeSequence(ScanningQueryEngine.java:688)
      	at org.modeshape.jcr.query.engine.ScanningQueryEngine.createNodeSequence(ScanningQueryEngine.java:801)
      	at org.modeshape.jcr.query.engine.ScanningQueryEngine.executeOptimizedQuery(ScanningQueryEngine.java:506)
      	at org.modeshape.jcr.query.engine.ScanningQueryEngine.execute(ScanningQueryEngine.java:324)
      	at org.modeshape.jcr.RepositoryQueryManager$1.execute(RepositoryQueryManager.java:181)
      	at org.modeshape.jcr.query.JcrQuery.execute(JcrQuery.java:118)
      	at org.modeshape.jcr.query.JcrQuery.execute(JcrQuery.java:43)
      	at org.modeshape.jcr.JcrQueryManagerTest.shouldBeAbleToCreateAndExecuteJcrSql2QueryWithTwoLeftOuterJoinsOnIsChildNodeWithSubsequentIsDescendantNode(JcrQueryManagerTest.java:2671)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
      	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
      	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
      	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
      	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
      	at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
      	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
      	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
      	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
      

      An example query (using the test pack dataset) is:

      SELECT parent.[jcr:path], child1.[jcr:name], desc.[jcr:name] FROM [nt:unstructured] AS parent
      LEFT OUTER JOIN [nt:unstructured] AS child1 ON ISCHILDNODE(child1,parent) 
      INNER JOIN [nt:unstructured] AS desc on ISCHILDNODE(desc, child1) 
      LEFT OUTER JOIN [nt:unstructured] AS child2 ON ISCHILDNODE(child2,parent)
      WHERE ISCHILDNODE(parent,'/') 
      AND NAME(child2) = 'Hybrid' 
      AND NAME(desc) LIKE 'Nissan%'
      

      I have narrowed it down to the case where two joins are made on the same child node ('child1' and 'child2' in the query above) and then a subsequent join is made on a child or descendant of one of these nodes (desc).

      The query works when the join on desc is not included, or when only one of the joins on child1 & child2 are included.

      It seems to be related to the query optimisation code which sometimes reverses the left and right side of the joins.

      Verified to be an issue since at least 4.1.0 and is currently still an issue on 4.4.

      Attachments

        Activity

          People

            Unassigned Unassigned
            dankelleher_jira Daniel Kelleher (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: