use of org.pentaho.di.core.row.value.ValueMetaBigNumber in project pentaho-kettle by pentaho.
the class PostgreSQLDatabaseMetaTest method testSQLStatements.
@Test
public void testSQLStatements() {
assertEquals("SELECT * FROM FOO limit 1", nativeMeta.getSQLQueryFields("FOO"));
assertEquals("SELECT * FROM FOO limit 1", nativeMeta.getSQLTableExists("FOO"));
assertEquals("SELECT FOO FROM BAR limit 1", nativeMeta.getSQLColumnExists("FOO", "BAR"));
assertEquals("SELECT FOO FROM BAR limit 1", nativeMeta.getSQLQueryColumnFields("FOO", "BAR"));
assertEquals("SELECT relname AS sequence_name FROM pg_catalog.pg_statio_all_sequences", nativeMeta.getSQLListOfSequences());
assertEquals("SELECT nextval('FOO')", nativeMeta.getSQLNextSequenceValue("FOO"));
assertEquals("SELECT currval('FOO')", nativeMeta.getSQLCurrentSequenceValue("FOO"));
assertEquals("SELECT relname AS sequence_name FROM pg_catalog.pg_statio_all_sequences WHERE relname = 'foo'", nativeMeta.getSQLSequenceExists("FOO"));
assertEquals("ALTER TABLE FOO ADD COLUMN BAR TIMESTAMP", nativeMeta.getAddColumnStatement("FOO", new ValueMetaDate("BAR"), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD COLUMN BAR TIMESTAMP", nativeMeta.getAddColumnStatement("FOO", new ValueMetaTimestamp("BAR"), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD COLUMN BAR CHAR(1)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBoolean("BAR"), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD COLUMN BAR BIGINT", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 10, 0), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD COLUMN BAR BIGINT", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBigNumber("BAR", 10, 0), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD COLUMN BAR BIGINT", nativeMeta.getAddColumnStatement("FOO", new ValueMetaInteger("BAR", 10, 0), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD COLUMN BAR DOUBLE PRECISION", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 0, 0), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD COLUMN BAR INTEGER", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 5, 0), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD COLUMN BAR NUMERIC(13, 3)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 10, 3), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD COLUMN BAR NUMERIC(13, 3)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBigNumber("BAR", 10, 3), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD COLUMN BAR NUMERIC(25, 4)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBigNumber("BAR", 21, 4), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD COLUMN BAR TEXT", nativeMeta.getAddColumnStatement("FOO", new ValueMetaString("BAR", nativeMeta.getMaxVARCHARLength() + 2, 0), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD COLUMN BAR VARCHAR(15)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaString("BAR", 15, 0), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD COLUMN BAR BIGINT", // Bug here - invalid SQL
nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 10, -7), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD COLUMN BAR NUMERIC(29, 7)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBigNumber("BAR", 22, 7), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD COLUMN BAR DOUBLE PRECISION", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", -10, 7), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD COLUMN BAR NUMERIC(12, 7)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 5, 7), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD COLUMN BAR UNKNOWN", nativeMeta.getAddColumnStatement("FOO", new ValueMetaInternetAddress("BAR"), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD COLUMN BAR BIGSERIAL", nativeMeta.getAddColumnStatement("FOO", new ValueMetaInteger("BAR"), "BAR", true, "", false));
assertEquals("ALTER TABLE FOO ADD COLUMN BAR BIGSERIAL", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 26, 8), "BAR", true, "", false));
String lineSep = System.getProperty("line.separator");
assertEquals("ALTER TABLE FOO DROP COLUMN BAR", nativeMeta.getDropColumnStatement("FOO", new ValueMetaString("BAR", 15, 0), "", false, "", true));
assertEquals("ALTER TABLE FOO ADD COLUMN BAR_KTL VARCHAR(15);" + lineSep + "UPDATE FOO SET BAR_KTL=BAR;" + lineSep + "ALTER TABLE FOO DROP COLUMN BAR;" + lineSep + "ALTER TABLE FOO RENAME BAR_KTL TO BAR;" + lineSep, nativeMeta.getModifyColumnStatement("FOO", new ValueMetaString("BAR", 15, 0), "", false, "", true));
assertEquals("ALTER TABLE FOO ADD COLUMN BAR_KTL TEXT;" + lineSep + "UPDATE FOO SET BAR_KTL=BAR;" + lineSep + "ALTER TABLE FOO DROP COLUMN BAR;" + lineSep + "ALTER TABLE FOO RENAME BAR_KTL TO BAR;" + lineSep, nativeMeta.getModifyColumnStatement("FOO", new ValueMetaString("BAR"), "", false, "", true));
// some subclass of the MSSQL meta probably ...
odbcMeta.setSupportsBooleanDataType(true);
assertEquals("ALTER TABLE FOO ADD COLUMN BAR BOOLEAN", odbcMeta.getAddColumnStatement("FOO", new ValueMetaBoolean("BAR"), "", false, "", false));
odbcMeta.setSupportsBooleanDataType(false);
assertEquals("ALTER TABLE FOO ADD COLUMN BAR SMALLINT", nativeMeta.getAddColumnStatement("FOO", new ValueMetaInteger("BAR", 4, 0), "", true, "", false));
odbcMeta.setUsername("fOoUsEr");
assertEquals("select proname " + "from pg_proc, pg_user " + "where pg_user.usesysid = pg_proc.proowner " + "and upper(pg_user.usename) = 'FOOUSER' order by proname", odbcMeta.getSQLListOfProcedures());
assertEquals("LOCK TABLE FOO , BAR IN ACCESS EXCLUSIVE MODE;" + lineSep, nativeMeta.getSQLLockTables(new String[] { "FOO", "BAR" }));
assertNull(nativeMeta.getSQLUnlockTables(new String[] { "FOO" }));
}
use of org.pentaho.di.core.row.value.ValueMetaBigNumber in project pentaho-kettle by pentaho.
the class BlockingStep_PDI_11344_Test method createRowMetaInterface.
private static RowMetaInterface createRowMetaInterface() {
RowMetaInterface rm = new RowMeta();
ValueMetaInterface[] valuesMeta = { new ValueMetaString("field1"), new ValueMetaInteger("field2"), new ValueMetaNumber("field3"), new ValueMetaDate("field4"), new ValueMetaBoolean("field5"), new ValueMetaBigNumber("field6"), new ValueMetaBigNumber("field7") };
for (ValueMetaInterface aValuesMeta : valuesMeta) {
rm.addValueMeta(aValuesMeta);
}
return rm;
}
use of org.pentaho.di.core.row.value.ValueMetaBigNumber in project pentaho-kettle by pentaho.
the class GroupByIntIT method getTestRowMetaAndData.
List<RowMetaAndData> getTestRowMetaAndData(int count, Integer[] nulls) {
List<RowMetaAndData> list = new ArrayList<RowMetaAndData>();
RowMetaInterface rm = new RowMeta();
rm.addValueMeta(new ValueMetaString(KEY1));
rm.addValueMeta(new ValueMetaInteger(KEY2));
rm.addValueMeta(new ValueMetaNumber(KEY3));
rm.addValueMeta(new ValueMetaBigNumber(KEY4));
Object[] row = new Object[4];
List<Integer> nullsList = Arrays.asList(nulls);
for (int i = 0; i < count; i++) {
if (nullsList.contains(i)) {
for (int j = 0; j < row.length; j++) {
row[j] = null;
}
} else {
row[0] = "";
row[1] = 1L;
row[2] = 2.0;
row[3] = new BigDecimal(3);
}
list.add(new RowMetaAndData(rm, row));
}
return list;
}
use of org.pentaho.di.core.row.value.ValueMetaBigNumber in project pentaho-kettle by pentaho.
the class JaninoStepIT method createRowMetaInterface.
public RowMetaInterface createRowMetaInterface() {
RowMetaInterface rm = new RowMeta();
ValueMetaInterface[] valuesMeta = { new ValueMetaString("string"), new ValueMetaInteger("integer"), new ValueMetaNumber("number"), new ValueMetaBigNumber("bigdecimal"), new ValueMetaDate("date"), new ValueMetaBinary("binary"), new ValueMetaBoolean("bool"), new ValueMetaTimestamp("timestamp"), new ValueMetaInternetAddress("inetaddress") };
for (int i = 0; i < valuesMeta.length; i++) {
rm.addValueMeta(valuesMeta[i]);
}
return rm;
}
use of org.pentaho.di.core.row.value.ValueMetaBigNumber in project pentaho-kettle by pentaho.
the class TransSingleThreadIT method createRowMetaInterface.
public RowMetaInterface createRowMetaInterface() {
RowMetaInterface rm = new RowMeta();
ValueMetaInterface[] valuesMeta = { new ValueMetaString("field1"), new ValueMetaInteger("field2"), new ValueMetaNumber("field3"), new ValueMetaDate("field4"), new ValueMetaBoolean("field5"), new ValueMetaBigNumber("field6"), new ValueMetaBigNumber("field7") };
for (int i = 0; i < valuesMeta.length; i++) {
rm.addValueMeta(valuesMeta[i]);
}
return rm;
}
Aggregations