Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Go & Cpp] Fix vector type check #70

Merged
merged 1 commit into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion cpp/test/options_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ TEST(SchemaOptionsTest, VectorColTypeTest) {
auto status = schema_options.Validate(schema.get());
ASSERT_FALSE(status.ok());
ASSERT_TRUE(status.IsInvalidArgument());
ASSERT_EQ("InvalidArgument: vector column is not fixed size binary", status.ToString());
ASSERT_EQ("InvalidArgument: vector column is not fixed size binary or fixed size list", status.ToString());

schema = CreateArrowSchema({"field1", "field2"}, {arrow::int64(), arrow::fixed_size_binary(8)});
status = schema_options.Validate(schema.get());
Expand Down
6 changes: 3 additions & 3 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,8 +69,8 @@ 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 {
return ErrVectorColumnType
} else if vectorField[0].Type.ID() != arrow.FIXED_SIZE_BINARY && vectorField[0].Type.ID() != arrow.FIXED_SIZE_LIST {
return ErrVectorColumnType
}
} else {
return ErrVectorColumnEmpty
Expand Down
Loading