Skip to content

Commit

Permalink
[Go & Cpp] Fix vector type check
Browse files Browse the repository at this point in the history
Signed-off-by: sunby <[email protected]>
  • Loading branch information
sunby committed Oct 8, 2023
1 parent c58990f commit 1df493f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions cpp/src/storage/options.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "storage/options.h"
#include <arrow/type_fwd.h>
#include "arrow/type.h"
#include "common/status.h"

Expand Down Expand Up @@ -30,8 +31,9 @@ Status SchemaOptions::Validate(const arrow::Schema* schema) {
auto vector_field = schema->GetFieldByName(vector_column);
if (!vector_field) {
return Status::InvalidArgument("vector column is not exist");
} else if (vector_field->type()->id() != arrow::Type::FIXED_SIZE_BINARY) {
return Status::InvalidArgument("vector column is not fixed size binary");
} else if (vector_field->type()->id() != arrow::Type::FIXED_SIZE_BINARY &&
vector_field->type()->id() != arrow::Type::FIXED_SIZE_LIST) {
return Status::InvalidArgument("vector column is not fixed size binary or fixed size list");
}
} else {
return Status::InvalidArgument("vector column is empty");
Expand Down
4 changes: 2 additions & 2 deletions go/storage/schema/schema_option.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var (
ErrVersionColumnNotFound = errors.New("version column not found")
ErrVersionColumnType = errors.New("version column is not int64")
ErrVectorColumnNotFound = errors.New("vector column not found")
ErrVectorColumnType = errors.New("vector column is not fixed size binary")
ErrVectorColumnType = errors.New("vector column is not fixed size binary or fixed size list")
ErrVectorColumnEmpty = errors.New("vector column is empty")
)

Expand Down Expand Up @@ -69,7 +69,7 @@ func (o *SchemaOptions) Validate(schema *arrow.Schema) error {
vectorField, b := schema.FieldsByName(o.VectorColumn)
if !b {
return ErrVectorColumnNotFound
} else if vectorField[0].Type.ID() != arrow.FIXED_SIZE_BINARY {
} else if vectorField[0].Type.ID() != arrow.FIXED_SIZE_BINARY && vectorField[0].Type.ID() != arrow.FIXED_SIZE_LIST {
return ErrVectorColumnType
}
} else {
Expand Down

0 comments on commit 1df493f

Please sign in to comment.