S3 Select: Add parser support for lists. (#8329)

This commit is contained in:
Klaus Post
2019-10-06 07:52:45 -07:00
committed by Harshavardhana
parent e85df07518
commit 002ac82631
10 changed files with 487 additions and 63 deletions

View File

@@ -88,6 +88,8 @@ func (r *Record) Set(name string, value *sql.Value) error {
v = nil
} else if b, ok := value.ToBytes(); ok {
v = RawJSON(b)
} else if arr, ok := value.ToArray(); ok {
v = arr
} else {
return fmt.Errorf("unsupported sql value %v and type %v", value, value.GetTypeString())
}
@@ -109,8 +111,14 @@ func (r *Record) WriteCSV(writer io.Writer, fieldDelimiter rune) error {
columnValue = ""
case RawJSON:
columnValue = string([]byte(val))
case []interface{}:
b, err := json.Marshal(val)
if err != nil {
return err
}
columnValue = string(b)
default:
return errors.New("Cannot marshal unhandled type")
return fmt.Errorf("Cannot marshal unhandled type: %T", kv.Value)
}
csvRecord = append(csvRecord, columnValue)
}