S3 Select: Convert CSV data to JSON (#8464)

This commit is contained in:
Klaus Post
2019-11-09 20:10:35 +03:00
committed by kannappanr
parent 26863009c0
commit 1c90a6bd49
3 changed files with 169 additions and 5 deletions

View File

@@ -87,7 +87,13 @@ func (r *Record) Set(name string, value *sql.Value) error {
} else if value.IsNull() {
v = nil
} else if b, ok := value.ToBytes(); ok {
v = RawJSON(b)
// This can either be raw json or a CSV value.
// Only treat objects and arrays as JSON.
if len(b) > 0 && (b[0] == '{' || b[0] == '[') {
v = RawJSON(b)
} else {
v = string(b)
}
} else if arr, ok := value.ToArray(); ok {
v = arr
} else {