This is an automated email from the ASF dual-hosted git repository.
paleolimbot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-nanoarrow.git
The following commit(s) were added to refs/heads/main by this push:
new 29307875 test: Make Arrow C++ dependency optional (#677)
29307875 is described below
commit 29307875d266bf0112892f70cbf3b43aa41ac379
Author: William Ayd <[email protected]>
AuthorDate: Tue Nov 19 11:31:36 2024 -0500
test: Make Arrow C++ dependency optional (#677)
---
.github/workflows/build-and-test-device.yaml | 4 +-
.github/workflows/build-and-test-ipc.yaml | 4 +-
.github/workflows/build-and-test.yaml | 21 ++++-
.github/workflows/clang-tidy.yaml | 6 +-
.github/workflows/verify.yaml | 12 ++-
CMakeLists.txt | 78 +++++++++++++----
README.md | 19 +++--
ci/scripts/coverage.sh | 3 +-
meson.build | 12 ++-
meson.options | 1 +
src/nanoarrow/common/array_test.cc | 123 ++++++++++++++++++++++++++-
src/nanoarrow/common/schema_test.cc | 70 ++++++++++++++-
src/nanoarrow/common/utils_test.cc | 8 ++
src/nanoarrow/ipc/decoder_test.cc | 12 +++
src/nanoarrow/ipc/files_test.cc | 2 +
15 files changed, 331 insertions(+), 44 deletions(-)
diff --git a/.github/workflows/build-and-test-device.yaml
b/.github/workflows/build-and-test-device.yaml
index 10ecaf70..3304d8fb 100644
--- a/.github/workflows/build-and-test-device.yaml
+++ b/.github/workflows/build-and-test-device.yaml
@@ -98,8 +98,8 @@ jobs:
cd build
export VERBOSE=1
cmake .. -DCMAKE_BUILD_TYPE=Debug -DNANOARROW_DEVICE=ON \
- -DNANOARROW_BUILD_TESTS=ON -DCMAKE_PREFIX_PATH="${ARROW_PATH}" \
- ${{ matrix.config.cmake_args }}
+ -DNANOARROW_BUILD_TESTS=ON -DNANOARROW_BUILD_TESTS_WITH_ARROW=ON \
+ -DCMAKE_PREFIX_PATH="${ARROW_PATH}" ${{ matrix.config.cmake_args }}
cmake --build .
diff --git a/.github/workflows/build-and-test-ipc.yaml
b/.github/workflows/build-and-test-ipc.yaml
index 0fd74d84..cd28908a 100644
--- a/.github/workflows/build-and-test-ipc.yaml
+++ b/.github/workflows/build-and-test-ipc.yaml
@@ -91,8 +91,8 @@ jobs:
cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DNANOARROW_BUILD_TESTS=ON \
- -DNANOARROW_IPC=ON -DCMAKE_PREFIX_PATH="${ARROW_PATH}" \
- ${{ matrix.config.cmake_args }}
+ -DNANOARROW_BUILD_TESTS_WITH_ARROW=ON -DNANOARROW_IPC=ON \
+ -DCMAKE_PREFIX_PATH="${ARROW_PATH}" ${{ matrix.config.cmake_args }}
cmake --build .
diff --git a/.github/workflows/build-and-test.yaml
b/.github/workflows/build-and-test.yaml
index 127917ed..9432c359 100644
--- a/.github/workflows/build-and-test.yaml
+++ b/.github/workflows/build-and-test.yaml
@@ -82,7 +82,8 @@ jobs:
cd build
cmake .. -DNANOARROW_BUILD_TESTS=ON
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
- -DCMAKE_PREFIX_PATH="${ARROW_PATH}" ${{ matrix.config.cmake_args }}
+ -DNANOARROW_BUILD_TESTS_WITH_ARROW=ON
-DCMAKE_PREFIX_PATH="${ARROW_PATH}" \
+ ${{ matrix.config.cmake_args }}
cmake --build .
@@ -158,3 +159,21 @@ jobs:
- name: Run meson testing script
run: |
PKG_CONFIG_PATH="$(pwd)/arrow/lib/pkgconfig"
ci/scripts/build-with-meson.sh
+
+ test-no-arrow:
+ name: test-no-arrow
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Build nanoarrow
+ run: |
+ cmake -S . -B build -DNANOARROW_BUILD_TESTS=ON
-DNANOARROW_BUILD_TESTS_WITH_ARROW=OFF \
+ -DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DCMAKE_PREFIX_PATH="${ARROW_PATH}"
+
+ cmake --build build
+
+ - name: Run tests
+ run: |
+ cd build
+ ctest -T test --output-on-failure .
diff --git a/.github/workflows/clang-tidy.yaml
b/.github/workflows/clang-tidy.yaml
index 2e4c4b4c..f7fbdfbc 100644
--- a/.github/workflows/clang-tidy.yaml
+++ b/.github/workflows/clang-tidy.yaml
@@ -66,9 +66,9 @@ jobs:
cd build
cmake .. -DNANOARROW_DEVICE=ON -DNANOARROW_IPC=ON \
- -DNANOARROW_BUILD_TESTS=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
- -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
- -DCMAKE_PREFIX_PATH="${ARROW_PATH}"
+ -DNANOARROW_BUILD_TESTS=ON -DNANOARROW_BUILD_TESTS_WITH_ARROW=ON \
+ -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE=Debug \
+ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-DCMAKE_PREFIX_PATH="${ARROW_PATH}"
cmake --build .
diff --git a/.github/workflows/verify.yaml b/.github/workflows/verify.yaml
index c6fbb7e2..9fb025f8 100644
--- a/.github/workflows/verify.yaml
+++ b/.github/workflows/verify.yaml
@@ -101,13 +101,21 @@ jobs:
if: matrix.config.label == 'windows'
shell: bash
run: |
- echo "NANOARROW_CMAKE_OPTIONS=${NANOARROW_CMAKE_OPTIONS}
-DNANOARROW_ARROW_STATIC=ON -DArrow_DIR=$(pwd -W)/arrow/lib/cmake/Arrow
-Dgtest_force_shared_crt=ON" >> $GITHUB_ENV
+ cat << EOF | tr '\n' ' ' >> $GITHUB_ENV
+ NANOARROW_CMAKE_OPTIONS=${NANOARROW_CMAKE_OPTIONS}
+ -DNANOARROW_ARROW_STATIC=ON
+ -DNANOARROW_BUILD_TESTS_WITH_ARROW=ON
+ -DArrow_DIR=$(pwd -W)/arrow/lib/cmake/Arrow
+ -Dgtest_force_shared_crt=ON
- name: Set CMake options (POSIX)
if: matrix.config.label != 'windows'
shell: bash
run: |
- echo "NANOARROW_CMAKE_OPTIONS=${NANOARROW_CMAKE_OPTIONS}
-DArrow_DIR=$(pwd)/arrow/lib/cmake/Arrow" >> $GITHUB_ENV
+ cat << EOF | tr '\n' ' ' >> $GITHUB_ENV
+ NANOARROW_CMAKE_OPTIONS=${NANOARROW_CMAKE_OPTIONS}
+ -DNANOARROW_BUILD_TESTS_WITH_ARROW=ON
+ -DArrow_DIR=$(pwd)/arrow/lib/cmake/Arrow
- name: Run dev/release/verify-release-candidate.sh
shell: bash
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4cefb8fb..a24f7873 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -45,6 +45,7 @@ option(NANOARROW_DEVICE_WITH_CUDA "Build CUDA libraries" OFF)
# Development options
option(NANOARROW_BUILD_APPS "Build utility applications" OFF)
option(NANOARROW_BUILD_TESTS "Build tests" OFF)
+option(NANOARROW_BUILD_TESTS_WITH_ARROW "Build tests that require Arrow" OFF)
option(NANOARROW_BUILD_BENCHMARKS "Build benchmarks" OFF)
option(NANOARROW_BUILD_INTEGRATION_TESTS
"Build cross-implementation Arrow integration tests" OFF)
@@ -422,26 +423,28 @@ if(NANOARROW_BUILD_TESTS)
)
include(CTest)
- find_package(Arrow REQUIRED)
- message(STATUS "Arrow version: ${ARROW_VERSION}")
- message(STATUS "Arrow SO version: ${ARROW_FULL_SO_VERSION}")
+ if(NANOARROW_BUILD_TESTS_WITH_ARROW)
+ find_package(Arrow REQUIRED)
+ message(STATUS "Arrow version: ${ARROW_VERSION}")
+ message(STATUS "Arrow SO version: ${ARROW_FULL_SO_VERSION}")
- # Give caller the option to link a static version of Arrow C++
- if(NANOARROW_ARROW_STATIC)
- set(NANOARROW_ARROW_TARGET arrow_static)
- else()
- set(NANOARROW_ARROW_TARGET arrow_shared)
- endif()
+ # Give caller the option to link a static version of Arrow C++
+ if(NANOARROW_ARROW_STATIC)
+ set(NANOARROW_ARROW_TARGET arrow_static)
+ else()
+ set(NANOARROW_ARROW_TARGET arrow_shared)
+ endif()
- # Arrow >= 10.0.0 requires C++17; GTest requires C++11.
- # Leave the option open to use an older version of Arrow
- # to make it easier to test on old Linux (e.g., Centos7)
- if(${ARROW_VERSION} VERSION_GREATER_EQUAL "10.0.0")
- set(CMAKE_CXX_STANDARD 17)
- else()
- set(CMAKE_CXX_STANDARD 11)
+ # Arrow >= 10.0.0 requires C++17; GTest requires C++11.
+ # Leave the option open to use an older version of Arrow
+ # to make it easier to test on old Linux (e.g., Centos7)
+ if(${ARROW_VERSION} VERSION_GREATER_EQUAL "10.0.0")
+ set(CMAKE_CXX_STANDARD 17)
+ else()
+ set(CMAKE_CXX_STANDARD 11)
+ endif()
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
- set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_subdirectory("thirdparty/googletest")
@@ -517,6 +520,27 @@ if(NANOARROW_BUILD_TESTS)
gmock_main
nanoarrow_coverage_config)
+ list(APPEND
+ NanoarrowTests
+ utils_test
+ buffer_test
+ array_test
+ schema_test
+ array_stream_test
+ nanoarrow_testing_test
+ c_data_integration_test
+ hpp_array_stream
+ hpp_buffer
+ hpp_exception
+ hpp_unique
+ hpp_view)
+ if(Arrow_FOUND)
+ foreach(test_target ${NanoarrowTests})
+ target_compile_definitions(${test_target}
+ PRIVATE -DNANOARROW_BUILD_TESTS_WITH_ARROW)
+ endforeach()
+ endif()
+
include(GoogleTest)
# Some users have reported a timeout with the default value of 5
# Building with -DBUILD_SHARED_LIBS=ON may also help reduce the size of test
@@ -569,6 +593,11 @@ if(NANOARROW_BUILD_TESTS)
target_link_libraries(nanoarrow_ipc_${name}_test flatccrt)
endif()
+ if(Arrow_FOUND)
+ target_compile_definitions(nanoarrow_ipc_${name}_test
+ PRIVATE -DNANOARROW_BUILD_TESTS_WITH_ARROW)
+ endif()
+
gtest_discover_tests(nanoarrow_ipc_${name}_test)
endforeach()
@@ -593,6 +622,13 @@ if(NANOARROW_BUILD_TESTS)
gtest_main
nanoarrow_coverage_config)
+ if(Arrow_FOUND)
+ target_compile_definitions(nanoarrow_device_test
+ PRIVATE -DNANOARROW_BUILD_TESTS_WITH_ARROW)
+ target_compile_definitions(nanoarrow_device_hpp_test
+ PRIVATE -DNANOARROW_BUILD_TESTS_WITH_ARROW)
+ endif()
+
include(GoogleTest)
gtest_discover_tests(nanoarrow_device_test)
gtest_discover_tests(nanoarrow_device_hpp_test)
@@ -604,6 +640,10 @@ if(NANOARROW_BUILD_TESTS)
nanoarrow
gtest_main
nanoarrow_coverage_config)
+ if(Arrow_FOUND)
+ target_compile_definitions(nanoarrow_device_metal_test
+ PRIVATE -DNANOARROW_BUILD_TESTS_WITH_ARROW)
+ endif()
gtest_discover_tests(nanoarrow_device_metal_test)
endif()
@@ -615,6 +655,10 @@ if(NANOARROW_BUILD_TESTS)
CUDA::cuda_driver
gtest_main
nanoarrow_coverage_config)
+ if(Arrow_FOUND)
+ target_compile_definitions(nanoarrow_device_cuda_test
+ PRIVATE -DNANOARROW_BUILD_TESTS_WITH_ARROW)
+ endif()
gtest_discover_tests(nanoarrow_device_cuda_test)
endif()
endif()
diff --git a/README.md b/README.md
index b3c5e1cf..27b5c944 100644
--- a/README.md
+++ b/README.md
@@ -127,9 +127,7 @@ cmake ..
cmake --build .
```
-Building nanoarrow with tests currently requires [Arrow
C++](https://arrow.apache.org/install/).
-If installed via a system package manager like `apt`, `dnf`, or `brew`, the
tests can be
-built with:
+To build nanoarrow along with tests run:
```sh
mkdir build && cd build
@@ -137,6 +135,15 @@ cmake .. -DNANOARROW_BUILD_TESTS=ON
cmake --build .
```
+If you are able to install [Arrow C++](https://arrow.apache.org/install/) you
can enable
+more testing:
+
+```sh
+mkdir build && cd build
+cmake .. -DNANOARROW_BUILD_TESTS=ON -DNANOARROW_BUILD_TESTS_WITH_ARROW=ON
+cmake --build .
+```
+
Tests can be run with `ctest`.
### Building with Meson
@@ -155,9 +162,9 @@ After setting up your project, be sure to enable the
options you want:
meson configure -Dtests=true -Dbenchmarks=true
```
-If Arrow is installed in a non-standard location on your system, you may need
to
-pass the `--pkg-config-path <path to directory with arrow.pc>` argument to
either
-the setup or configure steps above.
+You can enable better test coverage if Apache Arrow is installed on your system
+with `-Dtest_with_arrow=true`. Depending on how you have installed Apache
Arrow,
+you may also need to pass `--pkg-config-path <path to directory with
arrow.pc>`.
With the above out of the way, the `compile` command should take care of the
rest:
diff --git a/ci/scripts/coverage.sh b/ci/scripts/coverage.sh
index 14c3688e..c8d11760 100755
--- a/ci/scripts/coverage.sh
+++ b/ci/scripts/coverage.sh
@@ -74,7 +74,8 @@ function main() {
cmake "${TARGET_NANOARROW_DIR}" \
-DNANOARROW_DEVICE=ON -DNANOARROW_IPC=ON \
- -DNANOARROW_BUILD_TESTS=ON -DNANOARROW_CODE_COVERAGE=ON
+ -DNANOARROW_BUILD_TESTS=ON -DNANOARROW_BUILD_TESTS_WITH_ARROW=ON \
+ -DNANOARROW_CODE_COVERAGE=ON
cmake --build .
CTEST_OUTPUT_ON_FAILURE=1 ctest .
diff --git a/meson.build b/meson.build
index 6bbbe01a..53dd824d 100644
--- a/meson.build
+++ b/meson.build
@@ -208,8 +208,16 @@ if get_option('tests')
# Similarly code coverage has a built in option users should use instead
# https://mesonbuild.com/Unit-tests.html#coverage
- # The system include suppresses compilation warnings from Arrow
- arrow_dep = dependency('arrow', include_type: 'system')
+ arrow_dep = dependency('arrow', include_type: 'system', required: false)
+ if get_option('tests_with_arrow') and not arrow_dep.found()
+ error('tests_with_arrow=true but could not find Arrow')
+ endif
+
+ test_cpp_args = []
+ if get_option('tests_with_arrow')
+ test_cpp_args += ['-DNANOARROW_BUILD_TESTS_WITH_ARROW']
+ endif
+
gtest_dep = dependency('gtest_main')
gmock_dep = dependency('gmock')
diff --git a/meson.options b/meson.options
index f1ff092d..93fec950 100644
--- a/meson.options
+++ b/meson.options
@@ -16,6 +16,7 @@
# under the License.
option('tests', type: 'boolean', description: 'Build tests', value: false)
+option('tests_with_arrow', type: 'boolean', description: 'Build tests with
Arrow', value: false)
option('benchmarks', type: 'boolean', description: 'Build benchmarks', value:
false)
option('apps', type: 'boolean', description: 'Build utility applications',
value: false)
option('ipc', type: 'boolean', description: 'Build IPC libraries', value:
false)
diff --git a/src/nanoarrow/common/array_test.cc
b/src/nanoarrow/common/array_test.cc
index 5ef77029..04d3b1d2 100644
--- a/src/nanoarrow/common/array_test.cc
+++ b/src/nanoarrow/common/array_test.cc
@@ -20,6 +20,7 @@
#include <cmath>
#include <cstdint>
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
#include <arrow/array.h>
#include <arrow/array/builder_binary.h>
#include <arrow/array/builder_decimal.h>
@@ -32,13 +33,17 @@
#include <arrow/config.h>
#include <arrow/util/decimal.h>
-#if defined(ARROW_VERSION_MAJOR) && ARROW_VERSION_MAJOR >= 12
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW) && defined(ARROW_VERSION_MAJOR)
&& \
+ ARROW_VERSION_MAJOR >= 12
#include <arrow/array/builder_run_end.h>
#endif
+#endif
#include "nanoarrow/nanoarrow.hpp"
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
using namespace arrow;
+#endif
using namespace nanoarrow::literals;
using nanoarrow::NA;
using testing::ElementsAre;
@@ -46,6 +51,7 @@ using testing::ElementsAre;
// Lightweight versions of ArrowTesting's ARROW_EXPECT_OK. This
// version accomplishes the task of making sure the status message
// ends up in the ctests log.
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
void ARROW_EXPECT_OK(Status status) {
if (!status.ok()) {
throw std::runtime_error(status.message());
@@ -57,6 +63,7 @@ void ARROW_EXPECT_OK(Result<std::shared_ptr<Array>> result) {
throw std::runtime_error(result.status().message());
}
}
+#endif
TEST(ArrayTest, ArrayTestInit) {
struct ArrowArray array;
@@ -393,11 +400,15 @@ TEST(ArrayTest, ArrayTestAppendToNullArray) {
EXPECT_EQ(array.length, 3);
EXPECT_EQ(array.null_count, 3);
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_array = ImportArray(&array, null());
ARROW_EXPECT_OK(arrow_array);
auto expected_array = MakeArrayOfNull(null(), 3);
ARROW_EXPECT_OK(expected_array);
EXPECT_TRUE(arrow_array.ValueUnsafe()->Equals(expected_array.ValueUnsafe()));
+#else
+ ArrowArrayRelease(&array);
+#endif
ASSERT_EQ(ArrowArrayInitFromType(&array, NANOARROW_TYPE_NA), NANOARROW_OK);
EXPECT_EQ(ArrowArrayAppendInt(&array, 0), EINVAL);
@@ -434,6 +445,7 @@ TEST(ArrayTest, ArrayTestAppendToInt64Array) {
EXPECT_EQ(data_buffer[3], 3);
EXPECT_EQ(data_buffer[4], 0);
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_array = ImportArray(&array, int64());
ARROW_EXPECT_OK(arrow_array);
@@ -445,6 +457,9 @@ TEST(ArrayTest, ArrayTestAppendToInt64Array) {
auto expected_array = builder.Finish();
EXPECT_TRUE(arrow_array.ValueUnsafe()->Equals(expected_array.ValueUnsafe()));
+#else
+ ArrowArrayRelease(&array);
+#endif
}
TEST(ArrayTest, ArrayTestAppendToInt32Array) {
@@ -463,6 +478,7 @@ TEST(ArrayTest, ArrayTestAppendToInt32Array) {
EXPECT_EQ(array.buffers[0], nullptr);
EXPECT_EQ(data_buffer[0], 123);
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_array = ImportArray(&array, int32());
ARROW_EXPECT_OK(arrow_array);
@@ -471,6 +487,9 @@ TEST(ArrayTest, ArrayTestAppendToInt32Array) {
auto expected_array = builder.Finish();
EXPECT_TRUE(arrow_array.ValueUnsafe()->Equals(expected_array.ValueUnsafe()));
+#else
+ ArrowArrayRelease(&array);
+#endif
}
TEST(ArrayTest, ArrayTestAppendToInt16Array) {
@@ -489,6 +508,7 @@ TEST(ArrayTest, ArrayTestAppendToInt16Array) {
EXPECT_EQ(array.buffers[0], nullptr);
EXPECT_EQ(data_buffer[0], 123);
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_array = ImportArray(&array, int16());
ARROW_EXPECT_OK(arrow_array);
@@ -497,6 +517,9 @@ TEST(ArrayTest, ArrayTestAppendToInt16Array) {
auto expected_array = builder.Finish();
EXPECT_TRUE(arrow_array.ValueUnsafe()->Equals(expected_array.ValueUnsafe()));
+#else
+ ArrowArrayRelease(&array);
+#endif
}
TEST(ArrayTest, ArrayTestAppendToInt8Array) {
@@ -515,6 +538,7 @@ TEST(ArrayTest, ArrayTestAppendToInt8Array) {
EXPECT_EQ(array.buffers[0], nullptr);
EXPECT_EQ(data_buffer[0], 123);
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_array = ImportArray(&array, int8());
ARROW_EXPECT_OK(arrow_array);
@@ -523,6 +547,9 @@ TEST(ArrayTest, ArrayTestAppendToInt8Array) {
auto expected_array = builder.Finish();
EXPECT_TRUE(arrow_array.ValueUnsafe()->Equals(expected_array.ValueUnsafe()));
+#else
+ ArrowArrayRelease(&array);
+#endif
}
TEST(ArrayTest, ArrayTestAppendToStringArray) {
@@ -554,6 +581,7 @@ TEST(ArrayTest, ArrayTestAppendToStringArray) {
EXPECT_EQ(offset_buffer[4], 9);
EXPECT_EQ(memcmp(data_buffer, "123456789", 9), 0);
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_array = ImportArray(&array, utf8());
ARROW_EXPECT_OK(arrow_array);
@@ -565,6 +593,9 @@ TEST(ArrayTest, ArrayTestAppendToStringArray) {
auto expected_array = builder.Finish();
EXPECT_TRUE(arrow_array.ValueUnsafe()->Equals(expected_array.ValueUnsafe()));
+#else
+ ArrowArrayRelease(&array);
+#endif
}
TEST(ArrayTest, ArrayTestAppendEmptyToString) {
@@ -597,6 +628,7 @@ TEST(ArrayTest, ArrayTestAppendToUInt64Array) {
EXPECT_EQ(data_buffer[2], 0);
EXPECT_EQ(data_buffer[3], 3);
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_array = ImportArray(&array, uint64());
ARROW_EXPECT_OK(arrow_array);
@@ -607,6 +639,9 @@ TEST(ArrayTest, ArrayTestAppendToUInt64Array) {
auto expected_array = builder.Finish();
EXPECT_TRUE(arrow_array.ValueUnsafe()->Equals(expected_array.ValueUnsafe()));
+#else
+ ArrowArrayRelease(&array);
+#endif
}
TEST(ArrayTest, ArrayTestAppendToUInt32Array) {
@@ -649,6 +684,7 @@ TEST(ArrayTest, ArrayTestAppendToUInt16Array) {
EXPECT_EQ(data_buffer[0], 1);
EXPECT_EQ(data_buffer[1], 3);
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_array = ImportArray(&array, uint16());
ARROW_EXPECT_OK(arrow_array);
@@ -658,6 +694,9 @@ TEST(ArrayTest, ArrayTestAppendToUInt16Array) {
auto expected_array = builder.Finish();
EXPECT_TRUE(arrow_array.ValueUnsafe()->Equals(expected_array.ValueUnsafe()));
+#else
+ ArrowArrayRelease(&array);
+#endif
}
TEST(ArrayTest, ArrayTestAppendToUInt8Array) {
@@ -680,6 +719,7 @@ TEST(ArrayTest, ArrayTestAppendToUInt8Array) {
EXPECT_EQ(data_buffer[0], 1);
EXPECT_EQ(data_buffer[1], 3);
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_array = ImportArray(&array, uint8());
ARROW_EXPECT_OK(arrow_array);
@@ -689,6 +729,9 @@ TEST(ArrayTest, ArrayTestAppendToUInt8Array) {
auto expected_array = builder.Finish();
EXPECT_TRUE(arrow_array.ValueUnsafe()->Equals(expected_array.ValueUnsafe()));
+#else
+ ArrowArrayRelease(&array);
+#endif
}
TEST(ArrayTest, ArrayTestAppendToDoubleArray) {
@@ -728,6 +771,7 @@ TEST(ArrayTest, ArrayTestAppendToDoubleArray) {
EXPECT_FLOAT_EQ(static_cast<float>(data_buffer[9]), -1);
EXPECT_FLOAT_EQ(static_cast<float>(data_buffer[10]), 0);
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_array = ImportArray(&array, float64());
ARROW_EXPECT_OK(arrow_array);
@@ -746,6 +790,9 @@ TEST(ArrayTest, ArrayTestAppendToDoubleArray) {
auto options = arrow::EqualOptions::Defaults().nans_equal(true);
EXPECT_TRUE(arrow_array.ValueUnsafe()->Equals(expected_array.ValueUnsafe(),
options));
+#else
+ ArrowArrayRelease(&array);
+#endif
}
TEST(ArrayTest, ArrayTestAppendToFloatArray) {
@@ -784,6 +831,7 @@ TEST(ArrayTest, ArrayTestAppendToFloatArray) {
EXPECT_FLOAT_EQ(data_buffer[9], -1);
EXPECT_FLOAT_EQ(data_buffer[10], 0);
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_array = ImportArray(&array, float32());
ARROW_EXPECT_OK(arrow_array);
@@ -802,6 +850,9 @@ TEST(ArrayTest, ArrayTestAppendToFloatArray) {
auto options = arrow::EqualOptions::Defaults().nans_equal(true);
EXPECT_TRUE(arrow_array.ValueUnsafe()->Equals(expected_array.ValueUnsafe(),
options));
+#else
+ ArrowArrayRelease(&array);
+#endif
}
TEST(ArrayTest, ArrayTestAppendToHalfFloatArray) {
@@ -841,8 +892,12 @@ TEST(ArrayTest, ArrayTestAppendToHalfFloatArray) {
EXPECT_FLOAT_EQ(ArrowHalfFloatToFloat(data_buffer[9]), -1);
EXPECT_FLOAT_EQ(ArrowHalfFloatToFloat(data_buffer[10]), 0);
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_array = ImportArray(&array, float16());
ARROW_EXPECT_OK(arrow_array);
+#else
+ ArrowArrayRelease(&array);
+#endif
}
TEST(ArrayTest, ArrayTestAppendToBoolArray) {
@@ -1118,6 +1173,7 @@ TEST(ArrayTest, ArrayTestAppendToIntervalArrayDayTime) {
EXPECT_EQ(memcmp(data_buffer, &interval.days, 4), 0);
EXPECT_EQ(memcmp(data_buffer + sizeof(interval.days), &interval.ms, 4), 0);
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_array = ImportArray(&array, day_time_interval());
ARROW_EXPECT_OK(arrow_array);
@@ -1128,6 +1184,9 @@ TEST(ArrayTest, ArrayTestAppendToIntervalArrayDayTime) {
auto expected_array = builder.Finish();
EXPECT_TRUE(arrow_array.ValueUnsafe()->Equals(expected_array.ValueUnsafe()));
+#else
+ ArrowArrayRelease(&array);
+#endif
}
TEST(ArrayTest, ArrayTestAppendToIntervalArrayMonthDayNano) {
@@ -1167,6 +1226,7 @@ TEST(ArrayTest,
ArrayTestAppendToIntervalArrayMonthDayNano) {
&interval.ns, sizeof(interval.ns)),
0);
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_array = ImportArray(&array, month_day_nano_interval());
ARROW_EXPECT_OK(arrow_array);
@@ -1180,6 +1240,9 @@ TEST(ArrayTest,
ArrayTestAppendToIntervalArrayMonthDayNano) {
auto expected_array = builder.Finish();
EXPECT_TRUE(arrow_array.ValueUnsafe()->Equals(expected_array.ValueUnsafe()));
+#else
+ ArrowArrayRelease(&array);
+#endif
}
TEST(ArrayTest, ArrayTestAppendToDecimal128Array) {
@@ -1210,6 +1273,7 @@ TEST(ArrayTest, ArrayTestAppendToDecimal128Array) {
ArrowDecimalSetInt(&decimal, -67890);
EXPECT_EQ(memcmp(data_buffer + 3 * 16, decimal.words, 16), 0);
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_array = ImportArray(&array, decimal128(10, 3));
ARROW_EXPECT_OK(arrow_array);
@@ -1220,6 +1284,9 @@ TEST(ArrayTest, ArrayTestAppendToDecimal128Array) {
auto expected_array = builder.Finish();
EXPECT_TRUE(arrow_array.ValueUnsafe()->Equals(expected_array.ValueUnsafe()));
+#else
+ ArrowArrayRelease(&array);
+#endif
}
TEST(ArrayTest, ArrayTestAppendToDecimal256Array) {
@@ -1250,6 +1317,7 @@ TEST(ArrayTest, ArrayTestAppendToDecimal256Array) {
ArrowDecimalSetInt(&decimal, -67890);
EXPECT_EQ(memcmp(data_buffer + 3 * 32, decimal.words, 32), 0);
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_array = ImportArray(&array, decimal256(10, 3));
ARROW_EXPECT_OK(arrow_array);
@@ -1260,6 +1328,9 @@ TEST(ArrayTest, ArrayTestAppendToDecimal256Array) {
auto expected_array = builder.Finish();
EXPECT_TRUE(arrow_array.ValueUnsafe()->Equals(expected_array.ValueUnsafe()));
+#else
+ ArrowArrayRelease(&array);
+#endif
}
TEST(ArrayTest, ArrayTestAppendToListArray) {
@@ -1305,6 +1376,7 @@ TEST(ArrayTest, ArrayTestAppendToListArray) {
array.children[0]->length = array.children[0]->length + 1;
EXPECT_EQ(ArrowArrayFinishBuildingDefault(&array, &error), NANOARROW_OK);
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_array = ImportArray(&array, &schema);
ARROW_EXPECT_OK(arrow_array);
@@ -1321,6 +1393,10 @@ TEST(ArrayTest, ArrayTestAppendToListArray) {
ARROW_EXPECT_OK(expected_array);
EXPECT_TRUE(arrow_array.ValueUnsafe()->Equals(expected_array.ValueUnsafe()));
+#else
+ ArrowSchemaRelease(&schema);
+ ArrowArrayRelease(&array);
+#endif
}
TEST(ArrayTest, ArrayTestAppendToLargeListArray) {
@@ -1367,6 +1443,7 @@ TEST(ArrayTest, ArrayTestAppendToLargeListArray) {
array.children[0]->length = array.children[0]->length + 1;
EXPECT_EQ(ArrowArrayFinishBuildingDefault(&array, &error), NANOARROW_OK);
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_array = ImportArray(&array, &schema);
ARROW_EXPECT_OK(arrow_array);
@@ -1384,6 +1461,10 @@ TEST(ArrayTest, ArrayTestAppendToLargeListArray) {
ARROW_EXPECT_OK(expected_array);
EXPECT_TRUE(arrow_array.ValueUnsafe()->Equals(expected_array.ValueUnsafe()));
+#else
+ ArrowSchemaRelease(&schema);
+ ArrowArrayRelease(&array);
+#endif
}
TEST(ArrayTest, ArrayTestAppendToMapArray) {
@@ -1431,6 +1512,7 @@ TEST(ArrayTest, ArrayTestAppendToMapArray) {
array.children[0]->length = array.children[0]->length + 1;
EXPECT_EQ(ArrowArrayFinishBuildingDefault(&array, &error), NANOARROW_OK);
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto maybe_arrow_array = ImportArray(&array, &schema);
ARROW_EXPECT_OK(maybe_arrow_array);
auto arrow_array = std::move(maybe_arrow_array).MoveValueUnsafe();
@@ -1449,6 +1531,10 @@ TEST(ArrayTest, ArrayTestAppendToMapArray) {
auto expected_array = std::move(maybe_expected_array).MoveValueUnsafe();
EXPECT_TRUE(arrow_array->Equals(expected_array));
+#else
+ ArrowSchemaRelease(&schema);
+ ArrowArrayRelease(&array);
+#endif
}
TEST(ArrayTest, ArrayTestAppendToFixedSizeListArray) {
@@ -1499,6 +1585,7 @@ TEST(ArrayTest, ArrayTestAppendToFixedSizeListArray) {
array.children[0]->length = array.children[0]->length + 1;
EXPECT_EQ(ArrowArrayFinishBuildingDefault(&array, nullptr), NANOARROW_OK);
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_array = ImportArray(&array, &schema);
ARROW_EXPECT_OK(arrow_array);
@@ -1517,6 +1604,10 @@ TEST(ArrayTest, ArrayTestAppendToFixedSizeListArray) {
ARROW_EXPECT_OK(expected_array);
EXPECT_TRUE(arrow_array.ValueUnsafe()->Equals(expected_array.ValueUnsafe()));
+#else
+ ArrowSchemaRelease(&schema);
+ ArrowArrayRelease(&array);
+#endif
}
TEST(ArrayTest, ArrayTestAppendToListArrayErrors) {
@@ -1566,6 +1657,7 @@ TEST(ArrayTest, ArrayTestAppendToStructArray) {
EXPECT_EQ(ArrowArrayFinishBuildingDefault(&array, nullptr), NANOARROW_OK);
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_array = ImportArray(&array, &schema);
ARROW_EXPECT_OK(arrow_array);
@@ -1582,6 +1674,10 @@ TEST(ArrayTest, ArrayTestAppendToStructArray) {
ARROW_EXPECT_OK(expected_array);
EXPECT_TRUE(arrow_array.ValueUnsafe()->Equals(expected_array.ValueUnsafe()));
+#else
+ ArrowSchemaRelease(&schema);
+ ArrowArrayRelease(&array);
+#endif
}
TEST(ArrayTest, ArrayTestAppendToRunEndEncodedArray) {
@@ -1719,7 +1815,8 @@ TEST(ArrayTest, ArrayTestAppendToRunEndEncodedArray) {
EXPECT_EQ(ArrowArrayFinishBuilding(&array, NANOARROW_VALIDATION_LEVEL_FULL,
&error),
NANOARROW_OK);
-#if !defined(ARROW_VERSION_MAJOR) || ARROW_VERSION_MAJOR < 12
+#if !defined(NANOARROW_BUILD_TESTS_WITH_ARROW) ||
!defined(ARROW_VERSION_MAJOR) || \
+ ARROW_VERSION_MAJOR < 12
ArrowSchemaRelease(&schema);
ArrowArrayRelease(&array);
#else
@@ -1800,6 +1897,7 @@ TEST(ArrayTest, ArrayTestAppendToDenseUnionArray) {
EXPECT_EQ(ArrowArrayFinishBuildingDefault(&array, nullptr), NANOARROW_OK);
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_array = ImportArray(&array, &schema);
ARROW_EXPECT_OK(arrow_array);
@@ -1820,6 +1918,10 @@ TEST(ArrayTest, ArrayTestAppendToDenseUnionArray) {
ARROW_EXPECT_OK(expected_array);
EXPECT_TRUE(arrow_array.ValueUnsafe()->Equals(expected_array.ValueUnsafe()));
+#else
+ ArrowSchemaRelease(&schema);
+ ArrowArrayRelease(&array);
+#endif
}
TEST(ArrayTest, ArrayTestAppendToSparseUnionArray) {
@@ -1845,6 +1947,7 @@ TEST(ArrayTest, ArrayTestAppendToSparseUnionArray) {
EXPECT_EQ(ArrowArrayAppendEmpty(&array, 1), NANOARROW_OK);
EXPECT_EQ(ArrowArrayFinishBuildingDefault(&array, nullptr), NANOARROW_OK);
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_array = ImportArray(&array, &schema);
ARROW_EXPECT_OK(arrow_array);
@@ -1870,6 +1973,10 @@ TEST(ArrayTest, ArrayTestAppendToSparseUnionArray) {
EXPECT_EQ(arrow_array.ValueUnsafe()->ToString(),
expected_array.ValueUnsafe()->ToString());
EXPECT_TRUE(arrow_array.ValueUnsafe()->Equals(expected_array.ValueUnsafe()));
+#else
+ ArrowSchemaRelease(&schema);
+ ArrowArrayRelease(&array);
+#endif
}
TEST(ArrayTest, ArrayTestAppendToUnionArrayErrors) {
@@ -3250,6 +3357,7 @@ TEST(ArrayTest, ArrayViewTestSparseUnionGet) {
// the "value type" that would correspond to what
ArrowArrayViewGetDoubleUnsafe()
// or ArrowArrayAppendDouble() do since they operate on the logical/represented
// value.
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
template <typename TypeClass, typename BuilderValueT>
BuilderValueT logical_value_to_builder_value(int64_t value) {
return static_cast<BuilderValueT>(value);
@@ -3352,6 +3460,7 @@ TEST(ArrayViewTest, ArrayViewTestGetNumeric) {
TestGetFromNumericArrayView<FloatType>();
TestGetFromNumericArrayView<HalfFloatType>();
}
+#endif
TEST(ArrayViewTest, ArrayViewTestGetFloat16) {
struct ArrowArray array;
@@ -3419,6 +3528,7 @@ TEST(ArrayViewTest, ArrayViewTestGetFloat16) {
ArrowSchemaRelease(&schema);
}
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
template <typename BuilderClass>
void TestGetFromBinary(BuilderClass& builder) {
struct ArrowArray array;
@@ -3569,7 +3679,8 @@ void TestGetFromBinaryView(
}
TEST(ArrayViewTest, ArrayViewTestGetStringView) {
-#if defined(ARROW_VERSION_MAJOR) && ARROW_VERSION_MAJOR >= 15
+#if !defined(NANOARROW_BUILD_TESTS_WITH_ARROW) || \
+ defined(ARROW_VERSION_MAJOR) && ARROW_VERSION_MAJOR >= 15
auto string_view_builder = StringViewBuilder();
const auto get_string_view = [](const struct ArrowStringView* sv) { return
sv->data; };
TestGetFromInlinedBinaryView<StringViewBuilder, struct ArrowStringView>(
@@ -3582,7 +3693,8 @@ TEST(ArrayViewTest, ArrayViewTestGetStringView) {
}
TEST(ArrayViewTest, ArrayViewTestGetBinaryView) {
-#if defined(ARROW_VERSION_MAJOR) && ARROW_VERSION_MAJOR >= 15
+#if !defined(NANOARROW_BUILD_TESTS_WITH_ARROW) || \
+ defined(ARROW_VERSION_MAJOR) && ARROW_VERSION_MAJOR >= 15
auto binary_view_builder = BinaryViewBuilder();
const auto get_buffer_view = [](const struct ArrowBufferView* bv) {
return bv->data.data;
@@ -3595,6 +3707,7 @@ TEST(ArrayViewTest, ArrayViewTestGetBinaryView) {
GTEST_SKIP() << "Arrow C++ StringView compatibility test needs Arrow C++ >=
15";
#endif
}
+#endif
TEST(ArrayViewTest, ArrayViewTestGetIntervalYearMonth) {
struct ArrowArray array;
@@ -3633,6 +3746,7 @@ TEST(ArrayViewTest, ArrayViewTestGetIntervalYearMonth) {
ArrowArrayRelease(&array);
}
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
TEST(ArrayViewTest, ArrayViewTestGetIntervalDayTime) {
struct ArrowArray array;
struct ArrowSchema schema;
@@ -3780,3 +3894,4 @@ TEST(ArrayViewTest, ArrayViewTestGetDecimal256) {
ArrowSchemaRelease(&schema);
ArrowArrayRelease(&array);
}
+#endif
diff --git a/src/nanoarrow/common/schema_test.cc
b/src/nanoarrow/common/schema_test.cc
index 163f96c7..f05f5e08 100644
--- a/src/nanoarrow/common/schema_test.cc
+++ b/src/nanoarrow/common/schema_test.cc
@@ -17,14 +17,18 @@
#include <gtest/gtest.h>
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
#include <arrow/c/bridge.h>
#include <arrow/config.h>
#include <arrow/testing/gtest_util.h>
#include <arrow/util/key_value_metadata.h>
+#endif
#include "nanoarrow/nanoarrow.hpp"
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
using namespace arrow;
+#endif
// Helper to avoid the verbosity of ArrowSchemaToStdString
std::string ArrowSchemaToStdString(struct ArrowSchema* schema, bool recursive
= true) {
@@ -76,6 +80,7 @@ TEST(SchemaTest, SchemaInit) {
ArrowSchemaRelease(&schema);
}
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
static void ExpectSchemaInitOk(enum ArrowType type,
std::shared_ptr<DataType> expected_arrow_type) {
struct ArrowSchema schema;
@@ -108,11 +113,13 @@ TEST(SchemaTest, SchemaInitSimple) {
ExpectSchemaInitOk(NANOARROW_TYPE_INTERVAL_MONTHS, month_interval());
ExpectSchemaInitOk(NANOARROW_TYPE_INTERVAL_DAY_TIME, day_time_interval());
ExpectSchemaInitOk(NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO,
month_day_nano_interval());
-#if defined(ARROW_VERSION_MAJOR) && ARROW_VERSION_MAJOR >= 15
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW) && defined(ARROW_VERSION_MAJOR)
&& \
+ ARROW_VERSION_MAJOR >= 15
ExpectSchemaInitOk(NANOARROW_TYPE_STRING_VIEW, utf8_view());
ExpectSchemaInitOk(NANOARROW_TYPE_BINARY_VIEW, binary_view());
#endif
}
+#endif
TEST(SchemaTest, SchemaInitSimpleError) {
struct ArrowSchema schema;
@@ -127,6 +134,7 @@ TEST(SchemaTest, SchemaTestInitNestedList) {
EXPECT_STREQ(schema.format, "+l");
ASSERT_EQ(ArrowSchemaSetType(schema.children[0], NANOARROW_TYPE_INT32),
NANOARROW_OK);
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_type = ImportType(&schema);
ARROW_EXPECT_OK(arrow_type);
EXPECT_TRUE(arrow_type.ValueUnsafe()->Equals(list(int32())));
@@ -138,6 +146,9 @@ TEST(SchemaTest, SchemaTestInitNestedList) {
arrow_type = ImportType(&schema);
ARROW_EXPECT_OK(arrow_type);
EXPECT_TRUE(arrow_type.ValueUnsafe()->Equals(large_list(int32())));
+#else
+ ArrowSchemaRelease(&schema);
+#endif
}
TEST(SchemaTest, SchemaTestInitNestedStruct) {
@@ -149,9 +160,13 @@ TEST(SchemaTest, SchemaTestInitNestedStruct) {
ASSERT_EQ(ArrowSchemaSetType(schema.children[0], NANOARROW_TYPE_INT32),
NANOARROW_OK);
ASSERT_EQ(ArrowSchemaSetName(schema.children[0], "item"), NANOARROW_OK);
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_type = ImportType(&schema);
ARROW_EXPECT_OK(arrow_type);
EXPECT_TRUE(arrow_type.ValueUnsafe()->Equals(struct_({field("item",
int32())})));
+#else
+ ArrowSchemaRelease(&schema);
+#endif
}
TEST(SchemaTest, SchemaTestInitNestedMap) {
@@ -170,9 +185,13 @@ TEST(SchemaTest, SchemaTestInitNestedMap) {
EXPECT_FALSE(schema.children[0]->flags & ARROW_FLAG_NULLABLE);
EXPECT_FALSE(schema.children[0]->children[0]->flags & ARROW_FLAG_NULLABLE);
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_type = ImportType(&schema);
ARROW_EXPECT_OK(arrow_type);
EXPECT_TRUE(arrow_type.ValueUnsafe()->Equals(map(int32(), utf8())));
+#else
+ ArrowSchemaRelease(&schema);
+#endif
}
TEST(SchemaTest, SchemaInitFixedSize) {
@@ -187,6 +206,7 @@ TEST(SchemaTest, SchemaInitFixedSize) {
NANOARROW_OK);
EXPECT_STREQ(schema.format, "w:45");
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_type = ImportType(&schema);
ARROW_EXPECT_OK(arrow_type);
EXPECT_TRUE(arrow_type.ValueUnsafe()->Equals(fixed_size_binary(45)));
@@ -200,6 +220,9 @@ TEST(SchemaTest, SchemaInitFixedSize) {
arrow_type = ImportType(&schema);
ARROW_EXPECT_OK(arrow_type);
EXPECT_TRUE(arrow_type.ValueUnsafe()->Equals(fixed_size_list(int32(), 12)));
+#else
+ ArrowSchemaRelease(&schema);
+#endif
}
TEST(SchemaTest, SchemaInitDecimal) {
@@ -213,6 +236,7 @@ TEST(SchemaTest, SchemaInitDecimal) {
NANOARROW_OK);
EXPECT_STREQ(schema.format, "d:1,2");
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_type = ImportType(&schema);
ARROW_EXPECT_OK(arrow_type);
EXPECT_TRUE(arrow_type.ValueUnsafe()->Equals(decimal128(1, 2)));
@@ -224,6 +248,9 @@ TEST(SchemaTest, SchemaInitDecimal) {
arrow_type = ImportType(&schema);
ARROW_EXPECT_OK(arrow_type);
EXPECT_TRUE(arrow_type.ValueUnsafe()->Equals(decimal256(3, 4)));
+#else
+ ArrowSchemaRelease(&schema);
+#endif
}
TEST(SchemaTest, SchemaInitRunEndEncoded) {
@@ -242,7 +269,8 @@ TEST(SchemaTest, SchemaInitRunEndEncoded) {
ASSERT_EQ(ArrowSchemaSetType(schema.children[1], NANOARROW_TYPE_FLOAT),
NANOARROW_OK);
-#if !defined(ARROW_VERSION_MAJOR) || ARROW_VERSION_MAJOR < 12
+#if !defined(NANOARROW_BUILD_TESTS_WITH_ARROW) ||
!defined(ARROW_VERSION_MAJOR) || \
+ ARROW_VERSION_MAJOR < 12
ArrowSchemaRelease(&schema);
#else
auto arrow_type = ImportType(&schema);
@@ -317,6 +345,7 @@ TEST(SchemaTest, SchemaInitDateTime) {
NANOARROW_OK);
EXPECT_STREQ(schema.format, "tts");
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_type = ImportType(&schema);
ARROW_EXPECT_OK(arrow_type);
EXPECT_TRUE(arrow_type.ValueUnsafe()->Equals(time32(TimeUnit::SECOND)));
@@ -391,6 +420,9 @@ TEST(SchemaTest, SchemaInitDateTime) {
ARROW_EXPECT_OK(arrow_type);
EXPECT_TRUE(
arrow_type.ValueUnsafe()->Equals(timestamp(TimeUnit::SECOND,
"America/Halifax")));
+#else
+ ArrowSchemaRelease(&schema);
+#endif
}
TEST(SchemaTest, SchemaInitUnion) {
@@ -418,6 +450,7 @@ TEST(SchemaTest, SchemaInitUnion) {
EXPECT_STREQ(schema.format, "+us:0");
EXPECT_EQ(schema.n_children, 1);
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto arrow_type = ImportType(&schema);
ARROW_EXPECT_OK(arrow_type);
EXPECT_TRUE(arrow_type.ValueUnsafe()->Equals(sparse_union({field("u1",
int32())})));
@@ -451,6 +484,9 @@ TEST(SchemaTest, SchemaInitUnion) {
ARROW_EXPECT_OK(arrow_type);
EXPECT_TRUE(arrow_type.ValueUnsafe()->Equals(
dense_union({field("u1", int32()), field("u2", utf8())})));
+#else
+ ArrowSchemaRelease(&schema);
+#endif
}
TEST(SchemaTest, SchemaSetFormat) {
@@ -505,6 +541,7 @@ TEST(SchemaTest, SchemaAllocateDictionary) {
ArrowSchemaRelease(&schema);
}
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
TEST(SchemaTest, SchemaCopySimpleType) {
struct ArrowSchema schema;
ARROW_EXPECT_OK(ExportType(*int32(), &schema));
@@ -554,7 +591,8 @@ TEST(SchemaTest, SchemaCopyDictType) {
}
TEST(SchemaTest, SchemaCopyRunEndEncodedType) {
-#if !defined(ARROW_VERSION_MAJOR) || ARROW_VERSION_MAJOR < 12
+#if !defined(NANOARROW_BUILD_TESTS_WITH_ARROW) ||
!defined(ARROW_VERSION_MAJOR) || \
+ ARROW_VERSION_MAJOR < 12
GTEST_SKIP() << "Arrow C++ REE integration test requires ARROW_VERSION_MAJOR
>= 12";
#else
struct ArrowSchema schema;
@@ -616,6 +654,7 @@ TEST(SchemaTest, SchemaCopyMetadata) {
ArrowSchemaRelease(&schema);
}
+#endif
TEST(SchemaViewTest, SchemaViewInitErrors) {
struct ArrowSchema schema;
@@ -671,6 +710,7 @@ TEST(SchemaViewTest, SchemaViewInitErrors) {
ArrowSchemaRelease(&schema);
}
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
void ExpectSimpleTypeOk(std::shared_ptr<DataType> arrow_t, enum ArrowType
nanoarrow_t,
int bitwidth, const char* formatted) {
struct ArrowSchema schema;
@@ -723,6 +763,7 @@ TEST(SchemaViewTest, SchemaViewInitSimple) {
ExpectSimpleTypeOk(float64(), NANOARROW_TYPE_DOUBLE, 64, "double");
ExpectSimpleTypeOk(float32(), NANOARROW_TYPE_FLOAT, 32, "float");
}
+#endif
TEST(SchemaViewTest, SchemaViewInitSimpleErrors) {
struct ArrowSchema schema;
@@ -738,6 +779,7 @@ TEST(SchemaViewTest, SchemaViewInitSimpleErrors) {
ArrowSchemaRelease(&schema);
}
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
TEST(SchemaViewTest, SchemaViewInitDecimal) {
struct ArrowSchema schema;
struct ArrowSchemaView schema_view;
@@ -781,6 +823,7 @@ TEST(SchemaViewTest, SchemaViewInitDecimal) {
EXPECT_EQ(ArrowSchemaToStdString(&schema), "decimal256(5, 6)");
ArrowSchemaRelease(&schema);
}
+#endif
TEST(SchemaViewTest, SchemaViewInitDecimalErrors) {
struct ArrowSchema schema;
@@ -827,6 +870,7 @@ TEST(SchemaViewTest, SchemaViewInitDecimalErrors) {
ArrowSchemaRelease(&schema);
}
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
TEST(SchemaViewTest, SchemaViewInitBinaryAndString) {
struct ArrowSchema schema;
struct ArrowSchemaView schema_view;
@@ -915,7 +959,8 @@ TEST(SchemaViewTest, SchemaViewInitBinaryAndString) {
}
TEST(SchemaViewTest, SchemaViewInitBinaryAndStringView) {
-#if defined(ARROW_VERSION_MAJOR) && ARROW_VERSION_MAJOR >= 15
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW) && defined(ARROW_VERSION_MAJOR)
&& \
+ ARROW_VERSION_MAJOR >= 15
struct ArrowSchema schema;
struct ArrowSchemaView schema_view;
struct ArrowError error;
@@ -948,6 +993,7 @@ TEST(SchemaViewTest, SchemaViewInitBinaryAndStringView) {
GTEST_SKIP() << "Arrow C++ StringView compatibility test needs Arrow C++ >=
15";
#endif
}
+#endif
TEST(SchemaViewTest, SchemaViewInitBinaryAndStringErrors) {
struct ArrowSchema schema;
@@ -978,6 +1024,7 @@ TEST(SchemaViewTest, SchemaViewInitBinaryAndStringErrors) {
ArrowSchemaRelease(&schema);
}
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
TEST(SchemaViewTest, SchemaViewInitTimeDate) {
struct ArrowSchema schema;
struct ArrowSchemaView schema_view;
@@ -1142,6 +1189,7 @@ TEST(SchemaViewTest, SchemaViewInitTimeInterval) {
EXPECT_EQ(ArrowSchemaToStdString(&schema), "interval_month_day_nano");
ArrowSchemaRelease(&schema);
}
+#endif
TEST(SchemaViewTest, SchemaViewInitTimeErrors) {
struct ArrowSchema schema;
@@ -1193,6 +1241,7 @@ TEST(SchemaViewTest, SchemaViewInitTimeErrors) {
ArrowSchemaRelease(&schema);
}
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
TEST(SchemaViewTest, SchemaViewInitNestedList) {
struct ArrowSchema schema;
struct ArrowSchemaView schema_view;
@@ -1248,6 +1297,7 @@ TEST(SchemaViewTest, SchemaViewInitNestedList) {
EXPECT_EQ(ArrowSchemaToStdString(&schema), "fixed_size_list(123)<item:
int32>");
ArrowSchemaRelease(&schema);
}
+#endif
TEST(SchemaViewTest, SchemaViewNestedListErrors) {
struct ArrowSchema schema;
@@ -1273,6 +1323,7 @@ TEST(SchemaViewTest, SchemaViewNestedListErrors) {
ArrowSchemaRelease(&schema);
}
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
TEST(SchemaViewTest, SchemaViewInitNestedStruct) {
struct ArrowSchema schema;
struct ArrowSchemaView schema_view;
@@ -1300,6 +1351,7 @@ TEST(SchemaViewTest, SchemaViewInitNestedStruct) {
ArrowSchemaRelease(&schema);
}
+#endif
TEST(SchemaViewTest, SchemaViewInitNestedStructErrors) {
struct ArrowSchema schema;
@@ -1328,6 +1380,7 @@ TEST(SchemaViewTest, SchemaViewInitNestedStructErrors) {
ArrowSchemaRelease(&schema);
}
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
TEST(SchemaViewTest, SchemaViewInitNestedMap) {
struct ArrowSchema schema;
struct ArrowSchemaView schema_view;
@@ -1348,6 +1401,7 @@ TEST(SchemaViewTest, SchemaViewInitNestedMap) {
"map<entries: struct<key: int32, value: int32>>");
ArrowSchemaRelease(&schema);
}
+#endif
TEST(SchemaViewTest, SchemaViewInitNestedMapErrors) {
struct ArrowSchema schema;
@@ -1409,6 +1463,7 @@ TEST(SchemaViewTest, SchemaViewInitNestedMapErrors) {
ArrowSchemaRelease(&schema);
}
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
TEST(SchemaViewTest, SchemaViewInitNestedUnion) {
struct ArrowSchema schema;
struct ArrowSchemaView schema_view;
@@ -1448,6 +1503,7 @@ TEST(SchemaViewTest, SchemaViewInitNestedUnion) {
EXPECT_EQ(ArrowSchemaToStdString(&schema), "sparse_union([0])<col: int32>");
ArrowSchemaRelease(&schema);
}
+#endif
TEST(SchemaViewTest, SchemaViewInitNestedUnionErrors) {
struct ArrowSchema schema;
@@ -1500,6 +1556,7 @@ TEST(SchemaViewTest, SchemaViewInitInvalidSpecErrors) {
ArrowSchemaRelease(&schema);
}
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
TEST(SchemaViewTest, SchemaViewInitDictionary) {
struct ArrowSchema schema;
struct ArrowSchemaView schema_view;
@@ -1512,6 +1569,7 @@ TEST(SchemaViewTest, SchemaViewInitDictionary) {
EXPECT_EQ(ArrowSchemaToStdString(&schema), "dictionary(int32)<string>");
ArrowSchemaRelease(&schema);
}
+#endif
TEST(SchemaViewTest, SchemaViewInitDictionaryErrors) {
struct ArrowSchema schema;
@@ -1535,6 +1593,7 @@ TEST(SchemaViewTest, SchemaViewInitDictionaryErrors) {
ArrowSchemaRelease(&schema);
}
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
TEST(SchemaViewTest, SchemaViewInitExtension) {
using namespace nanoarrow::literals;
@@ -1555,7 +1614,9 @@ TEST(SchemaViewTest, SchemaViewInitExtension) {
ArrowSchemaRelease(&schema);
}
+#endif
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
TEST(SchemaViewTest, SchemaViewInitExtensionDictionary) {
using namespace nanoarrow::literals;
@@ -1596,6 +1657,7 @@ TEST(SchemaViewTest, SchemaFormatEmptyNested) {
ArrowSchemaRelease(&schema);
}
+#endif
TEST(SchemaViewTest, SchemaFormatInvalid) {
EXPECT_EQ(ArrowSchemaToStdString(nullptr), "[invalid: pointer is null]");
diff --git a/src/nanoarrow/common/utils_test.cc
b/src/nanoarrow/common/utils_test.cc
index e42990c4..be7ff758 100644
--- a/src/nanoarrow/common/utils_test.cc
+++ b/src/nanoarrow/common/utils_test.cc
@@ -18,14 +18,18 @@
#include <cstring>
#include <string>
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
#include <arrow/util/decimal.h>
+#endif
#include <gmock/gmock-matchers.h>
#include <gtest/gtest.h>
#include "nanoarrow/nanoarrow.hpp"
#include "nanoarrow/nanoarrow_testing.hpp"
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
using namespace arrow;
+#endif
TEST(BuildIdTest, VersionTest) {
EXPECT_STREQ(ArrowNanoarrowVersion(), NANOARROW_VERSION);
@@ -266,6 +270,7 @@ TEST(DecimalTest, Decimal128Test) {
EXPECT_EQ(decimal.low_word_index - decimal.high_word_index + 1,
decimal.n_words);
}
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto dec_pos = *Decimal128::FromString("12.345");
uint8_t bytes_pos[16];
dec_pos.ToBytes(bytes_pos);
@@ -287,6 +292,7 @@ TEST(DecimalTest, Decimal128Test) {
EXPECT_EQ(memcmp(decimal.words, bytes_neg, sizeof(bytes_neg)), 0);
ArrowDecimalSetBytes(&decimal, bytes_neg);
EXPECT_EQ(memcmp(decimal.words, bytes_neg, sizeof(bytes_neg)), 0);
+#endif
}
TEST(DecimalTest, DecimalNegateTest) {
@@ -362,6 +368,7 @@ TEST(DecimalTest, Decimal256Test) {
EXPECT_EQ(decimal.low_word_index - decimal.high_word_index + 1,
decimal.n_words);
}
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
auto dec_pos = *Decimal256::FromString("12.345");
uint8_t bytes_pos[32];
dec_pos.ToBytes(bytes_pos);
@@ -383,6 +390,7 @@ TEST(DecimalTest, Decimal256Test) {
EXPECT_EQ(memcmp(decimal.words, bytes_neg, sizeof(bytes_neg)), 0);
ArrowDecimalSetBytes(&decimal, bytes_neg);
EXPECT_EQ(memcmp(decimal.words, bytes_neg, sizeof(bytes_neg)), 0);
+#endif
}
TEST(DecimalTest, DecimalStringTestBasic) {
diff --git a/src/nanoarrow/ipc/decoder_test.cc
b/src/nanoarrow/ipc/decoder_test.cc
index 29209ec7..f59e52c5 100644
--- a/src/nanoarrow/ipc/decoder_test.cc
+++ b/src/nanoarrow/ipc/decoder_test.cc
@@ -17,10 +17,12 @@
#include <thread>
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
#include <arrow/array.h>
#include <arrow/c/bridge.h>
#include <arrow/ipc/api.h>
#include <arrow/util/key_value_metadata.h>
+#endif
#include <gmock/gmock-matchers.h>
#include <gtest/gtest.h>
@@ -29,7 +31,9 @@
#include "nanoarrow/nanoarrow_ipc.hpp"
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
using namespace arrow;
+#endif
// Copied from decoder.c so we can test the internal state
extern "C" {
@@ -465,6 +469,7 @@ TEST(NanoarrowIpcTest, NanoarrowIpcSetSchemaErrors) {
ArrowIpcDecoderReset(&decoder);
}
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
class ArrowTypeParameterizedTestFixture
: public ::testing::TestWithParam<std::shared_ptr<arrow::DataType>> {
protected:
@@ -500,6 +505,7 @@ TEST_P(ArrowTypeParameterizedTestFixture,
NanoarrowIpcArrowTypeRoundtrip) {
ArrowIpcDecoderReset(&decoder);
}
+#endif
std::string ArrowSchemaMetadataToString(const char* metadata) {
struct ArrowMetadataReader reader {};
@@ -557,6 +563,7 @@ std::string ArrowSchemaToString(const struct ArrowSchema*
schema) {
return out;
}
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
TEST_P(ArrowTypeParameterizedTestFixture, NanoarrowIpcNanoarrowTypeRoundtrip) {
nanoarrow::UniqueSchema schema;
ASSERT_TRUE(
@@ -593,6 +600,7 @@ TEST_P(ArrowTypeParameterizedTestFixture,
NanoarrowIpcNanoarrowTypeRoundtrip) {
EXPECT_EQ(ArrowSchemaToString(roundtripped.get()),
ArrowSchemaToString(schema.get()));
}
+#endif
TEST(NanoarrowIpcTest, NanoarrowIpcDecodeSimpleRecordBatchFromShared) {
struct ArrowIpcDecoder decoder;
@@ -727,6 +735,7 @@ TEST(NanoarrowIpcTest,
NanoarrowIpcSharedBufferThreadSafeDecode) {
// We will get a (occasional) memory leak if the atomic counter does not work
}
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
TEST_P(ArrowTypeParameterizedTestFixture, NanoarrowIpcArrowArrayRoundtrip) {
const std::shared_ptr<arrow::DataType>& data_type = GetParam();
std::shared_ptr<arrow::Schema> dummy_schema =
@@ -792,6 +801,7 @@ TEST_P(ArrowTypeParameterizedTestFixture,
NanoarrowIpcArrowArrayRoundtrip) {
ArrowSchemaRelease(&schema);
ArrowIpcDecoderReset(&decoder);
}
+#endif
void AssertArrayViewIdentical(const struct ArrowArrayView* actual,
const struct ArrowArrayView* expected) {
@@ -816,6 +826,7 @@ void AssertArrayViewIdentical(const struct ArrowArrayView*
actual,
}
}
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
TEST_P(ArrowTypeParameterizedTestFixture, NanoarrowIpcNanoarrowArrayRoundtrip)
{
struct ArrowError error;
nanoarrow::UniqueSchema schema;
@@ -1224,6 +1235,7 @@ INSTANTIATE_TEST_SUITE_P(NanoarrowIpcTest,
ArrowTypeIdParameterizedTestFixture,
NANOARROW_TYPE_DECIMAL128,
NANOARROW_TYPE_DECIMAL256,
NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO));
+#endif
TEST(NanoarrowIpcTest, NanoarrowIpcFooterDecodingErrors) {
struct ArrowError error;
diff --git a/src/nanoarrow/ipc/files_test.cc b/src/nanoarrow/ipc/files_test.cc
index 011d5935..cb505ce2 100644
--- a/src/nanoarrow/ipc/files_test.cc
+++ b/src/nanoarrow/ipc/files_test.cc
@@ -21,6 +21,7 @@
#include <zlib.h>
+#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
#include <arrow/buffer.h>
#include <arrow/c/bridge.h>
#include <arrow/io/api.h>
@@ -494,3 +495,4 @@ INSTANTIATE_TEST_SUITE_P(
"Schema message field with DictionaryEncoding not supported")
// Comment to keep last line from wrapping
));
+#endif