diff --git a/ApplicationLibCode/UnitTests/CMakeLists.txt b/ApplicationLibCode/UnitTests/CMakeLists.txt index d25c8bd5c9..ac7d8e0de6 100644 --- a/ApplicationLibCode/UnitTests/CMakeLists.txt +++ b/ApplicationLibCode/UnitTests/CMakeLists.txt @@ -102,6 +102,7 @@ set(SOURCE_UNITTEST_FILES ${CMAKE_CURRENT_LIST_DIR}/RifSummaryCalculationIO-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RimEmReader-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RifPolygonReader-Test.cpp + ${CMAKE_CURRENT_LIST_DIR}/RifParquetReader-Test.cpp ) if(RESINSIGHT_ENABLE_GRPC) diff --git a/ApplicationLibCode/UnitTests/RifParquetReader-Test.cpp b/ApplicationLibCode/UnitTests/RifParquetReader-Test.cpp new file mode 100644 index 0000000000..bcc0138287 --- /dev/null +++ b/ApplicationLibCode/UnitTests/RifParquetReader-Test.cpp @@ -0,0 +1,52 @@ +#include "gtest/gtest.h" + +#include "RiaTestDataDirectory.h" + +#include +#include +#include +#include +#include + +#include +#include + +TEST( RifParquetReaderTest, ReadValidFile ) +{ + QDir baseFolder( TEST_DATA_DIR ); + + QString filename( "RifParquetReader/example.parquet" ); + QString filePath = baseFolder.absoluteFilePath( filename ); + EXPECT_TRUE( QFile::exists( filePath ) ); + + arrow::MemoryPool* pool = arrow::default_memory_pool(); + + auto openResult = arrow::io::ReadableFile::Open( filePath.toStdString().c_str() ); + EXPECT_TRUE( openResult.ok() ); + + std::shared_ptr input = std::move( openResult ).ValueOrDie(); + + // Open Parquet file reader + std::unique_ptr arrow_reader; + EXPECT_TRUE( parquet::arrow::OpenFile( input, pool, &arrow_reader ).ok() ); + + // Read entire file as a single Arrow table + std::shared_ptr table; + EXPECT_TRUE( arrow_reader->ReadTable( &table ).ok() ); + + // Expect one column named "col1" + EXPECT_EQ( table->columns().size(), 1 ); + std::vector expectedNames = { "col1" }; + EXPECT_EQ( table->ColumnNames(), expectedNames ); + + // Expected the column to contain 100 int64 [0, 99] + auto columnData = table->column( 0 ); + int expectedSize = 100; + EXPECT_EQ( columnData->length(), expectedSize ); + for ( int i = 0; i < expectedSize; i++ ) + { + std::shared_ptr scalar = columnData->GetScalar( i ).ValueOrDie(); + std::shared_ptr intScalar = std::dynamic_pointer_cast( scalar ); + EXPECT_TRUE( scalar->Equals( arrow::Int64Scalar( i ) ) ); + } +} diff --git a/ApplicationLibCode/UnitTests/TestData/RifParquetReader/example.parquet b/ApplicationLibCode/UnitTests/TestData/RifParquetReader/example.parquet new file mode 100644 index 0000000000..96d4beda6c Binary files /dev/null and b/ApplicationLibCode/UnitTests/TestData/RifParquetReader/example.parquet differ diff --git a/CMakeLists.txt b/CMakeLists.txt index 80323bde92..f99c07e292 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -636,6 +636,26 @@ add_subdirectory(ThirdParty/tomlplusplus) add_subdirectory(ThirdParty/spdlog) list(APPEND THIRD_PARTY_LIBRARIES spdlog) +# ############################################################################## +# Arrow +# ############################################################################## +find_package(Arrow CONFIG REQUIRED) +if(MSVC) + list(APPEND THIRD_PARTY_LIBRARIES Arrow::arrow_shared) +else() + list(APPEND THIRD_PARTY_LIBRARIES Arrow::arrow_static) +endif() + +# ############################################################################## +# Parquet +# ############################################################################## +find_package(Parquet CONFIG REQUIRED) +if(MSVC) + list(APPEND THIRD_PARTY_LIBRARIES Parquet::parquet_shared) +else() + list(APPEND THIRD_PARTY_LIBRARIES Parquet::parquet_static) +endif() + # ############################################################################## # Thirdparty libraries are put in ThirdParty solution folder # ############################################################################## diff --git a/vcpkg_x64-linux.txt b/vcpkg_x64-linux.txt index f12f410abe..57e54939ff 100644 --- a/vcpkg_x64-linux.txt +++ b/vcpkg_x64-linux.txt @@ -2,5 +2,6 @@ grpc boost-filesystem boost-spirit eigen3 +arrow --triplet x64-linux diff --git a/vcpkg_x64-osx.txt b/vcpkg_x64-osx.txt index 243a439217..fbaa9aaabf 100644 --- a/vcpkg_x64-osx.txt +++ b/vcpkg_x64-osx.txt @@ -2,5 +2,6 @@ grpc boost-filesystem boost-spirit eigen3 +arrow --triplet x64-osx diff --git a/vcpkg_x64-windows.txt b/vcpkg_x64-windows.txt index 7a961593aa..fc191ee234 100644 --- a/vcpkg_x64-windows.txt +++ b/vcpkg_x64-windows.txt @@ -2,5 +2,6 @@ grpc boost-filesystem boost-spirit eigen3 +arrow --triplet x64-windows