Search in sources :

Example 26 with ValueMetaBigNumber

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" }));
}
Also used : ValueMetaTimestamp(org.pentaho.di.core.row.value.ValueMetaTimestamp) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaNumber(org.pentaho.di.core.row.value.ValueMetaNumber) ValueMetaBigNumber(org.pentaho.di.core.row.value.ValueMetaBigNumber) ValueMetaInternetAddress(org.pentaho.di.core.row.value.ValueMetaInternetAddress) ValueMetaBoolean(org.pentaho.di.core.row.value.ValueMetaBoolean) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) Test(org.junit.Test)

Example 27 with ValueMetaBigNumber

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;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) ValueMetaNumber(org.pentaho.di.core.row.value.ValueMetaNumber) ValueMetaBigNumber(org.pentaho.di.core.row.value.ValueMetaBigNumber) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaBoolean(org.pentaho.di.core.row.value.ValueMetaBoolean) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 28 with ValueMetaBigNumber

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;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) ArrayList(java.util.ArrayList) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) BigDecimal(java.math.BigDecimal) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ValueMetaNumber(org.pentaho.di.core.row.value.ValueMetaNumber) ValueMetaBigNumber(org.pentaho.di.core.row.value.ValueMetaBigNumber) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger)

Example 29 with ValueMetaBigNumber

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;
}
Also used : ValueMetaTimestamp(org.pentaho.di.core.row.value.ValueMetaTimestamp) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) ValueMetaInternetAddress(org.pentaho.di.core.row.value.ValueMetaInternetAddress) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaBoolean(org.pentaho.di.core.row.value.ValueMetaBoolean) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) ValueMetaBinary(org.pentaho.di.core.row.value.ValueMetaBinary) ValueMetaNumber(org.pentaho.di.core.row.value.ValueMetaNumber) ValueMetaBigNumber(org.pentaho.di.core.row.value.ValueMetaBigNumber) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate)

Example 30 with ValueMetaBigNumber

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;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) ValueMetaNumber(org.pentaho.di.core.row.value.ValueMetaNumber) ValueMetaBigNumber(org.pentaho.di.core.row.value.ValueMetaBigNumber) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaBoolean(org.pentaho.di.core.row.value.ValueMetaBoolean) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Aggregations

ValueMetaBigNumber (org.pentaho.di.core.row.value.ValueMetaBigNumber)34 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)31 ValueMetaNumber (org.pentaho.di.core.row.value.ValueMetaNumber)30 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)28 ValueMetaBoolean (org.pentaho.di.core.row.value.ValueMetaBoolean)25 ValueMetaDate (org.pentaho.di.core.row.value.ValueMetaDate)23 RowMeta (org.pentaho.di.core.row.RowMeta)21 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)18 Test (org.junit.Test)17 ValueMetaTimestamp (org.pentaho.di.core.row.value.ValueMetaTimestamp)15 ValueMetaInternetAddress (org.pentaho.di.core.row.value.ValueMetaInternetAddress)14 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)13 ValueMetaBinary (org.pentaho.di.core.row.value.ValueMetaBinary)13 BigDecimal (java.math.BigDecimal)6 ArrayList (java.util.ArrayList)4 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)4 KettleException (org.pentaho.di.core.exception.KettleException)4 SQLException (java.sql.SQLException)3 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)3 BatchUpdateException (java.sql.BatchUpdateException)2