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

Unexpected value returned for aggregate collection in distributed query #4720

Closed
mcculls opened this issue Aug 4, 2015 · 6 comments
Closed
Assignees
Labels
Milestone

Comments

@mcculls
Copy link
Contributor

mcculls commented Aug 4, 2015

The fix for issue #2914 (specifically be26632) seems to have caused a regression when using aggregate collections in distributed queries. For example, this test:

diff --git a/distributed/src/test/java/com/orientechnologies/orient/server/distributed/DistributedAggregateCollectionTest.java b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/DistributedAggregateCollectionTest.java
new file mode 100644
index 0000000..a0b65ee
--- /dev/null
+++ b/distributed/src/test/java/com/orientechnologies/orient/server/distributed/DistributedAggregateCollectionTest.java
@@ -0,0 +1,49 @@
+package com.orientechnologies.orient.server.distributed;
+
+import java.util.Collections;
+
+import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
+import com.orientechnologies.orient.core.record.impl.ODocument;
+import com.orientechnologies.orient.core.sql.OCommandSQL;
+import com.tinkerpop.blueprints.impls.orient.OrientBaseGraph;
+import junit.framework.Assert;
+import org.junit.Test;
+
+public class DistributedAggregateCollectionTest extends AbstractServerClusterTest {
+  private final static int SERVERS = 1;
+
+  @Override
+  public String getDatabaseName() {
+    return "DistributedAggregateCollectionTest";
+  }
+
+  @Test
+  public void test() throws Exception {
+    init(SERVERS);
+    prepare(false);
+    execute();
+  }
+
+  @Override
+  protected void onAfterDatabaseCreation(OrientBaseGraph db) {
+    db.command(new OCommandSQL("CREATE CLASS Item extends V")).execute();
+    db.command(new OCommandSQL("CREATE PROPERTY Item.name STRING")).execute();
+  }
+
+  @Override
+  protected void executeTest() throws Exception {
+
+    ODatabaseDocumentTx db = new ODatabaseDocumentTx("plocal:target/server0/databases/" + getDatabaseName());
+    db.open("admin", "admin");
+
+    try {
+      db.command(new OCommandSQL("INSERT into Item (name) values ('foo')")).execute();
+
+      final Iterable<ODocument> result = db.command(new OCommandSQL("select set(name) as names from Item")).execute();
+      Assert.assertEquals(Collections.singleton("foo"), result.iterator().next().field("names"));
+
+    } finally {
+      db.close();
+    }
+  }
+}

will fail with the following message using the latest code from the develop branch:

junit.framework.AssertionFailedError: expected:<[foo]> but was:<[{node=europe0.DistributedAggregateCollectionTest, context=[foo]}]>

Whereas if I revert be26632 then the test passes. AFAICT the node+context value is an internal form that's used to help merge results across nodes, but shouldn't be exposed to clients.

@lvca
Copy link
Member

lvca commented Aug 4, 2015

You're right. We found the same with other tests: our Jenkins was complaining form days. Fixing it now.

@lvca
Copy link
Member

lvca commented Aug 4, 2015

Is DistributedAggregateCollectionTest a your test case?

@lvca
Copy link
Member

lvca commented Aug 4, 2015

Ok, merging your test case...

@lvca lvca self-assigned this Aug 4, 2015
@lvca
Copy link
Member

lvca commented Aug 4, 2015

Fixed in 5e8d735

@lvca lvca closed this as completed Aug 4, 2015
@lvca
Copy link
Member

lvca commented Aug 4, 2015

Thanks for the test case

@lvca lvca added this to the 2.1 GA milestone Aug 4, 2015
@mcculls
Copy link
Contributor Author

mcculls commented Aug 4, 2015

No worries, thanks for the fast response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants