Add JSON Path expression evaluation support (#7315)

- Includes support for FROM clause JSON path
This commit is contained in:
Aditya Manthramurthy
2019-03-09 08:13:37 -08:00
committed by Harshavardhana
parent b296b3cf8b
commit e463386921
15 changed files with 488 additions and 59 deletions

View File

@@ -17,7 +17,6 @@
package json
import (
"encoding/json"
"io"
"github.com/minio/minio/pkg/s3select/sql"
@@ -43,24 +42,22 @@ func (r *Reader) Read() (sql.Record, error) {
return nil, io.EOF
}
var data []byte
var err error
var kvs jstream.KVS
if v.ValueType == jstream.Object {
data, err = json.Marshal(v.Value)
// This is a JSON object type (that preserves key
// order)
kvs = v.Value.(jstream.KVS)
} else {
// To be AWS S3 compatible Select for JSON needs to
// output non-object JSON as single column value
// i.e. a map with `_1` as key and value as the
// non-object.
data, err = json.Marshal(jstream.KVS{jstream.KV{Key: "_1", Value: v.Value}})
}
if err != nil {
return nil, errJSONParsingError(err)
kvs = jstream.KVS{jstream.KV{Key: "_1", Value: v.Value}}
}
return &Record{
Data: data,
KVS: kvs,
SelectFormat: sql.SelectFmtJSON,
}, nil
}