use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class TestMaterializedViewNonemptyTablesSuite method testDropView.
public void testDropView() throws Exception {
// Regression test for ENG-11497
Client client = getClient();
String ddl = "CREATE TABLE T_ENG_11497_1 (\n" + " AID integer NOT NULL,\n" + " USD float DEFAULT '0.0' NOT NULL,\n" + " PRIMARY KEY (AID)\n" + ");\n" + "PARTITION TABLE T_ENG_11497_1 ON COLUMN AID;\n" + "CREATE TABLE T_ENG_11497_2 (\n" + " AID integer NOT NULL,\n" + " USD float DEFAULT '0.0' NOT NULL,\n" + " PRIMARY KEY (AID)\n" + ");\n" + "PARTITION TABLE T_ENG_11497_2 ON COLUMN AID;\n" + "CREATE VIEW T_ENG_11497_1_VIEW\n" + "AS\n" + " SELECT\n" + " AID,\n" + " COUNT(*) AS IGNOREME,\n" + " SUM(CAST(USD AS DECIMAL)) AS USD\n" + "FROM T_ENG_11497_1\n" + "GROUP BY\n" + " AID;\n" + "CREATE VIEW T_ENG_11497_2_VIEW\n" + "AS\n" + " SELECT\n" + " t1.AID,\n" + " COUNT(*) AS IGNOREME,\n" + " SUM(CAST(t1.USD AS DECIMAL)) AS USD\n" + "FROM T_ENG_11497_1 as t1 inner join T_ENG_11497_2 as t2\n" + " ON t1.AID = t2.AID\n" + "GROUP BY\n" + " t1.AID;\n";
// Create some tables and some views
client.callProcedure("@AdHoc", ddl);
// Insert into the source tables so they're non-empty
client.callProcedure("@AdHoc", "insert into T_ENG_11497_1 values (0, 10.0);\n");
client.callProcedure("@AdHoc", "insert into T_ENG_11497_1 values (1, 10.0);\n");
client.callProcedure("@AdHoc", "insert into T_ENG_11497_2 values (0, 10.0);\n");
client.callProcedure("@AdHoc", "insert into T_ENG_11497_2 values (1, 10.0);\n");
ClientResponse cr;
// Make sure it's possible to drop the views
cr = client.callProcedure("@AdHoc", "drop view T_ENG_11497_1_VIEW;");
assertEquals(ClientResponse.SUCCESS, cr.getStatus());
cr = client.callProcedure("@AdHoc", "drop view T_ENG_11497_2_VIEW;");
assertEquals(ClientResponse.SUCCESS, cr.getStatus());
cr = client.callProcedure("@AdHoc", "drop table T_ENG_11497_1;");
assertEquals(ClientResponse.SUCCESS, cr.getStatus());
cr = client.callProcedure("@AdHoc", "drop table T_ENG_11497_2;");
assertEquals(ClientResponse.SUCCESS, cr.getStatus());
}
use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class TestMaterializedViewSuite method testEng11047.
public void testEng11047() throws Exception {
Client client = getClient();
ClientResponse cr;
VoltTable vt;
client.callProcedure("@AdHoc", "INSERT INTO P2_ENG_11024 VALUES (-1, null, null, null);");
client.callProcedure("@AdHoc", "INSERT INTO R2_ENG_11024 VALUES (-1, null, null, null);");
client.callProcedure("@AdHoc", "INSERT INTO P2_ENG_11024 VALUES (-2, null, null, -22.22);");
client.callProcedure("@AdHoc", "INSERT INTO R2_ENG_11024 VALUES (-2, null, null, -22.22);");
client.callProcedure("@AdHoc", "INSERT INTO P2_ENG_11024 VALUES (-3, null, -333, null);");
client.callProcedure("@AdHoc", "INSERT INTO R2_ENG_11024 VALUES (-3, null, -333, null);");
client.callProcedure("@AdHoc", "INSERT INTO P2_ENG_11024 VALUES (-4, null, -333, -22.22);");
client.callProcedure("@AdHoc", "INSERT INTO R2_ENG_11024 VALUES (-4, null, -333, -22.22);");
client.callProcedure("@AdHoc", "INSERT INTO P2_ENG_11024 VALUES (-5, 'eee', null, null);");
client.callProcedure("@AdHoc", "INSERT INTO R2_ENG_11024 VALUES (-5, 'eee', null, null);");
client.callProcedure("@AdHoc", "INSERT INTO P2_ENG_11024 VALUES (-6, 'eee', null, -66.66);");
client.callProcedure("@AdHoc", "INSERT INTO R2_ENG_11024 VALUES (-6, 'eee', null, -66.66);");
client.callProcedure("@AdHoc", "INSERT INTO P2_ENG_11024 VALUES (-7, 'eee', -777, null);");
client.callProcedure("@AdHoc", "INSERT INTO R2_ENG_11024 VALUES (-7, 'eee', -777, null);");
client.callProcedure("@AdHoc", "INSERT INTO P2_ENG_11024 VALUES (-8, 'eee', -777, -66.66);");
client.callProcedure("@AdHoc", "INSERT INTO R2_ENG_11024 VALUES (-8, 'eee', -777, -66.66);");
client.callProcedure("@AdHoc", "INSERT INTO P2_ENG_11024 VALUES (-9, 'jjj', -777, -66.66);");
client.callProcedure("@AdHoc", "INSERT INTO R2_ENG_11024 VALUES (-9, 'jjj', -777, -66.66);");
client.callProcedure("@AdHoc", "INSERT INTO P2_ENG_11024 VALUES (-10, 'jjj', -10, -10);");
client.callProcedure("@AdHoc", "INSERT INTO R2_ENG_11024 VALUES (-10, 'jjj', -10, -10);");
client.callProcedure("@AdHoc", "INSERT INTO P2_ENG_11024 VALUES (-11, 'jjj', -11, -11);");
client.callProcedure("@AdHoc", "INSERT INTO R2_ENG_11024 VALUES (-11, 'jjj', -11, -11);");
client.callProcedure("@AdHoc", "INSERT INTO P2_ENG_11024 VALUES (-12, 'mmm', -12, -12);");
client.callProcedure("@AdHoc", "INSERT INTO R2_ENG_11024 VALUES (-12, 'mmm', -12, -12);");
client.callProcedure("@AdHoc", "INSERT INTO P2_ENG_11024 VALUES (-13, 'mmm', -13, -13);");
client.callProcedure("@AdHoc", "INSERT INTO R2_ENG_11024 VALUES (-13, 'mmm', -13, -13);");
client.callProcedure("@AdHoc", "INSERT INTO P2_ENG_11024 VALUES (-14, 'bouSWVaJwQHtrp', -16078, 5.88087039394022959016e-02);");
client.callProcedure("@AdHoc", "INSERT INTO R2_ENG_11024 VALUES (-14, 'FOO', -16079, 9.88087039394022959016e-02);");
client.callProcedure("@AdHoc", "INSERT INTO P2_ENG_11024 VALUES (-15, 'NhFmPDULXEFLGI', 29960, 3.59831007623149345953e-01);");
client.callProcedure("@AdHoc", "INSERT INTO R2_ENG_11024 VALUES (-15, 'BAR', 29967, 7.59831007623149345953e-01);");
client.callProcedure("@AdHoc", "INSERT INTO P2_ENG_11024 VALUES (1, 'aaa', 1, 0);");
client.callProcedure("@AdHoc", "INSERT INTO R2_ENG_11024 VALUES (1, 'yyy', 1, 0);");
client.callProcedure("@AdHoc", "INSERT INTO P2_ENG_11024 VALUES (2, 'xxx', 2, 0);");
client.callProcedure("@AdHoc", "INSERT INTO R2_ENG_11024 VALUES (2, 'zzz', 2, 0);");
// The answers here and in the next query were determined by
// a judicious mix of testing and clever insertion. The last four
// insert statements above give the values in the second test.
cr = client.callProcedure("@AdHoc", "SELECT (A.NUM) AS Q5 FROM V21 A WHERE (A.NUM) = (A.ID - 14) ORDER BY 1 LIMIT 82;");
assertEquals(ClientResponse.SUCCESS, cr.getStatus());
vt = cr.getResults()[0];
assertEquals(1, vt.getRowCount());
vt.advanceRow();
assertEquals(-13, vt.getLong(0));
cr = client.callProcedure("@AdHoc", "SELECT (A.NUM) AS Q5 FROM V21 A WHERE (A.NUM) = (A.ID) ORDER BY 1 LIMIT 82;");
assertEquals(ClientResponse.SUCCESS, cr.getStatus());
vt = cr.getResults()[0];
assertEquals(1, vt.getRowCount());
vt.advanceRow();
assertEquals(1, vt.getLong(0));
}
use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class TestMaterializedViewSuite method subtestENG798.
/** Test a view that re-orders the source table's columns */
private void subtestENG798() throws IOException, ProcCallException {
if (isHSQL()) {
return;
}
// this would throw on a bad cast in the broken case.
Client client = getClient();
truncateBeforeTest(client);
ClientResponse callProcedure = client.callProcedure("Eng798Insert", "clientname");
assertTrue(callProcedure.getStatus() == ClientResponse.SUCCESS);
assertEquals(1, callProcedure.getResults().length);
assertEquals(1, callProcedure.getResults()[0].asScalarLong());
}
use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class TestMaterializedViewSuite method doTestMVFailedCase.
/**
* It's not allowed to have NOW or CURRENT_TIMESTAMP in a
* join condition or a where clause.
* @throws Exception
*/
public void doTestMVFailedCase(String sql, String pattern) throws Exception {
Client client = getClient();
ClientResponse cr = null;
client.callProcedure("@AdHoc", "drop view mv if exists");
String msg = null;
boolean success;
try {
cr = client.callProcedure("@AdHoc", sql);
success = true;
} catch (Exception ex) {
success = false;
msg = ex.getMessage();
}
client.callProcedure("@AdHoc", "drop view mv if exists");
assertFalse("Unexpected compilation success", success);
assertTrue("Did not find pattern \"" + pattern + "\" in error message.", msg.contains(pattern));
}
use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class TestLoadingSuite method testSinglePartitionLoad.
public void testSinglePartitionLoad() throws Exception {
Client client = getClient();
VoltTable table;
ClientResponse r;
// test simple success
table = m_template.clone(100);
table.addRow(1, 1, 1, "1", 1.0);
table.addRow(2, 1, 2, "2", 2.0);
r = client.callProcedure("@LoadSinglepartitionTable", VoltType.valueToBytes(1), "PARTITIONED", upsertMode, table);
assertEquals(ClientResponse.SUCCESS, r.getStatus());
assertEquals(1, r.getResults().length);
assertEquals(2, r.getResults()[0].asScalarLong());
assertEquals(2, countPartitionedRows(client));
// test failure to load replicated table from SP proc
try {
r = client.callProcedure("@LoadSinglepartitionTable", VoltType.valueToBytes(1), "REPLICATED", upsertMode, table);
// prev stmt should throw exception
fail();
} catch (ProcCallException e) {
e.printStackTrace();
}
assertEquals(0, countReplicatedRows(client));
// test rollback for constraint
table = m_template.clone(100);
table.addRow(3, 2, 3, "3", 3.0);
table.addRow(3, 2, 3, "3", 3.0);
try {
r = client.callProcedure("@LoadSinglepartitionTable", VoltType.valueToBytes(2), "PARTITIONED", upsertMode, table);
// prev stmt should throw exception
fail();
} catch (ProcCallException e) {
e.printStackTrace();
}
// 2 rows in the db from the previous test (3 for hsql)
if (// sadly, hsql is not super transactional as a backend
isHSQL())
assertEquals(3, countPartitionedRows(client));
else
assertEquals(2, countPartitionedRows(client));
}
Aggregations