fhueske commented on a change in pull request #8030: [FLINK-11991] Set headers 
to use for CSV output
URL: https://github.com/apache/flink/pull/8030#discussion_r276163298
 
 

 ##########
 File path: flink-java/src/main/java/org/apache/flink/api/java/DataSet.java
 ##########
 @@ -1622,16 +1622,39 @@ public long count() throws Exception {
         * @see DataSet#writeAsText(String) Output files and directories
         */
        public DataSink<T> writeAsCsv(String filePath, String rowDelimiter, 
String fieldDelimiter, WriteMode writeMode) {
-               return internalWriteAsCsv(new Path(filePath), rowDelimiter, 
fieldDelimiter, writeMode);
+               return internalWriteAsCsv(new Path(filePath), rowDelimiter, 
fieldDelimiter, writeMode, null);
+       }
+
+       /**
+        * Writes a {@link Tuple} DataSet as CSV file(s) to the specified 
location with the specified field and line delimiters.
+        *
+        * <p><b>Note: Only a Tuple DataSet can written as a CSV file.</b>
+        * For each Tuple field the result of {@link Object#toString()} is 
written.
+        *
+        * @param filePath The path pointing to the location the CSV file is 
written to.
+        * @param rowDelimiter The row delimiter to separate Tuples.
+        * @param fieldDelimiter The field delimiter to separate Tuple fields.
+        * @param writeMode The behavior regarding existing files. Options are 
NO_OVERWRITE and OVERWRITE.
+        * @param headers Strings to use as headers for the CSV output.
+        *
+        * @see Tuple
+        * @see CsvOutputFormat
+        * @see DataSet#writeAsText(String) Output files and directories
+        */
+       public DataSink<T> writeAsCsv(String filePath, String rowDelimiter, 
String fieldDelimiter, WriteMode writeMode, String[] headers) {
 
 Review comment:
   There is a balance between having a good amount of shortcuts and a bloated 
API. 
   We do not want to add too specific methods to the `DataSet` class.
   
   I think we should keep the `DataSet` class as is it. If somebody wants to 
add header rows to their CSV files, they can manually create a 
`CsvOutputFormat`, configure it correspondingly, and call `DataSet.write()`.

----------------------------------------------------------------
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

Reply via email to