You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@geode.apache.org by "nabarun (JIRA)" <ji...@apache.org> on 2017/09/26 23:55:00 UTC
[jira] [Created] (GEODE-3707) Join queries with two join conditions
return duplicate results when executed with indexes
nabarun created GEODE-3707:
------------------------------
Summary: Join queries with two join conditions return duplicate results when executed with indexes
Key: GEODE-3707
URL: https://issues.apache.org/jira/browse/GEODE-3707
Project: Geode
Issue Type: Bug
Components: querying
Reporter: nabarun
Fix For: 1.3.0
Acceptance: the test below must return the same number of results
{code: title = Customer.java}
public static class Customer implements Serializable {
public int pkid;
public int id;
public int joinId;
public String name;
public Map<String, Customer> nested = new HashMap<String, Customer>();
public Customer(int pkid, int id) {
this.pkid = pkid;
this.id = id;
this.joinId = id;
this.name = "name" + pkid;
}
public Customer(int pkid, int id, int joinId) {
this.pkid = pkid;
this.id = id;
this.joinId = joinId;
this.name = "name" + pkid;
}
public String toString() {
return "Customer pkid = " + pkid + ", id: " + id + " name:" + name;
}
}
{code}
{code: title = Test.java}
@Test
public void testJoinTwoRegions(/*String queryString, int resultSize*/) throws Exception {
Cache cache = getCache();
Region region1 =
cache.createRegionFactory().setDataPolicy(DataPolicy.REPLICATE).create("region1");
Region region2 =
cache.createRegionFactory().setDataPolicy(DataPolicy.REPLICATE).create("region2");
for (int i = 1; i < 11; i++) {
region1.put(i, new EquiJoinIntegrationTest.Customer(i, i, i));
if(i == 1 || i == 4 || i == 7 || i == 10){
region2.put(i, new EquiJoinIntegrationTest.Customer(1, 1, 1));
}else {
region2.put(i, new EquiJoinIntegrationTest.Customer(i % 5, i, i % 3));
}
String queryString = "<trace>select STA.id as STACID, STA.pkid as STAacctNum, STC.id as STCCID, STC.pkid as STCacctNum from /region1 STA, /region2 STC where STA.pkid = 1 AND STA.joinId = STC.joinId or STA.id = STC.id";
int resultSize = 1;
QueryService queryService = cache.getQueryService();
SelectResults results = (SelectResults) queryService.newQuery(queryString).execute();
int resultSizeWithoutIndex = results.size();
queryService.createIndex("pkidregion1", "p.pkid", "/region1 p");
queryService.createIndex("pkidregion2", "p.pkid", "/region2 p");
queryService.createIndex("indexIDRegion2","p.id", "/region2 p");
queryService.createIndex("indexIDRegion1","p.id", "/region1 p");
queryService.createIndex("joinIdregion1", "p.joinId", "/region1 p");
queryService.createIndex("joinIdregion2", "p.joinId", "/region2 p");
queryService.createIndex("nameIndex", "p.name", "/region2 p");
results = (SelectResults) queryService.newQuery(queryString).execute();
int resultSizeWithIndex = results.size();
assertEquals(resultSizeWithIndex, resultSizeWithoutIndex);
}
{code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)