use of org.voltdb.VoltTable in project voltdb by VoltDB.
the class TestUnionSuite method testUnionAllMultiColumns.
/**
* Two table Union ALL - A.PKEY, A.I and B.PKET, B.I
* @throws NoConnectionsException
* @throws IOException
* @throws ProcCallException
*/
public void testUnionAllMultiColumns() throws NoConnectionsException, IOException, ProcCallException {
Client client = this.getClient();
VoltTable vt;
//In the final result set
client.callProcedure("InsertA", 0, 1);
//In the final result set
client.callProcedure("InsertA", 1, 1);
//In the final result set
client.callProcedure("InsertB", 1, 1);
//In the final result set
client.callProcedure("InsertB", 2, 1);
vt = client.callProcedure("@AdHoc", "SELECT PKEY, I FROM A UNION ALL " + "SELECT PKEY, I FROM B order by pkey, i;").getResults()[0];
assertEquals(4, vt.getRowCount());
validateTableOfLongs(vt, new long[][] { { 0, 1 }, { 1, 1 }, { 1, 1 }, { 2, 1 } });
}
use of org.voltdb.VoltTable in project voltdb by VoltDB.
the class TestUnionSuite method testMultipleSetOperations4.
/**
* (A.I) except (B.I except C.I)
* @throws NoConnectionsException
* @throws IOException
* @throws ProcCallException
*/
public void testMultipleSetOperations4() throws NoConnectionsException, IOException, ProcCallException {
Client client = this.getClient();
VoltTable vt;
// in A and B and C. Eliminated by inner EXCEPT, so IN final result.
client.callProcedure("InsertA", 0, 0);
// in A and B, not in C. Eliminated by outer EXCEPT.
client.callProcedure("InsertA", 1, 1);
// in A and has no effect in C. IN final result set.
client.callProcedure("InsertA", 2, 2);
// in A only. IN final result set
client.callProcedure("InsertA", 3, 3);
// in A and B and C. Eliminated by inner EXCEPT, so IN final result.
client.callProcedure("InsertB", 0, 0);
// in A and B, not in C. Eliminated by outer EXCEPT.
client.callProcedure("InsertB", 1, 1);
// Not in A. Has no effect in B and C. Not in final result.
client.callProcedure("InsertB", 4, 4);
// Not in A. Has no effect in B. Not in final result.
client.callProcedure("InsertB", 5, 5);
// in A and B and C. Eliminated by inner EXCEPT, so IN final result.
client.callProcedure("InsertC", 0, 0);
// in A and has no effect in C. IN final result set.
client.callProcedure("InsertC", 2, 2);
// Not in A. Has no effect in B and C. Not in final result.
client.callProcedure("InsertC", 4, 4);
// Not in A. Has no effect in C. Not in final result.
client.callProcedure("InsertC", 6, 6);
vt = client.callProcedure("@AdHoc", "(SELECT I FROM A) EXCEPT " + "(SELECT I FROM B EXCEPT SELECT I FROM C) order by i;").getResults()[0];
assertEquals(3, vt.getRowCount());
validateTableOfScalarLongs(vt, new long[] { 0, 2, 3 });
}
use of org.voltdb.VoltTable in project voltdb by VoltDB.
the class TestUnionSuite method testMultipleSetOperations1.
/**
* (A.I union B.I) except C.I
* @throws NoConnectionsException
* @throws IOException
* @throws ProcCallException
*/
public void testMultipleSetOperations1() throws NoConnectionsException, IOException, ProcCallException {
Client client = this.getClient();
VoltTable vt;
// in A,B union. Eliminated by C.PKEY=3
client.callProcedure("InsertA", 0, 0);
// in A,B union. Eliminated by C.PKEY=1
client.callProcedure("InsertA", 1, 1);
// Eliminated (duplicate in A,B union)
client.callProcedure("InsertA", 2, 1);
// in A,B union. Not in C. In final result set
client.callProcedure("InsertA", 3, 2);
// Eliminated (duplicate A.PKEY=0)
client.callProcedure("InsertB", 1, 0);
// Eliminated (duplicate A.PKEY=1)
client.callProcedure("InsertB", 2, 1);
// Eliminated (duplicate A.PKEY=3)
client.callProcedure("InsertB", 3, 2);
// Eliminated ( in A,B union)
client.callProcedure("InsertC", 1, 1);
// Eliminated ( in A,B union)
client.callProcedure("InsertC", 3, 0);
// Eliminated ( not in A or B)
client.callProcedure("InsertC", 4, 3);
vt = client.callProcedure("@AdHoc", "SELECT I FROM A UNION SELECT I FROM B " + "EXCEPT SELECT I FROM C order by i;").getResults()[0];
assertEquals(1, vt.getRowCount());
validateTableOfScalarLongs(vt, new long[] { 2 });
vt = client.callProcedure("@AdHoc", "(SELECT I FROM A UNION SELECT I FROM B) " + "EXCEPT SELECT I FROM C order by i;").getResults()[0];
assertEquals(1, vt.getRowCount());
validateTableOfScalarLongs(vt, new long[] { 2 });
// test with parameters
vt = client.callProcedure("@AdHoc", "SELECT I FROM A where I = 0 UNION SELECT I FROM B " + "EXCEPT SELECT I FROM C WHERE I = 3 order by i;").getResults()[0];
assertEquals(3, vt.getRowCount());
validateTableOfScalarLongs(vt, new long[] { 0, 1, 2 });
}
use of org.voltdb.VoltTable in project voltdb by VoltDB.
the class TestUnionSuite method testUnion.
/**
* Three table Union - A.PKEY, B.I and C.I
* @throws NoConnectionsException
* @throws IOException
* @throws ProcCallException
*/
public void testUnion() throws NoConnectionsException, IOException, ProcCallException {
Client client = this.getClient();
VoltTable vt;
// In the final result set - 0
client.callProcedure("InsertA", 0, 1);
// In the final result set - 1
client.callProcedure("InsertB", 1, 1);
// Eliminated (duplicate)
client.callProcedure("InsertB", 2, 1);
// In the final result set - 2
client.callProcedure("InsertC", 1, 2);
// In the final result set - 3
client.callProcedure("InsertC", 2, 3);
// Eliminated (duplicate)
client.callProcedure("InsertC", 3, 3);
vt = client.callProcedure("@AdHoc", "SELECT PKEY FROM A UNION SELECT I FROM B UNION SELECT I FROM C order by pkey;").getResults()[0];
assertEquals(4, vt.getRowCount());
validateTableOfScalarLongs(vt, new long[] { 0, 1, 2, 3 });
vt = client.callProcedure("@AdHoc", "(SELECT PKEY FROM A UNION SELECT I FROM B) UNION SELECT I FROM C order by pkey;").getResults()[0];
assertEquals(4, vt.getRowCount());
validateTableOfScalarLongs(vt, new long[] { 0, 1, 2, 3 });
vt = client.callProcedure("@AdHoc", "SELECT PKEY FROM A UNION (SELECT I FROM B UNION SELECT I FROM C) order by pkey;").getResults()[0];
assertEquals(4, vt.getRowCount());
validateTableOfScalarLongs(vt, new long[] { 0, 1, 2, 3 });
// test with parameters
vt = client.callProcedure("@AdHoc", "SELECT PKEY FROM A where PKEY = 0 UNION SELECT I FROM B where PKEY = 2 " + "UNION SELECT I FROM C WHERE I = 3 order by pkey;").getResults()[0];
assertEquals(3, vt.getRowCount());
validateTableOfScalarLongs(vt, new long[] { 0, 1, 3 });
vt = client.callProcedure("@Explain", "SELECT PKEY FROM A where PKEY = 0 UNION SELECT I FROM B " + "UNION SELECT I FROM C WHERE I = 3;").getResults()[0];
String resultStr = vt.toString();
assertTrue(resultStr.contains("(PKEY = ?0)"));
assertTrue(resultStr.contains("(column#1 = ?1)"));
vt = client.callProcedure("@AdHoc", "SELECT PKEY FROM A where PKEY = 0 UNION SELECT I FROM B WHERE PKEY=? " + "UNION SELECT I FROM C WHERE PKEY = ? AND I = 3 order by pkey;", 3, 2).getResults()[0];
assertEquals(2, vt.getRowCount());
validateTableOfScalarLongs(vt, new long[] { 0, 3 });
String sql;
// data
client.callProcedure("@AdHoc", "INSERT INTO RPT_P (client_id, config_id, cost) VALUES (140,1,1.0);");
client.callProcedure("@AdHoc", "INSERT INTO RPT_P (client_id, config_id, cost) VALUES (140,3,3.0);");
client.callProcedure("@AdHoc", "INSERT INTO rpt_copy_p (client_id, config_id, cost) VALUES (140,2,2.0);");
client.callProcedure("@AdHoc", "INSERT INTO rpt_copy_p (client_id, config_id, cost) VALUES (140,1,1.0);");
sql = "select client_id, config_id from RPT_P where client_id=140 " + " UNION " + "select client_id, config_id from rpt_copy_p where client_id=140 " + " order by client_id, config_id;";
vt = client.callProcedure("@AdHoc", sql).getResults()[0];
assertEquals(3, vt.getRowCount());
validateTableOfLongs(vt, new long[][] { { 140, 1 }, { 140, 2 }, { 140, 3 } });
sql = "select client_id, config_id, sum(cost) as cost from RPT_P where client_id=140 group by client_id, config_id " + " UNION " + "select client_id, config_id, sum(cost) as cost from rpt_copy_p where client_id=140 group by client_id, config_id " + " order by client_id, config_id;";
vt = client.callProcedure("@AdHoc", sql).getResults()[0];
assertEquals(3, vt.getRowCount());
validateTableOfLongs(vt, new long[][] { { 140, 1, 1 }, { 140, 2, 2 }, { 140, 3, 3 } });
vt = client.callProcedure("testunion_p", 140, 140).getResults()[0];
assertEquals(3, vt.getRowCount());
vt = client.callProcedure("testunion_p", 10, 10).getResults()[0];
assertEquals(0, vt.getRowCount());
}
use of org.voltdb.VoltTable in project voltdb by VoltDB.
the class TestUndoSuite method testMultibatchMPGoodThenMPFail.
public void testMultibatchMPGoodThenMPFail() throws IOException, ProcCallException {
final Client client = this.getClient();
doMpLoad(client, 100);
doMpRollback(client, 0);
doMpRollback(client, 1);
doMpRollback(client, 2);
VoltTable[] results = client.callProcedure("CountP1").getResults();
assertEquals(100, results[0].asScalarLong());
}
Aggregations