Skip to content

ci: enable sanitizer #129

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

Merged
merged 1 commit into from
Jun 27, 2025
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
4 changes: 2 additions & 2 deletions .github/workflows/sanitizer_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ jobs:
- name: Run Tests
working-directory: build
env:
ASAN_OPTIONS: log_path=out.log:detect_leaks=1:symbolize=1:strict_string_checks=1:halt_on_error=0:detect_container_overflow=0
ASAN_OPTIONS: log_path=out.log:detect_leaks=1:symbolize=1:strict_string_checks=1:halt_on_error=1:detect_container_overflow=0
LSAN_OPTIONS: suppressions=${{ github.workspace }}/.github/lsan-suppressions.txt
UBSAN_OPTIONS: log_path=out.log:halt_on_error=0:print_stacktrace=1:suppressions=${{ github.workspace }}/.github/ubsan-suppressions.txt
UBSAN_OPTIONS: log_path=out.log:halt_on_error=1:print_stacktrace=1:suppressions=${{ github.workspace }}/.github/ubsan-suppressions.txt
run: |
ctest --output-on-failure
- name: Save the test output
Expand Down
32 changes: 13 additions & 19 deletions src/iceberg/schema_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,9 @@ ArrowErrorCode ToArrowSchema(const Type& type, bool optional, std::string_view n

switch (type.type_id()) {
case TypeId::kStruct: {
NANOARROW_RETURN_NOT_OK(ArrowSchemaInitFromType(schema, NANOARROW_TYPE_STRUCT));

const auto& struct_type = static_cast<const StructType&>(type);
const auto& fields = struct_type.fields();
NANOARROW_RETURN_NOT_OK(ArrowSchemaAllocateChildren(schema, fields.size()));
NANOARROW_RETURN_NOT_OK(ArrowSchemaSetTypeStruct(schema, fields.size()));

for (size_t i = 0; i < fields.size(); i++) {
const auto& field = fields[i];
Expand All @@ -64,7 +62,7 @@ ArrowErrorCode ToArrowSchema(const Type& type, bool optional, std::string_view n
}
} break;
case TypeId::kList: {
NANOARROW_RETURN_NOT_OK(ArrowSchemaInitFromType(schema, NANOARROW_TYPE_LIST));
NANOARROW_RETURN_NOT_OK(ArrowSchemaSetType(schema, NANOARROW_TYPE_LIST));

const auto& list_type = static_cast<const ListType&>(type);
const auto& elem_field = list_type.fields()[0];
Expand All @@ -73,7 +71,7 @@ ArrowErrorCode ToArrowSchema(const Type& type, bool optional, std::string_view n
schema->children[0]));
} break;
case TypeId::kMap: {
NANOARROW_RETURN_NOT_OK(ArrowSchemaInitFromType(schema, NANOARROW_TYPE_MAP));
NANOARROW_RETURN_NOT_OK(ArrowSchemaSetType(schema, NANOARROW_TYPE_MAP));

const auto& map_type = static_cast<const MapType&>(type);
const auto& key_field = map_type.key();
Expand All @@ -86,61 +84,55 @@ ArrowErrorCode ToArrowSchema(const Type& type, bool optional, std::string_view n
schema->children[0]->children[1]));
} break;
case TypeId::kBoolean:
NANOARROW_RETURN_NOT_OK(ArrowSchemaInitFromType(schema, NANOARROW_TYPE_BOOL));
NANOARROW_RETURN_NOT_OK(ArrowSchemaSetType(schema, NANOARROW_TYPE_BOOL));
break;
case TypeId::kInt:
NANOARROW_RETURN_NOT_OK(ArrowSchemaInitFromType(schema, NANOARROW_TYPE_INT32));
NANOARROW_RETURN_NOT_OK(ArrowSchemaSetType(schema, NANOARROW_TYPE_INT32));
break;
case TypeId::kLong:
NANOARROW_RETURN_NOT_OK(ArrowSchemaInitFromType(schema, NANOARROW_TYPE_INT64));
NANOARROW_RETURN_NOT_OK(ArrowSchemaSetType(schema, NANOARROW_TYPE_INT64));
break;
case TypeId::kFloat:
NANOARROW_RETURN_NOT_OK(ArrowSchemaInitFromType(schema, NANOARROW_TYPE_FLOAT));
NANOARROW_RETURN_NOT_OK(ArrowSchemaSetType(schema, NANOARROW_TYPE_FLOAT));
break;
case TypeId::kDouble:
NANOARROW_RETURN_NOT_OK(ArrowSchemaInitFromType(schema, NANOARROW_TYPE_DOUBLE));
NANOARROW_RETURN_NOT_OK(ArrowSchemaSetType(schema, NANOARROW_TYPE_DOUBLE));
break;
case TypeId::kDecimal: {
ArrowSchemaInit(schema);
const auto& decimal_type = static_cast<const DecimalType&>(type);
NANOARROW_RETURN_NOT_OK(ArrowSchemaSetTypeDecimal(schema, NANOARROW_TYPE_DECIMAL128,
decimal_type.precision(),
decimal_type.scale()));
} break;
case TypeId::kDate:
NANOARROW_RETURN_NOT_OK(ArrowSchemaInitFromType(schema, NANOARROW_TYPE_DATE32));
NANOARROW_RETURN_NOT_OK(ArrowSchemaSetType(schema, NANOARROW_TYPE_DATE32));
break;
case TypeId::kTime: {
ArrowSchemaInit(schema);
NANOARROW_RETURN_NOT_OK(ArrowSchemaSetTypeDateTime(schema, NANOARROW_TYPE_TIME64,
NANOARROW_TIME_UNIT_MICRO,
/*timezone=*/nullptr));
} break;
case TypeId::kTimestamp: {
ArrowSchemaInit(schema);
NANOARROW_RETURN_NOT_OK(ArrowSchemaSetTypeDateTime(schema, NANOARROW_TYPE_TIMESTAMP,
NANOARROW_TIME_UNIT_MICRO,
/*timezone=*/nullptr));
} break;
case TypeId::kTimestampTz: {
ArrowSchemaInit(schema);
NANOARROW_RETURN_NOT_OK(ArrowSchemaSetTypeDateTime(
schema, NANOARROW_TYPE_TIMESTAMP, NANOARROW_TIME_UNIT_MICRO, "UTC"));
} break;
case TypeId::kString:
NANOARROW_RETURN_NOT_OK(ArrowSchemaInitFromType(schema, NANOARROW_TYPE_STRING));
NANOARROW_RETURN_NOT_OK(ArrowSchemaSetType(schema, NANOARROW_TYPE_STRING));
break;
case TypeId::kBinary:
NANOARROW_RETURN_NOT_OK(ArrowSchemaInitFromType(schema, NANOARROW_TYPE_BINARY));
NANOARROW_RETURN_NOT_OK(ArrowSchemaSetType(schema, NANOARROW_TYPE_BINARY));
break;
case TypeId::kFixed: {
ArrowSchemaInit(schema);
const auto& fixed_type = static_cast<const FixedType&>(type);
NANOARROW_RETURN_NOT_OK(ArrowSchemaSetTypeFixedSize(
schema, NANOARROW_TYPE_FIXED_SIZE_BINARY, fixed_type.length()));
} break;
case TypeId::kUuid: {
ArrowSchemaInit(schema);
NANOARROW_RETURN_NOT_OK(ArrowSchemaSetTypeFixedSize(
schema, NANOARROW_TYPE_FIXED_SIZE_BINARY, /*fixed_size=*/16));
NANOARROW_RETURN_NOT_OK(
Expand Down Expand Up @@ -173,6 +165,8 @@ Status ToArrowSchema(const Schema& schema, ArrowSchema* out) {
return InvalidArgument("Output Arrow schema cannot be null");
}

ArrowSchemaInit(out);

if (ArrowErrorCode errorCode = ToArrowSchema(schema, /*optional=*/false, /*name=*/"",
/*field_id=*/std::nullopt, out);
errorCode != NANOARROW_OK) {
Expand Down
4 changes: 4 additions & 0 deletions test/arrow_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ TEST_P(FromArrowSchemaTest, PrimitiveType) {

auto type_result = FromArrowSchema(exported_schema, /*schema_id=*/1);
ASSERT_THAT(type_result, IsOk());
ArrowSchemaRelease(&exported_schema);

const auto& schema = type_result.value();
ASSERT_EQ(schema->schema_id(), 1);
Expand Down Expand Up @@ -358,6 +359,7 @@ TEST(FromArrowSchemaTest, StructType) {

auto schema_result = FromArrowSchema(exported_schema, /*schema_id=*/0);
ASSERT_THAT(schema_result, IsOk());
ArrowSchemaRelease(&exported_schema);

const auto& iceberg_schema = schema_result.value();
ASSERT_EQ(iceberg_schema->schema_id(), 0);
Expand Down Expand Up @@ -408,6 +410,7 @@ TEST(FromArrowSchemaTest, ListType) {

auto schema_result = FromArrowSchema(exported_schema, /*schema_id=*/0);
ASSERT_THAT(schema_result, IsOk());
ArrowSchemaRelease(&exported_schema);

const auto& iceberg_schema = schema_result.value();
ASSERT_EQ(iceberg_schema->schema_id(), 0);
Expand Down Expand Up @@ -458,6 +461,7 @@ TEST(FromArrowSchemaTest, MapType) {

auto schema_result = FromArrowSchema(exported_schema, /*schema_id=*/0);
ASSERT_THAT(schema_result, IsOk());
ArrowSchemaRelease(&exported_schema);

const auto& iceberg_schema = schema_result.value();
ASSERT_EQ(iceberg_schema->schema_id(), 0);
Expand Down
Loading