mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-12 23:51:03 +00:00
add checks for data presence on import req
This commit is contained in:
parent
e769c085ae
commit
002b65c516
2 changed files with 10 additions and 1 deletions
7
api.go
7
api.go
|
|
@ -1760,6 +1760,9 @@ func (api *API) ImportValueWithTx(ctx context.Context, qcx *Qcx, req *ImportValu
|
|||
|
||||
// if we're importing into a specific shard
|
||||
if req.Shard != math.MaxUint64 {
|
||||
if len(req.ColumnIDs) == 0 {
|
||||
return errors.Wrap(err, "calculating shard, no columns in request")
|
||||
}
|
||||
// Check that column IDs match the stated shard.
|
||||
shard := req.ColumnIDs[0] / ShardWidth
|
||||
if s2 := req.ColumnIDs[len(req.ColumnIDs)-1] / ShardWidth; (shard != s2) || (shard != req.Shard) {
|
||||
|
|
@ -1798,7 +1801,9 @@ func (api *API) ImportValueWithTx(ctx context.Context, qcx *Qcx, req *ImportValu
|
|||
return errors.Wrap(err, "importing value")
|
||||
|
||||
} // end if req.Shard != math.MaxUint64
|
||||
|
||||
if len(req.ColumnIDs) == 0 {
|
||||
return errors.Wrap(err, "calculating shard, no columns in request")
|
||||
}
|
||||
options.IgnoreKeyCheck = true
|
||||
start := 0
|
||||
shard := req.ColumnIDs[0] / ShardWidth
|
||||
|
|
|
|||
|
|
@ -2721,6 +2721,10 @@ func (h *Handler) handlePostImport(w http.ResponseWriter, r *http.Request) {
|
|||
qcx := h.api.Txf().NewQcx()
|
||||
defer qcx.Abort()
|
||||
|
||||
if len(req.Values) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if err := h.api.ImportValue(r.Context(), qcx, req, opts...); err != nil {
|
||||
switch errors.Cause(err) {
|
||||
case pilosa.ErrClusterDoesNotOwnShard, pilosa.ErrPreconditionFailed:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue