You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by sb...@apache.org on 2019/03/12 20:11:18 UTC

[arrow] branch master updated: ARROW-4826: [Go] export Flush method for CSV writer

This is an automated email from the ASF dual-hosted git repository.

sbinet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 6945227  ARROW-4826: [Go] export Flush method for CSV writer
6945227 is described below

commit 6945227123b8f2fe12ce153d05966546f1b91860
Author: Anson Qian <ab...@uber.com>
AuthorDate: Tue Mar 12 21:11:00 2019 +0100

    ARROW-4826: [Go] export Flush method for CSV writer
    
    @sbinet
    
    Author: Anson Qian <ab...@uber.com>
    
    Closes #3865 from anson627/ARROW-4826 and squashes the following commits:
    
    a9cd6fea <Anson Qian> Fix test
    19a2569d <Anson Qian> Expose error methold
    059e99bd <Anson Qian> Address code review
    dd4725c1 <Anson Qian> ARROW-4826:  export Flush method for CSV writer
---
 go/arrow/csv/writer.go      | 12 ++++++++++++
 go/arrow/csv/writer_test.go | 20 ++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/go/arrow/csv/writer.go b/go/arrow/csv/writer.go
index b8e0854..ded3fa2 100644
--- a/go/arrow/csv/writer.go
+++ b/go/arrow/csv/writer.go
@@ -127,3 +127,15 @@ func (w *Writer) Write(record array.Record) error {
 
 	return w.w.WriteAll(recs)
 }
+
+// Flush writes any buffered data to the underlying csv Writer.
+// If an error occurred during the Flush, return it
+func (w *Writer) Flush() error {
+	w.w.Flush()
+	return w.w.Error()
+}
+
+// Error reports any error that has occurred during a previous Write or Flush.
+func (w *Writer) Error() error {
+	return w.w.Error()
+}
diff --git a/go/arrow/csv/writer_test.go b/go/arrow/csv/writer_test.go
index d554a77..d5cb326 100644
--- a/go/arrow/csv/writer_test.go
+++ b/go/arrow/csv/writer_test.go
@@ -58,6 +58,16 @@ func Example_writer() {
 		log.Fatal(err)
 	}
 
+	err = w.Flush()
+	if err != nil {
+		log.Fatal(err)
+	}
+
+	err = w.Error()
+	if err != nil {
+		log.Fatal(err)
+	}
+
 	r := csv.NewReader(f, schema, csv.WithComment('#'), csv.WithComma(';'))
 	defer r.Release()
 
@@ -151,6 +161,16 @@ func TestCSVWriter(t *testing.T) {
 		t.Fatal(err)
 	}
 
+	err = w.Flush()
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	err = w.Error()
+	if err != nil {
+		t.Fatal(err)
+	}
+
 	want := `true;-1;-1;-1;-1;0;0;0;0;0;0;str-0
 false;0;0;0;0;1;1;1;1;0.1;0.1;str-1
 true;1;1;1;1;2;2;2;2;0.2;0.2;str-2