You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by ch...@apache.org on 2015/03/03 12:26:18 UTC
svn commit: r1663666 -
/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexTest.java
Author: chetanm
Date: Tue Mar 3 11:26:18 2015
New Revision: 1663666
URL: http://svn.apache.org/r1663666
Log:
OAK-2568 - Ignore redundant IS NOT NULL constraints
Adding test to confirm that QueryEngine does not pass 'is not null' constraint to indexes after converting the passed query
Modified:
jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexTest.java
Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexTest.java?rev=1663666&r1=1663665&r2=1663666&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexTest.java (original)
+++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexTest.java Tue Mar 3 11:26:18 2015
@@ -75,6 +75,7 @@ import static org.apache.jackrabbit.oak.
import static org.apache.jackrabbit.oak.plugins.index.lucene.TestUtil.useV2;
import static org.apache.jackrabbit.oak.plugins.index.property.OrderedIndex.OrderDirection;
import static org.apache.jackrabbit.oak.plugins.memory.PropertyStates.createProperty;
+import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.matchers.JUnitMatchers.containsString;
@@ -332,6 +333,39 @@ public class LucenePropertyIndexTest ext
assertQuery("select [jcr:path] from [nt:base] where propa is not null", asList("/test/a", "/test/b"));
}
+ //OAK-2568
+ @Test
+ public void redundantNotNullCheck() throws Exception{
+ Tree idx = createIndex("test1", of("tags"));
+ root.commit();
+
+ Tree test = root.getTree("/").addChild("test");
+ test.addChild("a").setProperty("tags", of("a","b"), Type.STRINGS);
+ test.addChild("b").setProperty("tags", of("a","c"), Type.STRINGS);
+ root.commit();
+
+ String q = "SELECT * FROM [nt:unstructured] as content WHERE ISDESCENDANTNODE('/content/dam/en/us')\n" +
+ "and(\n" +
+ " content.[tags] = 'Products:A'\n" +
+ " or content.[tags] = 'Products:A/B'\n" +
+ " or content.[tags] = 'Products:A/B'\n" +
+ " or content.[tags] = 'Products:A'\n" +
+ ")\n" +
+ "and(\n" +
+ " content.[tags] = 'DocTypes:A'\n" +
+ " or content.[tags] = 'DocTypes:B'\n" +
+ " or content.[tags] = 'DocTypes:C'\n" +
+ " or content.[tags] = 'ProblemType:A'\n" +
+ ")\n" +
+ "and(\n" +
+ " content.[hasRendition] IS NULL\n" +
+ " or content.[hasRendition] = 'false'\n" +
+ ")";
+
+ //Check that filter created out of query does not have is not null restriction
+ assertThat(explain(q), not(containsString("[content].[tags] is not null")));
+ }
+
@Test
public void propertyNonExistenceQuery() throws Exception {
NodeTypeRegistry.register(root, IOUtils.toInputStream(TestUtil.TEST_NODE_TYPE), "test nodeType");