@Test public void testToFloat() throws Exception { List<Row> rows = Collections.singletonList( new Row("str_col", "10000.00").add("int_col", 10000).add("double_col", 10000.00d) .add("short_col", new Short("10000")).add("long_col", 10000L).add("float_col", 10000.0f) .add("bytes_col", new byte[]{70, 28, 64, 0}) ); String[] directives = new String[] { "set-type str_col float", "set-type int_col Float", "set-type double_col FLOAT", "set-type short_col float", "set-type long_col Float", "set-type float_col FLOAT", "set-type bytes_col float" }; List<Row> results = TestingRig.execute(directives, rows); Row row = results.get(0); for (int i = 0; i < row.width(); i++) { Object object = row.getValue(i); Assert.assertTrue(object instanceof Float); Float value = (Float) object; Assert.assertTrue(value.equals(new Float(10000))); } }
@Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { ColumnConverter.convertType(NAME, row, col, type); } return rows; }
SetType implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { ColumnConverter.convertType(NAME, row, col, type); } return rows; } }
SetType implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { ColumnConverter.convertType(NAME, row, col, type); } return rows; }  }
SetType implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { ColumnConverter.convertType(NAME, row, col, type); } return rows; }  @Override UsageDefinition define(); @Override void initialize(Arguments args); @Override void destroy(); @Override List<Row> execute(List<Row> rows, ExecutorContext context); @Override Mutation lineage(); }
SetType implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { ColumnConverter.convertType(NAME, row, col, type); } return rows; }  @Override UsageDefinition define(); @Override void initialize(Arguments args); @Override void destroy(); @Override List<Row> execute(List<Row> rows, ExecutorContext context); @Override Mutation lineage(); static final String NAME; }