Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

Commit

Permalink
writer_util: fix csv format performance bug (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
lichunzhu authored Dec 3, 2020
1 parent 92b87b9 commit 598d56b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions v4/export/writer_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,11 @@ func WriteInsertInCsv(pCtx context.Context, tblIR TableDataIR, w storage.Writer,
counter uint64
lastCounter uint64
escapeBackSlash = tblIR.EscapeBackSlash()
selectedFields = tblIR.SelectedField()
err error
)

if !cfg.NoHeader && len(tblIR.ColumnNames()) != 0 && tblIR.SelectedField() != "" {
if !cfg.NoHeader && len(tblIR.ColumnNames()) != 0 && selectedFields != "" {
for i, col := range tblIR.ColumnNames() {
bf.Write(opt.delimiter)
escape([]byte(col), bf, getEscapeQuotation(escapeBackSlash, opt.delimiter))
Expand All @@ -312,7 +313,7 @@ func WriteInsertInCsv(pCtx context.Context, tblIR TableDataIR, w storage.Writer,

for fileRowIter.HasNext() {
lastBfSize := bf.Len()
if tblIR.SelectedField() != "" {
if selectedFields != "" {
if err = fileRowIter.Decode(row); err != nil {
log.Error("scanning from sql.Row failed", zap.Error(err))
return err
Expand Down

0 comments on commit 598d56b

Please sign in to comment.