Skip to content

Commit 0c1cbca

Browse files
committed
feat: enable arrow to build parquet
1 parent a14c2b7 commit 0c1cbca

File tree

4 files changed

+64
-7
lines changed

4 files changed

+64
-7
lines changed

cmake_modules/IcebergThirdpartyToolchain.cmake

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,15 @@ function(resolve_arrow_dependency)
6565
set(ARROW_BUILD_STATIC
6666
ON
6767
CACHE BOOL "" FORCE)
68-
# To workaround https://github.com/apache/arrow/pull/45513
6968
set(ARROW_IPC
70-
ON
69+
OFF
7170
CACHE BOOL "" FORCE)
7271
set(ARROW_FILESYSTEM
7372
ON
7473
CACHE BOOL "" FORCE)
74+
set(ARROW_PARQUET
75+
ON
76+
CACHE BOOL "" FORCE)
7577
set(ARROW_SIMD_LEVEL
7678
"NONE"
7779
CACHE STRING "" FORCE)
@@ -82,13 +84,15 @@ function(resolve_arrow_dependency)
8284
ON
8385
CACHE BOOL "" FORCE)
8486
set(ARROW_DEPENDENCY_SOURCE
85-
"AUTO"
87+
"BUNDLED"
8688
CACHE STRING "" FORCE)
8789

8890
fetchcontent_declare(Arrow
8991
${FC_DECLARE_COMMON_OPTIONS}
90-
URL ${ARROW_SOURCE_URL}
91-
URL_HASH "SHA256=${ICEBERG_ARROW_BUILD_SHA256_CHECKSUM}"
92+
GIT_REPOSITORY https://github.com/wgtmac/arrow.git
93+
GIT_TAG 7d50c4ac803ad983734de5f418b7cd18f25b0dc9
94+
#URL ${ARROW_SOURCE_URL}
95+
#URL_HASH "SHA256=${ICEBERG_ARROW_BUILD_SHA256_CHECKSUM}"
9296
SOURCE_SUBDIR
9397
cpp
9498
FIND_PACKAGE_ARGS
@@ -107,13 +111,35 @@ function(resolve_arrow_dependency)
107111
${arrow_SOURCE_DIR}/cpp/src)
108112
endif()
109113

114+
if(NOT TARGET Parquet::parquet_static)
115+
add_library(Parquet::parquet_static INTERFACE IMPORTED)
116+
target_link_libraries(Parquet::parquet_static INTERFACE parquet_static)
117+
target_include_directories(Parquet::parquet_static
118+
INTERFACE ${arrow_BINARY_DIR}/src
119+
${arrow_SOURCE_DIR}/cpp/src)
120+
endif()
121+
110122
set(ARROW_VENDORED TRUE)
111123
set_target_properties(arrow_static PROPERTIES OUTPUT_NAME "iceberg_vendored_arrow")
112-
install(TARGETS arrow_static
124+
set_target_properties(parquet_static PROPERTIES OUTPUT_NAME
125+
"iceberg_vendored_parquet")
126+
install(TARGETS arrow_static parquet_static
113127
EXPORT iceberg_targets
114128
RUNTIME DESTINATION "${ICEBERG_INSTALL_BINDIR}"
115129
ARCHIVE DESTINATION "${ICEBERG_INSTALL_LIBDIR}"
116130
LIBRARY DESTINATION "${ICEBERG_INSTALL_LIBDIR}")
131+
132+
if(TARGET arrow_bundled_dependencies)
133+
message(STATUS "arrow_bundled_dependencies found")
134+
# arrow_bundled_dependencies is only INSTALL_INTERFACE and will not be built by default.
135+
# We need to add it as a dependency to arrow_static so that it will be built.
136+
add_dependencies(arrow_static arrow_bundled_dependencies)
137+
# We cannot install an IMPORTED target, so we need to install the library manually.
138+
get_target_property(arrow_bundled_dependencies_location arrow_bundled_dependencies
139+
IMPORTED_LOCATION)
140+
install(FILES ${arrow_bundled_dependencies_location}
141+
DESTINATION ${ICEBERG_INSTALL_LIBDIR})
142+
endif()
117143
else()
118144
set(ARROW_VENDORED FALSE)
119145
list(APPEND ICEBERG_SYSTEM_DEPENDENCIES Arrow)

src/iceberg/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,25 +89,29 @@ if(ICEBERG_BUILD_BUNDLE)
8989
ICEBERG_BUNDLE_STATIC_BUILD_INTERFACE_LIBS
9090
"$<IF:$<TARGET_EXISTS:iceberg_static>,iceberg_static,iceberg_shared>"
9191
"$<IF:$<TARGET_EXISTS:Arrow::arrow_static>,Arrow::arrow_static,Arrow::arrow_shared>"
92+
"$<IF:$<TARGET_EXISTS:Parquet::parquet_static>,Parquet::parquet_static,Parquet::parquet_shared>"
9293
"$<IF:$<TARGET_EXISTS:Avro::avrocpp_static>,Avro::avrocpp_static,Avro::avrocpp_shared>"
9394
)
9495
list(APPEND
9596
ICEBERG_BUNDLE_SHARED_BUILD_INTERFACE_LIBS
9697
"$<IF:$<TARGET_EXISTS:iceberg_shared>,iceberg_shared,iceberg_static>"
9798
"$<IF:$<TARGET_EXISTS:Arrow::arrow_shared>,Arrow::arrow_shared,Arrow::arrow_static>"
99+
"$<IF:$<TARGET_EXISTS:Parquet::parquet_shared>,Parquet::parquet_shared,Parquet::parquet_static>"
98100
"$<IF:$<TARGET_EXISTS:Avro::avrocpp_shared>,Avro::avrocpp_shared,Avro::avrocpp_static>"
99101
)
100102

101103
list(APPEND
102104
ICEBERG_BUNDLE_STATIC_INSTALL_INTERFACE_LIBS
103105
"$<IF:$<TARGET_EXISTS:Iceberg::iceberg_static>,Iceberg::iceberg_static,Iceberg::iceberg_shared>"
104106
"$<IF:$<BOOL:${ARROW_VENDORED}>,Iceberg::arrow_static,$<IF:$<TARGET_EXISTS:Arrow::arrow_static>,Arrow::arrow_static,Arrow::arrow_shared>>"
107+
"$<IF:$<BOOL:${ARROW_VENDORED}>,Iceberg::parquet_static,$<IF:$<TARGET_EXISTS:Parquet::parquet_static>,Parquet::parquet_static,Parquet::parquet_shared>>"
105108
"$<IF:$<BOOL:${AVRO_VENDORED}>,Iceberg::avrocpp_s,$<IF:$<TARGET_EXISTS:Avro::avrocpp_static>,Avro::avrocpp_static,Avro::avrocpp_shared>>"
106109
)
107110
list(APPEND
108111
ICEBERG_BUNDLE_SHARED_INSTALL_INTERFACE_LIBS
109112
"$<IF:$<TARGET_EXISTS:Iceberg::iceberg_shared>,Iceberg::iceberg_shared,Iceberg::iceberg_static>"
110113
"$<IF:$<BOOL:${ARROW_VENDORED}>,Iceberg::arrow_static,$<IF:$<TARGET_EXISTS:Arrow::arrow_shared>,Arrow::arrow_shared,Arrow::arrow_static>>"
114+
"$<IF:$<BOOL:${ARROW_VENDORED}>,Iceberg::parquet_static,$<IF:$<TARGET_EXISTS:Parquet::parquet_shared>,Parquet::parquet_shared,Parquet::parquet_static>>"
111115
"$<IF:$<BOOL:${AVRO_VENDORED}>,Iceberg::avrocpp_s,$<IF:$<TARGET_EXISTS:Avro::avrocpp_shared>,Avro::avrocpp_shared,Avro::avrocpp_static>>"
112116
)
113117

src/iceberg/IcebergConfig.cmake.in

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,31 @@ iceberg_find_dependencies("${ICEBERG_SYSTEM_DEPENDENCIES}")
7272

7373
include("${CMAKE_CURRENT_LIST_DIR}/IcebergTargets.cmake")
7474

75+
if(TARGET Iceberg::arrow_static)
76+
add_library(Arrow::arrow_static ALIAS Iceberg::arrow_static)
77+
78+
add_library(Arrow::arrow_bundled_dependencies STATIC IMPORTED)
79+
get_target_property(arrow_static_configurations Iceberg::arrow_static
80+
IMPORTED_CONFIGURATIONS)
81+
foreach(CONFIGURATION ${arrow_static_configurations})
82+
string(TOUPPER "${CONFIGURATION}" CONFIGURATION)
83+
get_target_property(arrow_static_location Iceberg::arrow_static
84+
LOCATION_${CONFIGURATION})
85+
get_filename_component(arrow_lib_dir "${arrow_static_location}" DIRECTORY)
86+
set_property(TARGET Arrow::arrow_bundled_dependencies
87+
APPEND
88+
PROPERTY IMPORTED_CONFIGURATIONS ${CONFIGURATION})
89+
set_target_properties(Arrow::arrow_bundled_dependencies
90+
PROPERTIES IMPORTED_LOCATION_${CONFIGURATION}
91+
"${arrow_lib_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}arrow_bundled_dependencies${CMAKE_STATIC_LIBRARY_SUFFIX}"
92+
)
93+
endforeach()
94+
endif()
95+
96+
if(TARGET Iceberg::parquet_static)
97+
add_library(Parquet::parquet_static ALIAS Iceberg::parquet_static)
98+
endif()
99+
75100
# Find required components
76101
iceberg_find_components("${Iceberg_FIND_COMPONENTS}")
77102

src/iceberg/arrow/demo_arrow.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@
2020
#include "iceberg/arrow/demo_arrow.h"
2121

2222
#include <arrow/config.h>
23+
#include <parquet/parquet_version.h>
2324

2425
#include "iceberg/demo.h"
2526

2627
namespace iceberg::arrow {
2728

2829
std::string DemoArrow::print() const {
29-
return Demo().print() + ", Arrow version: " + ::arrow::GetBuildInfo().version_string;
30+
return Demo().print() + ", Arrow version: " + ::arrow::GetBuildInfo().version_string +
31+
", Parquet version: " + CREATED_BY_VERSION;
3032
}
3133

3234
} // namespace iceberg::arrow

0 commit comments

Comments
 (0)