DataSetConversionUtil { public static Table toTable(Long sessionId, DataSet <Row> data, TableSchema schema) { return toTable(sessionId, data, schema.getFieldNames(), schema.getFieldTypes()); }  static DataSet <Row> fromTable(Long sessionId, Table table); static Table toTable(Long sessionId, DataSet <Row> data, TableSchema schema); static Table toTable(Long sessionId, DataSet <Row> data, String[] colNames, TypeInformation <?>[] colTypes); static Table toTable(Long sessionId, DataSet <Row> data, String[] colNames); static Table toTable(MLEnvironment session, DataSet <Row> data, String[] colNames, TypeInformation <?>[] colTypes); static Table toTable(MLEnvironment session, DataSet <Row> data, String[] colNames);  }
@Test public void testForceType() { ExecutionEnvironment env = MLEnvironmentFactory.getDefault().getExecutionEnvironment(); DataSet<Row> input = env.fromElements(Row.of("s1")).map(new GenericTypeMap()); Table table2 = DataSetConversionUtil.toTable(MLEnvironmentFactory.DEFAULT_ML_ENVIRONMENT_ID, input, new String[] {"word"}, new TypeInformation[] {TypeInformation.of(Integer.class)} ); Assert.assertEquals( new TableSchema(new String[] {"word"}, new TypeInformation[] {TypeInformation.of(Integer.class)}), table2.getSchema() ); }
@Test public void testExceptionWithoutTypeSchema() { thrown.expect(ValidationException.class); ExecutionEnvironment env = MLEnvironmentFactory.getDefault().getExecutionEnvironment(); DataSet<Row> input = env.fromElements(Row.of("s1")).map(new GenericTypeMap()); DataSetConversionUtil.toTable(MLEnvironmentFactory.DEFAULT_ML_ENVIRONMENT_ID, input, new String[] {"f0"}); }