use of org.voltdb.catalog.Database in project voltdb by VoltDB.
the class TestVoltCompiler method testDDLWithLongStringInCharacters.
public void testDDLWithLongStringInCharacters() throws IOException {
int length = VoltType.MAX_VALUE_LENGTH_IN_CHARACTERS + 10;
String schema1 = "create table books (cash integer default 23, " + "title varchar(" + length + ") default 'foo', PRIMARY KEY(cash));";
VoltCompiler compiler = new VoltCompiler(false);
final boolean success = compileDDL(schema1, compiler);
assertTrue(success);
// Check warnings
assertEquals(1, compiler.m_warnings.size());
String warningMsg = compiler.m_warnings.get(0).getMessage();
String expectedMsg = "The size of VARCHAR column TITLE in table BOOKS greater than " + "262144 will be enforced as byte counts rather than UTF8 character counts. " + "To eliminate this warning, specify \"VARCHAR(262154 BYTES)\"";
assertEquals(expectedMsg, warningMsg);
Database db = compiler.getCatalog().getClusters().get("cluster").getDatabases().get("database");
Column var = db.getTables().get("BOOKS").getColumns().get("TITLE");
assertTrue(var.getInbytes());
}
use of org.voltdb.catalog.Database in project voltdb by VoltDB.
the class TestVoltCompilerAlterDropTable method verifyIndexExists.
//Check given index exists
private void verifyIndexExists(VoltCompiler compiler, String tableName, String idxName) {
Database db = compiler.m_catalog.getClusters().get("cluster").getDatabases().get("database");
Table table = db.getTables().get(tableName);
Index idx = table.getIndexes().get(idxName);
assertNotNull(idx);
}
use of org.voltdb.catalog.Database in project voltdb by VoltDB.
the class TestVoltCompilerAlterDropTable method verifyTableColumnType.
//Check given col type if catalog was compiled.
private void verifyTableColumnType(VoltCompiler compiler, String tableName, String colName, VoltType type) {
Database db = compiler.m_catalog.getClusters().get("cluster").getDatabases().get("database");
Table table = db.getTables().get(tableName);
Column col = table.getColumns().get(colName);
assertNotNull(col);
assertEquals(0, type.compareTo(VoltType.get((byte) col.getType())));
}
use of org.voltdb.catalog.Database in project voltdb by VoltDB.
the class TestVoltCompiler method testValidAnnotatedProcedureDLL.
public void testValidAnnotatedProcedureDLL() throws Exception {
String schema = "create table books" + " (cash integer default 23 not null," + " title varchar(3) default 'foo'," + " PRIMARY KEY(cash));" + "PARTITION TABLE books ON COLUMN cash;" + "creAte PrOcEdUrE FrOm CLasS org.voltdb.compiler.procedures.AddBook;";
VoltCompiler compiler = new VoltCompiler(false);
final boolean success = compileDDL(schema, compiler);
assertTrue(success);
String catalogContents = VoltCompilerUtils.readFileFromJarfile(testout_jar, "catalog.txt");
Catalog c2 = new Catalog();
c2.execute(catalogContents);
Database db = c2.getClusters().get("cluster").getDatabases().get("database");
Procedure addBook = db.getProcedures().get("AddBook");
assertTrue(addBook.getSinglepartition());
}
use of org.voltdb.catalog.Database in project voltdb by VoltDB.
the class TestVoltCompiler method testOverrideNonAnnotatedProcInfo.
public void testOverrideNonAnnotatedProcInfo() throws IOException {
String schema = "create table books" + " (cash integer default 23 not null," + " title varchar(3) default 'foo'," + " PRIMARY KEY(cash));" + "PARTITION TABLE books ON COLUMN cash;" + "create procedure from class org.voltdb.compiler.procedures.AddBook;" + "partition procedure AddBook ON TABLE books COLUMN cash;";
ProcInfoData info = new ProcInfoData();
info.singlePartition = true;
info.partitionInfo = "BOOKS.CASH: 0";
Map<String, ProcInfoData> overrideMap = new HashMap<>();
overrideMap.put("AddBook", info);
VoltCompiler compiler = new VoltCompiler(false);
compiler.setProcInfoOverrides(overrideMap);
final boolean success = compileDDL(schema, compiler);
assertTrue(success);
String catalogContents = VoltCompilerUtils.readFileFromJarfile(testout_jar, "catalog.txt");
Catalog c2 = new Catalog();
c2.execute(catalogContents);
Database db = c2.getClusters().get("cluster").getDatabases().get("database");
Procedure addBook = db.getProcedures().get("AddBook");
assertTrue(addBook.getSinglepartition());
}
Aggregations