Skip to content

Commit

Permalink
Snowflake: convert query output to string before printing (closes #166)
Browse files Browse the repository at this point in the history
  • Loading branch information
adatzer committed Jan 13, 2021
1 parent 77be034 commit a96e12c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions sql_runner/snowflake_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,9 @@ func printSfTable(rows *sql.Rows) error {
}

vals := make([]interface{}, len(cols))
for i := range cols {
vals[i] = new(sql.RawBytes)
rawResult := make([][]byte, len(cols))
for i := range rawResult {
vals[i] = &rawResult[i]
}

for rows.Next() {
Expand All @@ -147,7 +148,7 @@ func printSfTable(rows *sql.Rows) error {
}

if len(vals) > 0 {
outputBuffer = append(outputBuffer, stringify(vals))
outputBuffer = append(outputBuffer, stringify(rawResult))
}
}

Expand All @@ -167,10 +168,10 @@ func printSfTable(rows *sql.Rows) error {
return nil
}

func stringify(row []interface{}) []string {
func stringify(row [][]byte) []string {
var line []string
for _, element := range row {
line = append(line, fmt.Sprint(element))
line = append(line, fmt.Sprint(string(element)))
}
return line
}

0 comments on commit a96e12c

Please sign in to comment.