From 360c6a3ea3415c2fba29fc9aa191ba06cdc7d36b Mon Sep 17 00:00:00 2001 From: Nathaniel Cook Date: Wed, 30 May 2018 13:55:24 -0600 Subject: [PATCH] fix(query/csv): Fix EOF causing error An EOF should not be reported as an error but as an indication that no more data is available. --- query/csv/result.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/query/csv/result.go b/query/csv/result.go index 504cd9eddf..3f33475960 100644 --- a/query/csv/result.go +++ b/query/csv/result.go @@ -115,6 +115,10 @@ func (r *resultIterator) More() bool { if r.err == nil { return true } + if r.err == io.EOF { + // Do not report EOF errors + r.err = nil + } } // Release the resources for this query. @@ -265,6 +269,10 @@ func readMetadata(r *csv.Reader, c ResultDecoderConfig, extraLine []string) (tab l, err := r.Read() if err != nil { if err == io.EOF { + if datatypes == nil && partitions == nil && defaults == nil { + // No, just pass the EOF up + return tableMetadata{}, err + } switch { case datatypes == nil: return tableMetadata{}, fmt.Errorf("missing expected annotation datatype") @@ -272,9 +280,6 @@ func readMetadata(r *csv.Reader, c ResultDecoderConfig, extraLine []string) (tab return tableMetadata{}, fmt.Errorf("missing expected annotation partition") case defaults == nil: return tableMetadata{}, fmt.Errorf("missing expected annotation default") - default: - // No, just pass the EOF up - return tableMetadata{}, err } } return tableMetadata{}, err