nsivabalan commented on a change in pull request #1165: [HUDI-76] Add CSV
Source support for Hudi Delta Streamer
URL: https://github.com/apache/incubator-hudi/pull/1165#discussion_r385998155
##########
File path:
hudi-utilities/src/test/java/org/apache/hudi/utilities/UtilitiesTestBase.java
##########
@@ -193,19 +204,60 @@ public static void saveStringsToDFS(String[] lines,
FileSystem fs, String target
os.close();
}
+ /**
+ * Converts the json records into CSV format and writes to a file.
+ *
+ * @param hasHeader whether the CSV file should have a header line.
+ * @param sep the column separator to use.
+ * @param lines the records in JSON format.
+ * @param fs {@link FileSystem} instance.
+ * @param targetPath File path.
+ * @throws IOException
+ */
+ public static void saveCsvToDFS(
+ boolean hasHeader, char sep,
+ String[] lines, FileSystem fs, String targetPath) throws IOException {
+ Builder csvSchemaBuilder = CsvSchema.builder();
+
+ ArrayNode arrayNode = mapper.createArrayNode();
+ Arrays.stream(lines).forEachOrdered(
+ line -> {
+ try {
+ arrayNode.add(mapper.readValue(line, ObjectNode.class));
+ } catch (IOException e) {
+ e.printStackTrace();
Review comment:
don't we need to throw here as well?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services