Search in sources :

Example 11 with Catalog

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()));
}
Also used : Catalog(org.voltdb.catalog.Catalog)

Example 12 with Catalog

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();
    }
}
Also used : Connector(org.voltdb.catalog.Connector) File(java.io.File) Catalog(org.voltdb.catalog.Catalog)

Example 13 with Catalog

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();
    }
}
Also used : Connector(org.voltdb.catalog.Connector) File(java.io.File) Catalog(org.voltdb.catalog.Catalog)

Example 14 with Catalog

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);
    }
}
Also used : Table(org.voltdb.catalog.Table) Database(org.voltdb.catalog.Database) TPCCProjectBuilder(org.voltdb.benchmark.tpcc.TPCCProjectBuilder) Catalog(org.voltdb.catalog.Catalog)

Example 15 with Catalog

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();
}
Also used : UnsupportedEncodingException(java.io.UnsupportedEncodingException) Catalog(org.voltdb.catalog.Catalog) URL(java.net.URL) AllTpccSQL(org.voltdb.AllTpccSQL)

Aggregations

Catalog (org.voltdb.catalog.Catalog)44 File (java.io.File)21 Database (org.voltdb.catalog.Database)12 IOException (java.io.IOException)8 Table (org.voltdb.catalog.Table)7 InMemoryJarfile (org.voltdb.utils.InMemoryJarfile)6 CatalogContext (org.voltdb.CatalogContext)5 Procedure (org.voltdb.catalog.Procedure)5 DeploymentType (org.voltdb.compiler.deploymentfile.DeploymentType)5 DbSettings (org.voltdb.settings.DbSettings)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 TPCCProjectBuilder (org.voltdb.benchmark.tpcc.TPCCProjectBuilder)4 Cluster (org.voltdb.catalog.Cluster)4 VoltCompiler (org.voltdb.compiler.VoltCompiler)4 VoltProjectBuilder (org.voltdb.compiler.VoltProjectBuilder)4 FileInputStream (java.io.FileInputStream)3 HostMessenger (org.voltcore.messaging.HostMessenger)3 PlannerTool (org.voltdb.compiler.PlannerTool)3 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2