use of org.pentaho.di.core.row.value.ValueMetaBigNumber in project pentaho-kettle by pentaho.
the class DetectLastRowStepIT method createResultRowMetaInterface.
public RowMetaInterface createResultRowMetaInterface() {
RowMetaInterface rm = new RowMeta();
ValueMetaInterface[] valuesMeta = { new ValueMetaString("field1"), new ValueMetaInteger("field2"), new ValueMetaNumber("field3"), new ValueMetaBoolean("field5"), new ValueMetaBigNumber("field6"), new ValueMetaBoolean("result") };
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 FormulaIT method getTestRowMetaAndData.
List<RowMetaAndData> getTestRowMetaAndData(BigDecimal[] value) {
List<RowMetaAndData> list = new ArrayList<RowMetaAndData>();
Object[] row = new Object[value.length];
RowMetaInterface rm = new RowMeta();
for (int i = 0; i < value.length; i++) {
rm.addValueMeta(new ValueMetaBigNumber(keys[i]));
row[i] = value[i];
}
list.add(new RowMetaAndData(rm, row));
return list;
}
use of org.pentaho.di.core.row.value.ValueMetaBigNumber in project pdi-dataservice-server-plugin by pentaho.
the class SqlTransGeneratorTest method testTypeHandlingWithAvg.
@Test
public void testTypeHandlingWithAvg() throws KettleException {
SQL sql = new SQL("SELECT avg( intVal ), avg( numericVal ), avg( bigNumber) FROM table");
RowMetaInterface rowMeta = new RowMeta();
rowMeta.addValueMeta(new ValueMetaInteger("intVal"));
rowMeta.addValueMeta(new ValueMetaNumber("numericVal"));
rowMeta.addValueMeta(new ValueMetaBigNumber("bigNumber"));
sql.parse(rowMeta);
SqlTransGenerator generator = new SqlTransGenerator(sql, 0);
SelectValuesMeta meta = (SelectValuesMeta) getStepByName(generator.generateTransMeta(), "Set Conversion");
assertThat(meta.getMeta().length, is(3));
// Integer should be converted to TYPE_NUMBER
assertThat(meta.getMeta()[0].getType(), is(TYPE_NUMBER));
// Other types should be left alone ( SelectMetadataChange.getType remains TYPE_NONE )
assertThat(meta.getMeta()[1].getType(), is(TYPE_NONE));
assertThat(meta.getMeta()[2].getType(), is(TYPE_NONE));
}
use of org.pentaho.di.core.row.value.ValueMetaBigNumber in project pentaho-kettle by pentaho.
the class Database method getQueryFieldsFromDatabaseMetaData.
public RowMetaInterface getQueryFieldsFromDatabaseMetaData() throws Exception {
ResultSet columns = connection.getMetaData().getColumns("", "", databaseMeta.getName(), "");
RowMetaInterface rowMeta = new RowMeta();
while (columns.next()) {
ValueMetaInterface valueMeta = null;
String name = columns.getString("COLUMN_NAME");
String type = columns.getString("SOURCE_DATA_TYPE");
int size = columns.getInt("COLUMN_SIZE");
if (type.equals("Integer") || type.equals("Long")) {
valueMeta = new ValueMetaInteger();
} else if (type.equals("BigDecimal") || type.equals("BigNumber")) {
valueMeta = new ValueMetaBigNumber();
} else if (type.equals("Double") || type.equals("Number")) {
valueMeta = new ValueMetaNumber();
} else if (type.equals("String")) {
valueMeta = new ValueMetaString();
} else if (type.equals("Date")) {
valueMeta = new ValueMetaDate();
} else if (type.equals("Boolean")) {
valueMeta = new ValueMetaBoolean();
} else if (type.equals("Binary")) {
valueMeta = new ValueMetaBinary();
} else if (type.equals("Timestamp")) {
valueMeta = new ValueMetaTimestamp();
} else if (type.equals("Internet Address")) {
valueMeta = new ValueMetaInternetAddress();
}
if (valueMeta != null) {
valueMeta.setName(name);
valueMeta.setComments(name);
valueMeta.setLength(size);
valueMeta.setOriginalColumnTypeName(type);
valueMeta.setConversionMask(columns.getString("SOURCE_MASK"));
valueMeta.setDecimalSymbol(columns.getString("SOURCE_DECIMAL_SYMBOL"));
valueMeta.setGroupingSymbol(columns.getString("SOURCE_GROUPING_SYMBOL"));
valueMeta.setCurrencySymbol(columns.getString("SOURCE_CURRENCY_SYMBOL"));
rowMeta.addValueMeta(valueMeta);
} else {
log.logBasic("Database.getQueryFields() ValueMetaInterface mapping not resolved for the column " + name);
rowMeta = null;
break;
}
}
if (rowMeta != null && !rowMeta.isEmpty()) {
return rowMeta;
} else {
throw new Exception("Error in Database.getQueryFields()");
}
}
use of org.pentaho.di.core.row.value.ValueMetaBigNumber in project pentaho-kettle by pentaho.
the class Database method getParameterMetaData.
public RowMetaInterface getParameterMetaData(PreparedStatement ps) {
RowMetaInterface par = new RowMeta();
try {
ParameterMetaData pmd = ps.getParameterMetaData();
for (int i = 1; i <= pmd.getParameterCount(); i++) {
String name = "par" + i;
int sqltype = pmd.getParameterType(i);
int length = pmd.getPrecision(i);
int precision = pmd.getScale(i);
ValueMetaInterface val;
switch(sqltype) {
case java.sql.Types.CHAR:
case java.sql.Types.VARCHAR:
val = new ValueMetaString(name);
break;
case java.sql.Types.BIGINT:
case java.sql.Types.INTEGER:
case java.sql.Types.NUMERIC:
case java.sql.Types.SMALLINT:
case java.sql.Types.TINYINT:
val = new ValueMetaInteger(name);
break;
case java.sql.Types.DECIMAL:
case java.sql.Types.DOUBLE:
case java.sql.Types.FLOAT:
case java.sql.Types.REAL:
val = new ValueMetaNumber(name);
break;
case java.sql.Types.DATE:
case java.sql.Types.TIME:
case java.sql.Types.TIMESTAMP:
val = new ValueMetaDate(name);
break;
case java.sql.Types.BOOLEAN:
case java.sql.Types.BIT:
val = new ValueMetaBoolean(name);
break;
default:
val = new ValueMetaNone(name);
break;
}
if (val.isNumeric() && (length > 18 || precision > 18)) {
val = new ValueMetaBigNumber(name);
}
par.addValueMeta(val);
}
} catch (AbstractMethodError e) {
// Oops: probably the database or JDBC doesn't support it.
return null;
} catch (SQLException e) {
return null;
} catch (Exception e) {
return null;
}
return par;
}
Aggregations