use of org.voltdb.compiler.VoltCompiler in project voltdb by VoltDB.
the class TestJdbcDatabaseMetaDataGenerator method testGetTypeInfo.
public void testGetTypeInfo() throws Exception {
String schema = "create table Table1 (Column1 varchar(200) not null, Column2 integer);" + "partition table Table1 on column Column1;" + "create procedure proc1 as select * from Table1 where Column1=?;" + "partition procedure proc1 on table Table1 column Column1;" + "create procedure proc2 as select * from Table1 where Column2=?;";
VoltCompiler c = compileForDDLTest2(schema);
JdbcDatabaseMetaDataGenerator dut = new JdbcDatabaseMetaDataGenerator(c.getCatalog(), null, new InMemoryJarfile(testout_jar));
VoltTable typeInfo = dut.getMetaData("typEINfo");
System.out.println(typeInfo);
// just do some minor sanity checks on size of table and that it contains the types
// we expect
HashMap<String, VoltType> expectedTypes = new HashMap<String, VoltType>();
for (VoltType type : VoltType.values()) {
if (type.isJdbcVisible()) {
expectedTypes.put(type.toSQLString().toUpperCase(), type);
}
}
assertEquals(expectedTypes.size(), typeInfo.getRowCount());
assertEquals(18, typeInfo.getColumnCount());
typeInfo.resetRowPosition();
while (typeInfo.advanceRow()) {
String gotName = typeInfo.getString("TYPE_NAME");
VoltType expectedType = expectedTypes.remove(gotName);
assertTrue(expectedType != null);
}
assertTrue(expectedTypes.isEmpty());
}
use of org.voltdb.compiler.VoltCompiler in project voltdb by VoltDB.
the class TestJdbcDatabaseMetaDataGenerator method testGetProcedureColumns.
public void testGetProcedureColumns() throws Exception {
String schema = "create table Table1 (Column1 varchar(200) not null, Column2 integer);" + "partition table Table1 on column Column1;" + "create procedure proc1 as select * from Table1 where Column1=?;" + "partition procedure proc1 on table Table1 column Column1;" + "create procedure proc2 as select * from Table1 where Column2=?;";
VoltCompiler c = compileForDDLTest2(schema);
System.out.println(c.getCatalog().serialize());
DefaultProcedureManager defaultProcs = new DefaultProcedureManager(c.getCatalogDatabase());
JdbcDatabaseMetaDataGenerator dut = new JdbcDatabaseMetaDataGenerator(c.getCatalog(), defaultProcs, new InMemoryJarfile(testout_jar));
VoltTable params = dut.getMetaData("ProcedureColumns");
System.out.println(params);
assertEquals(20, params.getColumnCount());
// 2 real and 2 crud inserts
assertEquals(4, params.getRowCount());
assertTrue(VoltTableTestHelpers.moveToMatchingRow(params, "PROCEDURE_NAME", "proc1"));
assertEquals("param0", params.get("COLUMN_NAME", VoltType.STRING));
assertEquals(VoltType.MAX_VALUE_LENGTH, params.get("PRECISION", VoltType.INTEGER));
assertEquals(VoltType.MAX_VALUE_LENGTH, params.get("LENGTH", VoltType.INTEGER));
assertEquals(VoltType.MAX_VALUE_LENGTH, params.get("CHAR_OCTET_LENGTH", VoltType.INTEGER));
assertEquals("PARTITION_PARAMETER", params.get("REMARKS", VoltType.STRING));
assertTrue(VoltTableTestHelpers.moveToMatchingRow(params, "PROCEDURE_NAME", "proc2"));
assertEquals("param0", params.get("COLUMN_NAME", VoltType.STRING));
assertEquals(VoltType.INTEGER.getLengthInBytesForFixedTypes() * 8 - 1, params.get("PRECISION", VoltType.INTEGER));
assertEquals(VoltType.INTEGER.getLengthInBytesForFixedTypes(), params.get("LENGTH", VoltType.INTEGER));
assertWithNullCheck(null, params.get("CHAR_OCTET_LENGTH", VoltType.INTEGER), params);
assertWithNullCheck(null, params.get("REMARKS", VoltType.STRING), params);
}
use of org.voltdb.compiler.VoltCompiler in project voltdb by VoltDB.
the class CatalogUtil method createTemporaryEmptyCatalogJarFile.
/**
* Build an empty catalog jar file.
* @return jar file or null (on failure)
* @throws IOException on failure to create temporary jar file
* @param isXDCR
*/
public static File createTemporaryEmptyCatalogJarFile(boolean isXDCR) throws IOException {
File emptyJarFile = File.createTempFile("catalog-empty", ".jar");
emptyJarFile.deleteOnExit();
VoltCompiler compiler = new VoltCompiler(isXDCR);
if (!compiler.compileEmptyCatalog(emptyJarFile.getAbsolutePath())) {
return null;
}
return emptyJarFile;
}
use of org.voltdb.compiler.VoltCompiler in project voltdb by VoltDB.
the class TestCanonicalDDLThroughSQLcmd method secondCanonicalDDLFromAdhoc.
private void secondCanonicalDDLFromAdhoc() throws Exception {
String pathToCatalog = Configuration.getPathToCatalogForTest("emptyDDL.jar");
String pathToDeployment = Configuration.getPathToCatalogForTest("emptyDDL.xml");
VoltCompiler compiler = new VoltCompiler(false);
VoltProjectBuilder builder = new VoltProjectBuilder();
builder.setUseDDLSchema(true);
boolean success = builder.compile(pathToCatalog);
assertTrue(success);
MiscUtils.copyFile(builder.getPathToDeployment(), pathToDeployment);
VoltDB.Configuration config = new VoltDB.Configuration();
config.m_pathToCatalog = pathToCatalog;
config.m_pathToDeployment = pathToDeployment;
startSystem(config);
m_client.callProcedure("@AdHoc", firstCanonicalDDL);
// First line of canonical DDL differs thanks to creation time. Avoid
// it in the comparison
// Sanity check that we're not trimming the entire fullddl.sql file away
assertTrue(firstCanonicalDDL.indexOf('\n') < 100);
String secondDDL = compiler.getCanonicalDDL();
assertEquals(firstCanonicalDDL.substring(firstCanonicalDDL.indexOf('\n')), secondDDL.substring(secondDDL.indexOf('\n')));
teardownSystem();
}
use of org.voltdb.compiler.VoltCompiler in project voltdb by VoltDB.
the class TestCanonicalDDLThroughSQLcmd method getFirstCanonicalDDL.
private String getFirstCanonicalDDL() throws Exception {
String pathToCatalog = Configuration.getPathToCatalogForTest("fullDDL.jar");
VoltCompiler compiler = new VoltCompiler(false);
final URL url = TestDDLFeatures.class.getResource("fullDDL.sql");
String pathToSchema = URLDecoder.decode(url.getPath(), "UTF-8");
boolean success = compiler.compileFromDDL(pathToCatalog, pathToSchema);
assertTrue(success);
return compiler.getCanonicalDDL();
}
Aggregations