use of org.voltdb.catalog.Catalog in project voltdb by VoltDB.
the class TestVoltCompiler method testMaterializedView.
public void testMaterializedView() throws IOException {
String schema = "create table books (cash integer default 23 NOT NULL, title varchar(10) default 'foo', PRIMARY KEY(cash));\n" + "partition table books on column cash;\n" + "create table foo (cash integer not null);\n" + "create view matt (title, cash, num, foo) as select title, cash, count(*), sum(cash) from books group by title, cash;\n" + "create view matt2 (title, cash, num, foo) as select books.title, books.cash, count(*), sum(books.cash) from books join foo on books.cash = foo.cash group by books.title, books.cash;";
VoltCompiler compiler = new VoltCompiler(false);
final boolean success = compileDDL(schema, compiler);
assertTrue(success);
Catalog c1 = compiler.getCatalog();
String catalogContents = VoltCompilerUtils.readFileFromJarfile(testout_jar, "catalog.txt");
Catalog c2 = new Catalog();
c2.execute(catalogContents);
assertTrue(c2.serialize().equals(c1.serialize()));
}
use of org.voltdb.catalog.Catalog in project voltdb by VoltDB.
the class TestVoltCompiler method testExportTableCase.
// test that Export configuration is insensitive to the case of the table name
public void testExportTableCase() throws IOException {
if (!MiscUtils.isPro()) {
return;
}
// not supported in community
VoltProjectBuilder project = new VoltProjectBuilder();
project.addSchema(TestVoltCompiler.class.getResource("ExportTester-ddl.sql"));
project.addStmtProcedure("Dummy", "insert into a values (?, ?, ?);", "a.a_id: 0");
project.addExport(true);
try {
assertTrue(project.compile("/tmp/exportsettingstest.jar"));
String catalogContents = VoltCompilerUtils.readFileFromJarfile("/tmp/exportsettingstest.jar", "catalog.txt");
Catalog cat = new Catalog();
cat.execute(catalogContents);
CatalogUtil.compileDeployment(cat, project.getPathToDeployment(), false);
Connector connector = cat.getClusters().get("cluster").getDatabases().get("database").getConnectors().get(Constants.DEFAULT_EXPORT_CONNECTOR_NAME);
assertTrue(connector.getEnabled());
// Assert that all tables exist in the connector section of catalog
assertNotNull(connector.getTableinfo().getIgnoreCase("a"));
assertNotNull(connector.getTableinfo().getIgnoreCase("b"));
assertNotNull(connector.getTableinfo().getIgnoreCase("e"));
assertNotNull(connector.getTableinfo().getIgnoreCase("f"));
} finally {
File jar = new File("/tmp/exportsettingstest.jar");
jar.delete();
}
}
use of org.voltdb.catalog.Catalog in project voltdb by VoltDB.
the class TestVoltCompiler method testExportSetting.
// TestExportSuite tests most of these options are tested end-to-end; however need to test
// that a disabled connector is really disabled and that auth data is correct.
public void testExportSetting() throws IOException {
VoltProjectBuilder project = new VoltProjectBuilder();
project.addSchema(getClass().getResource("ExportTester-ddl.sql"));
project.addExport(false);
try {
assertTrue(project.compile("/tmp/exportsettingstest.jar"));
String catalogContents = VoltCompilerUtils.readFileFromJarfile("/tmp/exportsettingstest.jar", "catalog.txt");
Catalog cat = new Catalog();
cat.execute(catalogContents);
Connector connector = cat.getClusters().get("cluster").getDatabases().get("database").getConnectors().get(Constants.DEFAULT_EXPORT_CONNECTOR_NAME);
assertFalse(connector.getEnabled());
} finally {
File jar = new File("/tmp/exportsettingstest.jar");
jar.delete();
}
}
use of org.voltdb.catalog.Catalog in project voltdb by VoltDB.
the class TestDDLCompiler method testNullAnnotation.
public void testNullAnnotation() throws IOException {
Catalog catalog = new TPCCProjectBuilder().createTPCCSchemaCatalog();
Database catalog_db = catalog.getClusters().get("cluster").getDatabases().get("database");
for (Table t : catalog_db.getTables()) {
assertNotNull(((TableAnnotation) t.getAnnotation()).ddl);
}
}
use of org.voltdb.catalog.Catalog in project voltdb by VoltDB.
the class TestParsedStatements method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
Catalog catalog = TPCCProjectBuilder.getTPCCSchemaCatalog();
m_db = catalog.getClusters().get("cluster").getDatabases().get("database");
URL url = TPCCProjectBuilder.class.getResource("tpcc-ddl.sql");
m_hsql = HSQLInterface.loadHsqldb();
try {
m_hsql.runDDLFile(URLDecoder.decode(url.getPath(), "UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
System.exit(-1);
}
m_allSQL = new AllTpccSQL();
}
Aggregations