use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.
the class TestCatalogDiffs method testRemoveMaterializedView.
public void testRemoveMaterializedView() throws IOException {
String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
// with a view
VoltProjectBuilder builder = new VoltProjectBuilder();
builder.addLiteralSchema("\nCREATE TABLE A (C1 BIGINT NOT NULL, C2 BIGINT NOT NULL);");
builder.addLiteralSchema("\nCREATE TABLE B (C1 BIGINT NOT NULL, C2 BIGINT NOT NULL);");
builder.addLiteralSchema("\nCREATE VIEW MATVIEW(C1, NUM) AS " + "\n SELECT C1, COUNT(*) FROM A GROUP BY C1;");
builder.addLiteralSchema("\nCREATE VIEW MATVIEWJOIN(C1, NUM) AS " + "\n SELECT A.C1, COUNT(*) FROM A JOIN B ON A.C1=B.C2 GROUP BY A.C1;");
builder.addPartitionInfo("A", "C1");
builder.addProcedures(org.voltdb.catalog.ProcedureA.class);
assertTrue("Failed to compile schema", builder.compile(testDir + File.separator + "remmatview1.jar"));
Catalog catOriginal = catalogForJar(testDir + File.separator + "remmatview1.jar");
// without a view
builder = new VoltProjectBuilder();
builder.addLiteralSchema("\nCREATE TABLE A (C1 BIGINT NOT NULL, C2 BIGINT NOT NULL);");
builder.addLiteralSchema("\nCREATE TABLE B (C1 BIGINT NOT NULL, C2 BIGINT NOT NULL);");
builder.addPartitionInfo("A", "C1");
builder.addProcedures(org.voltdb.catalog.ProcedureA.class);
assertTrue("Failed to compile schema", builder.compile(testDir + File.separator + "remmatview2.jar"));
Catalog catUpdated = catalogForJar(testDir + File.separator + "remmatview2.jar");
verifyDiff(catOriginal, catUpdated);
}
use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.
the class TestCatalogDiffs method testModifyMaterializedViewDropPredicateRejected.
public void testModifyMaterializedViewDropPredicateRejected() throws IOException {
String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
// with a view
VoltProjectBuilder builder = new VoltProjectBuilder();
builder.addLiteralSchema("\nCREATE TABLE A (C1 BIGINT NOT NULL, C2 BIGINT NOT NULL);");
builder.addLiteralSchema("\nCREATE TABLE B (C1 BIGINT NOT NULL, C2 BIGINT NOT NULL);");
builder.addLiteralSchema("\nCREATE VIEW MATVIEW(C1, NUM) AS " + "\n SELECT C1, COUNT(*) FROM A WHERE C1 > 0 GROUP BY C1;");
builder.addLiteralSchema("\nCREATE VIEW MATVIEWJOIN(C1, NUM) AS " + "\n SELECT A.C1, COUNT(*) FROM A JOIN B ON A.C1=B.C2 WHERE A.C1 > 0 GROUP BY A.C1;");
builder.addPartitionInfo("A", "C1");
builder.addProcedures(org.voltdb.catalog.ProcedureA.class);
assertTrue("Failed to compile schema", builder.compile(testDir + File.separator + "droppredmatview1.jar"));
Catalog catOriginal = catalogForJar(testDir + File.separator + "droppredmatview1.jar");
// without a view
builder = new VoltProjectBuilder();
builder.addLiteralSchema("\nCREATE TABLE A (C1 BIGINT NOT NULL, C2 BIGINT NOT NULL);");
builder.addLiteralSchema("\nCREATE TABLE B (C1 BIGINT NOT NULL, C2 BIGINT NOT NULL);");
builder.addLiteralSchema("\nCREATE VIEW MATVIEW(C1, NUM) AS " + "\n SELECT C1, COUNT(*) FROM A GROUP BY C1;");
builder.addLiteralSchema("\nCREATE VIEW MATVIEWJOIN(C1, NUM) AS " + "\n SELECT A.C1, COUNT(*) FROM A JOIN B ON A.C1=B.C2 GROUP BY A.C1;");
builder.addPartitionInfo("A", "C1");
builder.addProcedures(org.voltdb.catalog.ProcedureA.class);
assertTrue("Failed to compile schema", builder.compile(testDir + File.separator + "droppredmatview2.jar"));
Catalog catUpdated = catalogForJar(testDir + File.separator + "droppredmatview2.jar");
verifyDiffRejected(catOriginal, catUpdated);
}
use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.
the class TestCatalogDiffs method testExpandUniqueNonCoveringTableIndex.
public void testExpandUniqueNonCoveringTableIndex() throws IOException {
String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
// start with a table
VoltProjectBuilder builder = new VoltProjectBuilder();
builder.addLiteralSchema("\nCREATE TABLE A (C1 BIGINT NOT NULL, C2 BIGINT NOT NULL, PRIMARY KEY(C1));");
builder.addPartitionInfo("A", "C1");
builder.addProcedures(org.voltdb.catalog.ProcedureA.class);
assertTrue("Failed to compile schema", builder.compile(testDir + File.separator + "testAddUniqueNonCoveringTableIndexRejected1.jar"));
Catalog catOriginal = catalogForJar(testDir + File.separator + "testAddUniqueNonCoveringTableIndexRejected1.jar");
// shrink the pkey index
builder = new VoltProjectBuilder();
builder.addLiteralSchema("\nCREATE TABLE A (C1 BIGINT NOT NULL, C2 BIGINT NOT NULL, PRIMARY KEY(C1, C2));");
builder.addPartitionInfo("A", "C1");
builder.addProcedures(org.voltdb.catalog.ProcedureA.class);
assertTrue("Failed to compile schema", builder.compile(testDir + File.separator + "testAddUniqueNonCoveringTableIndexRejected2.jar"));
Catalog catUpdated = catalogForJar(testDir + File.separator + "testAddUniqueNonCoveringTableIndexRejected2.jar");
verifyDiff(catOriginal, catUpdated);
}
use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.
the class TestCatalogDiffs method testRemoveNonUniqueIndex.
public void testRemoveNonUniqueIndex() throws IOException {
String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
// start with a table with an index
VoltProjectBuilder builder = new VoltProjectBuilder();
builder.addLiteralSchema("\nCREATE TABLE A (C1 BIGINT NOT NULL, C2 BIGINT NOT NULL, PRIMARY KEY(C1));");
builder.addLiteralSchema("\nCREATE INDEX IDX ON A(C1,C2);");
builder.addPartitionInfo("A", "C1");
builder.addProcedures(org.voltdb.catalog.ProcedureA.class);
assertTrue("Failed to compile schema", builder.compile(testDir + File.separator + "testRemoveNonUniqueIndex1.jar"));
Catalog catOriginal = catalogForJar(testDir + File.separator + "testRemoveNonUniqueIndex1.jar");
// remove the index
Catalog catUpdated = get2ColumnCatalogForTable("A", "testRemoveNonUniqueIndex2");
verifyDiff(catOriginal, catUpdated);
}
use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.
the class TestCatalogDiffs method testAddMaterializedView.
public void testAddMaterializedView() throws IOException {
String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
VoltProjectBuilder builder = new VoltProjectBuilder();
builder.addLiteralSchema("\nCREATE TABLE A (C1 BIGINT NOT NULL, C2 BIGINT NOT NULL);");
builder.addLiteralSchema("\nCREATE TABLE B (C1 BIGINT NOT NULL, C2 BIGINT NOT NULL);");
builder.addPartitionInfo("A", "C1");
builder.addProcedures(org.voltdb.catalog.ProcedureA.class);
assertTrue("Failed to compile schema", builder.compile(testDir + File.separator + "addmatview1.jar"));
Catalog catOriginal = catalogForJar(testDir + File.separator + "addmatview1.jar");
builder.addLiteralSchema("\nCREATE VIEW MATVIEW(C1, NUM) AS " + "\n SELECT C1, COUNT(*) FROM A GROUP BY C1;");
builder.addLiteralSchema("\nCREATE VIEW MATVIEWJOIN(C1, NUM) AS " + "\n SELECT A.C1, COUNT(*) FROM A JOIN B ON A.C1=B.C2 GROUP BY A.C1;");
assertTrue("Failed to compile schema", builder.compile(testDir + File.separator + "addmatview2.jar"));
Catalog catUpdated = catalogForJar(testDir + File.separator + "addmatview2.jar");
verifyDiff(catOriginal, catUpdated);
}
Aggregations