use of org.pentaho.di.core.row.value.ValueMetaInternetAddress in project pentaho-kettle by pentaho.
the class MemoryGroupByMetaTest method getInputRowMeta.
private RowMetaInterface getInputRowMeta() {
RowMetaInterface rm = new RowMeta();
rm.addValueMeta(new ValueMetaString("myGroupField2"));
rm.addValueMeta(new ValueMetaString("myGroupField1"));
rm.addValueMeta(new ValueMetaString("myString"));
rm.addValueMeta(new ValueMetaInteger("myInteger"));
rm.addValueMeta(new ValueMetaNumber("myNumber"));
rm.addValueMeta(new ValueMetaBigNumber("myBigNumber"));
rm.addValueMeta(new ValueMetaBinary("myBinary"));
rm.addValueMeta(new ValueMetaBoolean("myBoolean"));
rm.addValueMeta(new ValueMetaDate("myDate"));
rm.addValueMeta(new ValueMetaTimestamp("myTimestamp"));
rm.addValueMeta(new ValueMetaInternetAddress("myInternetAddress"));
return rm;
}
use of org.pentaho.di.core.row.value.ValueMetaInternetAddress 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.ValueMetaInternetAddress in project pentaho-kettle by pentaho.
the class CacheDatabaseMetaTest method testSQLStatements.
@Test
public void testSQLStatements() {
assertEquals("ALTER TABLE FOO ADD COLUMN ( BAR VARCHAR(15) ) ", cdm.getAddColumnStatement("FOO", new ValueMetaString("BAR", 15, 0), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD COLUMN ( BAR TIMESTAMP ) ", cdm.getAddColumnStatement("FOO", new ValueMetaDate("BAR"), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD COLUMN ( BAR TIMESTAMP ) ", cdm.getAddColumnStatement("FOO", new ValueMetaTimestamp("BAR"), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD COLUMN ( BAR CHAR(1) ) ", cdm.getAddColumnStatement("FOO", new ValueMetaBoolean("BAR"), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD COLUMN ( BAR INT ) ", cdm.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 0, 0), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD COLUMN ( BAR DOUBLE ) ", // I believe this is a bug!
cdm.getAddColumnStatement("FOO", new ValueMetaInteger("BAR"), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD COLUMN ( BAR DOUBLE ) ", cdm.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 10, -7), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD COLUMN ( BAR DOUBLE ) ", cdm.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", -10, 7), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD COLUMN ( BAR DECIMAL(5, 7) ) ", cdm.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 5, 7), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD COLUMN ( BAR UNKNOWN ) ", cdm.getAddColumnStatement("FOO", new ValueMetaInternetAddress("BAR"), "", false, "", false));
String lineSep = System.getProperty("line.separator");
assertEquals("ALTER TABLE FOO DROP COLUMN BAR" + lineSep, cdm.getDropColumnStatement("FOO", new ValueMetaString("BAR", 15, 0), "", false, "", true));
assertEquals("ALTER TABLE FOO ALTER COLUMN BAR VARCHAR(15)", cdm.getModifyColumnStatement("FOO", new ValueMetaString("BAR", 15, 0), "", false, "", true));
}
use of org.pentaho.di.core.row.value.ValueMetaInternetAddress in project pentaho-kettle by pentaho.
the class Exasol4DatabaseMetaTest method testSQLStatements.
@Test
public void testSQLStatements() {
assertEquals(" WHERE ROWNUM <= 15", nativeMeta.getLimitClause(15));
assertEquals("SELECT /*+FIRST_ROWS*/ * FROM FOO WHERE 1=0", nativeMeta.getSQLQueryFields("FOO"));
assertEquals("SELECT /*+FIRST_ROWS*/ * FROM FOO WHERE 1=0", nativeMeta.getSQLTableExists("FOO"));
assertEquals("SELECT /*+FIRST_ROWS*/ FOO FROM BAR WHERE 1=0", nativeMeta.getSQLQueryColumnFields("FOO", "BAR"));
assertEquals("SELECT /*+FIRST_ROWS*/ FOO FROM BAR WHERE 1=0", nativeMeta.getSQLColumnExists("FOO", "BAR"));
String lineSep = System.getProperty("line.separator");
assertEquals("ALTER TABLE FOO DROP COLUMN BAR" + lineSep, nativeMeta.getDropColumnStatement("FOO", new ValueMetaString("BAR", 15, 0), "", false, "", true));
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 BOOLEAN ) ", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBoolean("BAR"), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD ( BAR DECIMAL ) ", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR"), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD ( BAR DECIMAL ) ", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBigNumber("BAR"), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD ( BAR DECIMAL(15) ) ", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 15, 0), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD ( BAR DECIMAL(15) ) ", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBigNumber("BAR", 15, 0), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD ( BAR DECIMAL(15, 5) ) ", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 15, 5), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD ( BAR DECIMAL(15, 5) ) ", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBigNumber("BAR", 15, 5), "", false, "", false));
assertEquals("ALTER TABLE FOO ADD ( BAR INTEGER ) ", nativeMeta.getAddColumnStatement("FOO", new ValueMetaInteger("BAR"), "", 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 VARCHAR(2000000) ) ", nativeMeta.getAddColumnStatement("FOO", new ValueMetaString("BAR", nativeMeta.getMaxVARCHARLength() + 15, 0), "", 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 PRIMARY KEY ) ", nativeMeta.getAddColumnStatement("FOO", new ValueMetaInteger("BAR"), "BAR", false, "", false));
}
use of org.pentaho.di.core.row.value.ValueMetaInternetAddress in project pentaho-kettle by pentaho.
the class HypersonicDatabaseMetaTest method testSQLStatements.
@Test
public void testSQLStatements() throws Exception {
HypersonicDatabaseMeta nativeMeta = new HypersonicDatabaseMeta();
nativeMeta.setAccessType(DatabaseMeta.TYPE_ACCESS_NATIVE);
HypersonicDatabaseMeta odbcMeta = new HypersonicDatabaseMeta();
odbcMeta.setAccessType(DatabaseMeta.TYPE_ACCESS_ODBC);
assertEquals("TRUNCATE TABLE 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 LONGVARCHAR", 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 BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 0, INCREMENT BY 1) PRIMARY KEY", nativeMeta.getAddColumnStatement("FOO", new ValueMetaInteger("BAR"), "BAR", true, "", false));
assertEquals("ALTER TABLE FOO ADD BAR BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 0, INCREMENT BY 1) PRIMARY KEY", 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 COLUMN BAR VARCHAR(15)", nativeMeta.getModifyColumnStatement("FOO", new ValueMetaString("BAR", 15, 0), "", false, "", true));
assertEquals("ALTER TABLE FOO ALTER COLUMN 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 BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 0, INCREMENT BY 1) PRIMARY KEY", 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 LONGVARCHAR", 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(FOOKEY, FOOVERSION) values (0, 1)", nativeMeta.getSQLInsertAutoIncUnknownDimensionRow("FOO", "FOOKEY", "FOOVERSION"));
}
Aggregations