Search in sources :

Example 1 with ValueMetaBigNumber

use of org.pentaho.di.core.row.value.ValueMetaBigNumber in project pentaho-kettle by pentaho.

the class NeoviewDatabaseMetaTest method testGetValueFromResultSet.

@Test
public void testGetValueFromResultSet() throws Exception {
    Object rtn = null;
    ResultSet resultSet = Mockito.mock(ResultSet.class);
    ResultSetMetaData metaData = Mockito.mock(ResultSetMetaData.class);
    Mockito.when(resultSet.getMetaData()).thenReturn(metaData);
    Mockito.when(resultSet.getTimestamp(1)).thenReturn(new java.sql.Timestamp(65535));
    Mockito.when(resultSet.getTime(2)).thenReturn(new java.sql.Time(1000));
    // ValueMetaDate -> Timestamp
    Mockito.when(resultSet.getTimestamp(3)).thenReturn(new java.sql.Timestamp(65535));
    ValueMetaTimestamp ts = new ValueMetaTimestamp("FOO");
    ts.setOriginalColumnType(java.sql.Types.TIMESTAMP);
    ValueMetaDate tm = new ValueMetaDate("BAR");
    tm.setOriginalColumnType(java.sql.Types.TIME);
    ValueMetaDate dt = new ValueMetaDate("WIBBLE");
    dt.setOriginalColumnType(java.sql.Types.DATE);
    rtn = nativeMeta.getValueFromResultSet(resultSet, ts, 0);
    assertNotNull(rtn);
    assertEquals("java.sql.Timestamp", rtn.getClass().getName());
    rtn = nativeMeta.getValueFromResultSet(resultSet, tm, 1);
    assertNotNull(rtn);
    assertEquals("java.sql.Time", rtn.getClass().getName());
    rtn = nativeMeta.getValueFromResultSet(resultSet, dt, 2);
    assertNotNull(rtn);
    assertEquals("java.sql.Timestamp", rtn.getClass().getName());
    Mockito.when(resultSet.wasNull()).thenReturn(true);
    rtn = nativeMeta.getValueFromResultSet(resultSet, new ValueMetaString("WOBBLE"), 3);
    assertNull(rtn);
    // Verify that getDate is not called, getTime is called once, and getTimestamp was called 2 times (once for TimeStamp, once for Date)
    Mockito.verify(resultSet, Mockito.times(0)).getDate(Mockito.anyInt());
    Mockito.verify(resultSet, Mockito.times(1)).getTime(Mockito.anyInt());
    Mockito.verify(resultSet, Mockito.times(2)).getTimestamp(Mockito.anyInt());
    // Now that the date stuff is done, validate the behaviors of other aspects of getValueFromResultSet
    Mockito.when(resultSet.wasNull()).thenReturn(false);
    Mockito.when(resultSet.getBoolean(1)).thenReturn(new Boolean(true));
    Mockito.when(resultSet.getDouble(1)).thenReturn(new Double(15));
    Mockito.when(resultSet.getBigDecimal(1)).thenReturn(new BigDecimal("15"));
    Mockito.when(resultSet.getLong(1)).thenReturn(new Long("15"));
    Mockito.when(resultSet.getString(1)).thenReturn("ASTRING");
    Mockito.when(resultSet.getBytes(1)).thenReturn("ASTRING".getBytes());
    Blob mockBlob = Mockito.mock(Blob.class);
    byte[] bytes = "FOO".getBytes();
    ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
    Mockito.when(mockBlob.getBinaryStream()).thenReturn(bais);
    Mockito.when(mockBlob.length()).thenReturn(new Long(bytes.length));
    Mockito.when(mockBlob.getBytes(Mockito.anyLong(), Mockito.anyInt())).thenReturn(bytes);
    Mockito.when(resultSet.getBlob(1)).thenReturn(mockBlob);
    rtn = nativeMeta.getValueFromResultSet(resultSet, new ValueMetaBoolean("FOO"), 0);
    assertNotNull(rtn);
    assertTrue(rtn instanceof Boolean);
    rtn = nativeMeta.getValueFromResultSet(resultSet, new ValueMetaNumber("FOO", 15, 5), 0);
    assertNotNull(rtn);
    assertTrue(rtn instanceof Double);
    rtn = nativeMeta.getValueFromResultSet(resultSet, new ValueMetaBigNumber("FOO", 15, 5), 0);
    assertNotNull(rtn);
    assertTrue(rtn instanceof BigDecimal);
    rtn = nativeMeta.getValueFromResultSet(resultSet, new ValueMetaInteger("FOO", 5, 0), 0);
    assertNotNull(rtn);
    assertTrue(rtn instanceof Long);
    rtn = nativeMeta.getValueFromResultSet(resultSet, new ValueMetaString("FOO", 25, 0), 0);
    assertNotNull(rtn);
    assertTrue(rtn instanceof String);
    ValueMetaString binStr = new ValueMetaString("FOO");
    binStr.setStorageType(ValueMetaString.STORAGE_TYPE_BINARY_STRING);
    rtn = nativeMeta.getValueFromResultSet(resultSet, binStr, 0);
    assertNotNull(rtn);
    assertTrue(rtn instanceof byte[]);
    rtn = nativeMeta.getValueFromResultSet(resultSet, new ValueMetaBinary("FOO", 150, 0), 0);
    assertNotNull(rtn);
    assertTrue(rtn instanceof byte[]);
    try {
        Mockito.when(resultSet.getBoolean(15)).thenThrow(new SQLException("Expected Exception Here"));
        rtn = nativeMeta.getValueFromResultSet(resultSet, new ValueMetaBoolean("FOO"), 14);
        fail("Should not get here");
    } catch (Exception someException) {
        assertTrue(someException instanceof KettleDatabaseException);
    }
}
Also used : SQLException(java.sql.SQLException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) ValueMetaBoolean(org.pentaho.di.core.row.value.ValueMetaBoolean) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ResultSetMetaData(java.sql.ResultSetMetaData) ValueMetaNumber(org.pentaho.di.core.row.value.ValueMetaNumber) ValueMetaBigNumber(org.pentaho.di.core.row.value.ValueMetaBigNumber) ResultSet(java.sql.ResultSet) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaBoolean(org.pentaho.di.core.row.value.ValueMetaBoolean) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) ValueMetaTimestamp(org.pentaho.di.core.row.value.ValueMetaTimestamp) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) Blob(java.sql.Blob) BigDecimal(java.math.BigDecimal) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) SQLException(java.sql.SQLException) ValueMetaBinary(org.pentaho.di.core.row.value.ValueMetaBinary) ByteArrayInputStream(java.io.ByteArrayInputStream) Test(org.junit.Test)

Example 2 with ValueMetaBigNumber

use of org.pentaho.di.core.row.value.ValueMetaBigNumber in project pentaho-kettle by pentaho.

the class NetezzaDatabaseMetaTest method testGetFieldDefinition.

@Test
public void testGetFieldDefinition() {
    assertEquals("FOO date", nativeMeta.getFieldDefinition(new ValueMetaDate("FOO"), null, null, false, true, false));
    assertEquals("boolean", nativeMeta.getFieldDefinition(new ValueMetaBoolean("FOO"), null, null, false, false, false));
    assertEquals("", nativeMeta.getFieldDefinition(new ValueMetaInteger("FOO", 0, 0), null, null, false, false, false));
    assertEquals("byteint", nativeMeta.getFieldDefinition(new ValueMetaNumber("FOO", 1, 0), null, null, false, false, false));
    assertEquals("byteint", nativeMeta.getFieldDefinition(new ValueMetaBigNumber("FOO", 2, 0), null, null, false, false, false));
    assertEquals("smallint", nativeMeta.getFieldDefinition(new ValueMetaInteger("FOO", 3, 0), null, null, false, false, false));
    assertEquals("smallint", nativeMeta.getFieldDefinition(new ValueMetaInteger("FOO", 4, 0), null, null, false, false, false));
    for (int i = 5; i < 10; i++) {
        assertEquals("integer", nativeMeta.getFieldDefinition(new ValueMetaInteger("FOO", i, 0), null, null, false, false, false));
    }
    assertEquals("bigint", nativeMeta.getFieldDefinition(new ValueMetaInteger("FOO", 10, 0), null, null, false, false, false));
    assertEquals("", nativeMeta.getFieldDefinition(new ValueMetaNumber("FOO", -22, 3), null, null, false, false, false));
    assertEquals("", nativeMeta.getFieldDefinition(new ValueMetaNumber("FOO", 0, 3), null, null, false, false, false));
    assertEquals("real", // pretty sure this is a bug ...
    nativeMeta.getFieldDefinition(new ValueMetaNumber("FOO", 1, 3), null, null, false, false, false));
    assertEquals("real", // pretty sure this is a bug ...
    nativeMeta.getFieldDefinition(new ValueMetaNumber("FOO", 2, 3), null, null, false, false, false));
    for (int i = 3; i < 9; i++) {
        assertEquals("real", nativeMeta.getFieldDefinition(new ValueMetaNumber("FOO", i, 3), null, null, false, false, false));
    }
    for (int i = 10; i < 18; i++) {
        assertEquals("double", nativeMeta.getFieldDefinition(new ValueMetaNumber("FOO", i, 3), null, null, false, false, false));
    }
    assertEquals("numeric(18, 3)", nativeMeta.getFieldDefinition(new ValueMetaNumber("FOO", 18, 3), null, null, false, false, false));
    assertEquals("numeric(19)", nativeMeta.getFieldDefinition(new ValueMetaNumber("FOO", 19, -12), null, null, false, false, false));
    assertEquals("varchar(32767)", nativeMeta.getFieldDefinition(new ValueMetaString("FOO", (NetezzaDatabaseMeta.MAX_CHAR_LEN + 2), 0), null, null, false, false, false));
    assertEquals("varchar(10)", nativeMeta.getFieldDefinition(new ValueMetaString("FOO", 10, 0), null, null, false, false, false));
    assertEquals(" UNKNOWN", nativeMeta.getFieldDefinition(new ValueMetaBinary("FOO", 10, 0), null, null, false, false, false));
    String lineSep = System.getProperty("line.separator");
    assertEquals(" UNKNOWN" + lineSep, nativeMeta.getFieldDefinition(new ValueMetaBinary("FOO", 10, 0), null, null, false, false, true));
}
Also used : ValueMetaBinary(org.pentaho.di.core.row.value.ValueMetaBinary) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaNumber(org.pentaho.di.core.row.value.ValueMetaNumber) ValueMetaBigNumber(org.pentaho.di.core.row.value.ValueMetaBigNumber) 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 3 with ValueMetaBigNumber

use of org.pentaho.di.core.row.value.ValueMetaBigNumber in project pentaho-kettle by pentaho.

the class RowMetaAndDataTest method testEmptyValues.

@Test
public void testEmptyValues() throws Exception {
    RowMeta rowsMetaEmpty = new RowMeta();
    rowsMetaEmpty.addValueMeta(new ValueMetaString("str"));
    rowsMetaEmpty.addValueMeta(new ValueMetaBoolean("bool"));
    rowsMetaEmpty.addValueMeta(new ValueMetaInteger("int"));
    rowsMetaEmpty.addValueMeta(new ValueMetaNumber("num"));
    rowsMetaEmpty.addValueMeta(new ValueMetaBigNumber("bignum"));
    rowsMetaEmpty.addValueMeta(new ValueMetaBinary("bin"));
    rowsMetaEmpty.addValueMeta(new ValueMetaDate("date"));
    rowsMetaEmpty.addValueMeta(new ValueMetaTimestamp("timestamp"));
    rowsMetaEmpty.addValueMeta(new ValueMetaInternetAddress("inet"));
    row = new RowMetaAndData(rowsMetaEmpty, null, null, null, null, null, null, null, null, null);
    assertTrue(row.isEmptyValue("str"));
    assertTrue(row.isEmptyValue("bool"));
    assertTrue(row.isEmptyValue("int"));
    assertTrue(row.isEmptyValue("num"));
    assertTrue(row.isEmptyValue("bignum"));
    assertTrue(row.isEmptyValue("bin"));
    assertTrue(row.isEmptyValue("date"));
    assertTrue(row.isEmptyValue("timestamp"));
    assertTrue(row.isEmptyValue("inet"));
}
Also used : ValueMetaBinary(org.pentaho.di.core.row.value.ValueMetaBinary) ValueMetaTimestamp(org.pentaho.di.core.row.value.ValueMetaTimestamp) 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) ValueMetaInternetAddress(org.pentaho.di.core.row.value.ValueMetaInternetAddress) ValueMetaBoolean(org.pentaho.di.core.row.value.ValueMetaBoolean) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) Test(org.junit.Test)

Example 4 with ValueMetaBigNumber

use of org.pentaho.di.core.row.value.ValueMetaBigNumber in project pentaho-kettle by pentaho.

the class DerbyDatabaseMetaTest method testSQLStatements.

@Test
public void testSQLStatements() {
    assertEquals("DELETE FROM FOO", nativeMeta.getTruncateTableStatement("FOO"));
    assertEquals("ALTER TABLE FOO ADD BAR TIMESTAMP", nativeMeta.getAddColumnStatement("FOO", new ValueMetaDate("BAR"), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR TIMESTAMP", nativeMeta.getAddColumnStatement("FOO", new ValueMetaTimestamp("BAR"), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR CHAR(1)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBoolean("BAR"), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR BIGINT", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 10, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR BIGINT", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBigNumber("BAR", 10, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR BIGINT", nativeMeta.getAddColumnStatement("FOO", new ValueMetaInteger("BAR", 10, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR SMALLINT", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 0, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR INTEGER", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 5, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR FLOAT", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 10, 3), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR FLOAT", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBigNumber("BAR", 10, 3), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR DECIMAL(21, 4)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBigNumber("BAR", 21, 4), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR CLOB", nativeMeta.getAddColumnStatement("FOO", new ValueMetaString("BAR", nativeMeta.getMaxVARCHARLength() + 2, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR BLOB", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBinary("BAR", nativeMeta.getMaxVARCHARLength() + 2, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR BLOB", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBinary("BAR"), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR BLOB", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBinary("BAR", 200, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR VARCHAR(15)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaString("BAR", 15, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR FLOAT", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 10, -7), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR DECIMAL(22, 7)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBigNumber("BAR", 22, 7), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR FLOAT", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", -10, 7), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR FLOAT", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 5, 7), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR UNKNOWN", nativeMeta.getAddColumnStatement("FOO", new ValueMetaInternetAddress("BAR"), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 0, INCREMENT BY 1)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaInteger("BAR"), "BAR", true, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 0, INCREMENT BY 1)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 26, 8), "BAR", true, "", false));
    String lineSep = System.getProperty("line.separator");
    assertEquals("ALTER TABLE FOO DROP BAR" + lineSep, nativeMeta.getDropColumnStatement("FOO", new ValueMetaString("BAR", 15, 0), "", false, "", true));
    assertEquals("ALTER TABLE FOO ALTER BAR VARCHAR(15)", nativeMeta.getModifyColumnStatement("FOO", new ValueMetaString("BAR", 15, 0), "", false, "", true));
    assertEquals("insert into FOO(FOOVERSION) values (1)", nativeMeta.getSQLInsertAutoIncUnknownDimensionRow("FOO", "FOOKEY", "FOOVERSION"));
}
Also used : ValueMetaTimestamp(org.pentaho.di.core.row.value.ValueMetaTimestamp) ValueMetaBinary(org.pentaho.di.core.row.value.ValueMetaBinary) 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 5 with ValueMetaBigNumber

use of org.pentaho.di.core.row.value.ValueMetaBigNumber in project pentaho-kettle by pentaho.

the class GenericDatabaseMetaTest method testSQLStatements.

@Test
public void testSQLStatements() {
    assertEquals("DELETE FROM FOO", nativeMeta.getTruncateTableStatement("FOO"));
    assertEquals("SELECT * FROM FOO", nativeMeta.getSQLQueryFields("FOO"));
    assertEquals("SELECT 1 FROM FOO", nativeMeta.getSQLTableExists("FOO"));
    assertEquals("ALTER TABLE FOO ADD BAR TIMESTAMP", nativeMeta.getAddColumnStatement("FOO", new ValueMetaDate("BAR"), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR TIMESTAMP", nativeMeta.getAddColumnStatement("FOO", new ValueMetaTimestamp("BAR"), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR CHAR(1)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBoolean("BAR"), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR BIGINT", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 10, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR BIGINT", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBigNumber("BAR", 10, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR BIGINT", nativeMeta.getAddColumnStatement("FOO", new ValueMetaInteger("BAR", 10, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR DOUBLE PRECISION", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 0, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR INTEGER", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 5, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR NUMERIC(10, 3)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 10, 3), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR NUMERIC(10, 3)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBigNumber("BAR", 10, 3), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR NUMERIC(21, 4)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBigNumber("BAR", 21, 4), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR TEXT", nativeMeta.getAddColumnStatement("FOO", new ValueMetaString("BAR", nativeMeta.getMaxVARCHARLength() + 2, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR VARCHAR(15)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaString("BAR", 15, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR BIGINT", // Bug here - invalid SQL
    nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 10, -7), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR NUMERIC(22, 7)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBigNumber("BAR", 22, 7), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR DOUBLE PRECISION", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", -10, 7), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR NUMERIC(5, 7)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 5, 7), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR  UNKNOWN", nativeMeta.getAddColumnStatement("FOO", new ValueMetaInternetAddress("BAR"), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR BIGSERIAL", nativeMeta.getAddColumnStatement("FOO", new ValueMetaInteger("BAR"), "BAR", true, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR BIGSERIAL", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 26, 8), "BAR", true, "", false));
    String lineSep = System.getProperty("line.separator");
    assertEquals("ALTER TABLE FOO DROP BAR" + lineSep, nativeMeta.getDropColumnStatement("FOO", new ValueMetaString("BAR", 15, 0), "", false, "", true));
    assertEquals("ALTER TABLE FOO MODIFY BAR VARCHAR(15)", nativeMeta.getModifyColumnStatement("FOO", new ValueMetaString("BAR", 15, 0), "", false, "", true));
    assertEquals("ALTER TABLE FOO MODIFY BAR VARCHAR()", // I think this is a bug ..
    nativeMeta.getModifyColumnStatement("FOO", new ValueMetaString("BAR"), "", false, "", true));
    assertEquals("ALTER TABLE FOO ADD BAR SMALLINT", nativeMeta.getAddColumnStatement("FOO", new ValueMetaInteger("BAR", 4, 0), "", true, "", false));
    // do a boolean check
    odbcMeta.setSupportsBooleanDataType(true);
    assertEquals("ALTER TABLE FOO ADD BAR BOOLEAN", odbcMeta.getAddColumnStatement("FOO", new ValueMetaBoolean("BAR"), "", false, "", false));
    odbcMeta.setSupportsBooleanDataType(false);
    assertEquals("ALTER TABLE FOO ADD BAR BIGSERIAL", nativeMeta.getAddColumnStatement("FOO", new ValueMetaInteger("BAR"), "BAR", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR BIGINT", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBigNumber("BAR", 10, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR NUMERIC(22, 0)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBigNumber("BAR", 22, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR VARCHAR(1)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaString("BAR", 1, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR TEXT", nativeMeta.getAddColumnStatement("FOO", new ValueMetaString("BAR", 16777250, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR  UNKNOWN", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBinary("BAR", 16777250, 0), "", false, "", false));
    assertEquals("insert into FOO(FOOVERSION) values (1)", nativeMeta.getSQLInsertAutoIncUnknownDimensionRow("FOO", "FOOKEY", "FOOVERSION"));
}
Also used : ValueMetaTimestamp(org.pentaho.di.core.row.value.ValueMetaTimestamp) ValueMetaBinary(org.pentaho.di.core.row.value.ValueMetaBinary) 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)

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