Search in sources :

Example 11 with Database

use of org.voltdb.catalog.Database in project voltdb by VoltDB.

the class TestVoltCompiler method testCreateTableWithGeographyPointValue.

public void testCreateTableWithGeographyPointValue() throws Exception {
    String ddl = "create table points (" + "  id integer," + "  pt geography_point" + ");";
    Database db = goodDDLAgainstSimpleSchema(ddl);
    assertNotNull(db);
    Table pointTable = db.getTables().getIgnoreCase("points");
    assertNotNull(pointTable);
    Column pointCol = pointTable.getColumns().getIgnoreCase("pt");
    assertEquals(VoltType.GEOGRAPHY_POINT.getValue(), pointCol.getType());
}
Also used : Table(org.voltdb.catalog.Table) Column(org.voltdb.catalog.Column) Database(org.voltdb.catalog.Database)

Example 12 with Database

use of org.voltdb.catalog.Database in project voltdb by VoltDB.

the class TestVoltCompiler method testGoodCreateStream.

public void testGoodCreateStream() throws Exception {
    Database db;
    db = goodDDLAgainstSimpleSchema("create stream e1 (id integer, f1 varchar(16));");
    assertNotNull(getConnectorTableInfoFor(db, "e1", Constants.DEFAULT_EXPORT_CONNECTOR_NAME));
    db = goodDDLAgainstSimpleSchema("create stream e1 (id integer, f1 varchar(16));", "create stream e2 partition on column id (id integer not null, f1 varchar(16));", "create stream e3 export to target bar (id integer, f1 varchar(16));", "create stream e4 partition on column id export to target bar (id integer not null, f1 varchar(16));", "create stream e5 export to target bar partition on column id (id integer not null, f1 varchar(16));");
    assertNotNull(getConnectorTableInfoFor(db, "e1", Constants.DEFAULT_EXPORT_CONNECTOR_NAME));
    assertEquals(null, getPartitionColumnInfoFor(db, "e1"));
    assertNotNull(getConnectorTableInfoFor(db, "e2", Constants.DEFAULT_EXPORT_CONNECTOR_NAME));
    assertEquals("ID", getPartitionColumnInfoFor(db, "e2"));
    assertNotNull(getConnectorTableInfoFor(db, "e3", "bar"));
    assertEquals(null, getPartitionColumnInfoFor(db, "e3"));
    assertNotNull(getConnectorTableInfoFor(db, "e4", "bar"));
    assertEquals("ID", getPartitionColumnInfoFor(db, "e4"));
    assertNotNull(getConnectorTableInfoFor(db, "e5", "bar"));
    assertEquals("ID", getPartitionColumnInfoFor(db, "e5"));
    db = goodDDLAgainstSimpleSchema("CREATE STREAM User_Stream Partition On Column UserId" + " (UserId BIGINT NOT NULL, SessionStart TIMESTAMP);", "CREATE VIEW User_Logins (UserId, LoginCount)" + "AS SELECT UserId, Count(*) FROM User_Stream GROUP BY UserId;", "CREATE VIEW User_LoginLastTime (UserId, LoginCount, LoginLastTime)" + "AS SELECT UserId, Count(*), MAX(SessionStart) FROM User_Stream GROUP BY UserId;");
    assertNotNull(getViewInfoFor(db, "User_Stream", "User_Logins"));
    assertNotNull(getViewInfoFor(db, "User_Stream", "User_LoginLastTime"));
}
Also used : Database(org.voltdb.catalog.Database)

Example 13 with Database

use of org.voltdb.catalog.Database in project voltdb by VoltDB.

the class TestVoltCompiler method testGoodDRTable.

public void testGoodDRTable() throws Exception {
    Database db;
    db = goodDDLAgainstSimpleSchema("create table e1 (id integer not null, f1 varchar(16));", "partition table e1 on column id;", "dr table e1;");
    assertTrue(db.getTables().getIgnoreCase("e1").getIsdred());
    String schema = "create table e1 (id integer not null, f1 varchar(16));\n" + "create table e2 (id integer not null, f1 varchar(16));\n" + "partition table e1 on column id;";
    db = goodDDLAgainstSimpleSchema(schema, "dr table e1;", "DR TABLE E2;");
    assertTrue(db.getTables().getIgnoreCase("e1").getIsdred());
    assertTrue(db.getTables().getIgnoreCase("e2").getIsdred());
    // DR statement is order sensitive
    db = goodDDLAgainstSimpleSchema(schema, "dr table e2;", "dr table e2 disable;");
    assertFalse(db.getTables().getIgnoreCase("e2").getIsdred());
    db = goodDDLAgainstSimpleSchema(schema, "dr table e2 disable;", "dr table e2;");
    assertTrue(db.getTables().getIgnoreCase("e2").getIsdred());
    schema = "create table geogs ( id integer NOT NULL, " + " region1 geography NOT NULL, " + " point1 geography_point NOT NULL, " + " point2 geography_point NOT NULL);\n" + "partition table geogs on column id;\n";
    db = goodDDLAgainstSimpleSchema(schema, "dr table geogs;");
    assertTrue(db.getTables().getIgnoreCase("geogs").getIsdred());
    db = goodDDLAgainstSimpleSchema(schema, "dr table geogs;", "dr table geogs disable;");
    assertFalse(db.getTables().getIgnoreCase("geogs").getIsdred());
}
Also used : Database(org.voltdb.catalog.Database)

Example 14 with Database

use of org.voltdb.catalog.Database in project voltdb by VoltDB.

the class TestVoltCompiler method testGoodExportTable.

public void testGoodExportTable() throws Exception {
    Database db;
    db = goodDDLAgainstSimpleSchema("create stream e1 export to target e1 (id integer, f1 varchar(16));");
    assertNotNull(getConnectorTableInfoFor(db, "e1", "e1"));
    db = goodDDLAgainstSimpleSchema("create stream e1 export to target e1 (id integer, f1 varchar(16));", "create stream e2 export to target E2 (id integer, f1 varchar(16));");
    assertNotNull(getConnectorTableInfoFor(db, "e1", "e1"));
    assertNotNull(getConnectorTableInfoFor(db, "e2", "e2"));
}
Also used : Database(org.voltdb.catalog.Database)

Example 15 with Database

use of org.voltdb.catalog.Database 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)

Aggregations

Database (org.voltdb.catalog.Database)62 Table (org.voltdb.catalog.Table)22 Catalog (org.voltdb.catalog.Catalog)12 Cluster (org.voltdb.catalog.Cluster)10 File (java.io.File)9 Column (org.voltdb.catalog.Column)9 Procedure (org.voltdb.catalog.Procedure)9 IOException (java.io.IOException)5 VoltTable (org.voltdb.VoltTable)5 ArrayList (java.util.ArrayList)4 Group (org.voltdb.catalog.Group)4 Connector (org.voltdb.catalog.Connector)3 Constraint (org.voltdb.catalog.Constraint)3 Statement (org.voltdb.catalog.Statement)3 FileNotFoundException (java.io.FileNotFoundException)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 HashMap (java.util.HashMap)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 JAXBException (javax.xml.bind.JAXBException)2