johnjcasey commented on code in PR #31802: URL: https://github.com/apache/beam/pull/31802#discussion_r1670968134
########## sdks/java/io/csv/src/main/java/org/apache/beam/sdk/io/csv/CsvIOParseHelpers.java: ########## @@ -48,8 +50,38 @@ static List<Schema.Field> mapFieldPositions(CSVFormat format, Schema schema) { * Parse the given {@link String} cell of the CSV record based on the given field's {@link * Schema.FieldType}. */ - // TODO(https://github.com/apache/beam/issues/31719): implement method. static Object parseCell(String cell, Schema.Field field) { - return ""; + Schema.FieldType fieldType = field.getType(); + try { + switch (fieldType.getTypeName()) { + case STRING: + return cell; + case INT16: + return Short.parseShort(cell); + case INT32: + return Integer.parseInt(cell); + case INT64: + return Long.parseLong(cell); + case BOOLEAN: + return Boolean.parseBoolean(cell); + case BYTE: + return Byte.parseByte(cell); + case DECIMAL: + return new BigDecimal(cell); + case DOUBLE: + return Double.parseDouble(cell); + case FLOAT: + return Float.parseFloat(cell); + case DATETIME: + return Instant.parse(cell); Review Comment: Is the value always going to be in a format such that instant can parse it? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org