Skip to content

Commit 751d1a4

Browse files
akvladlmangani
andauthored
Feature: read_parquet_mergetree (#13)
* parquet ordered scan / mergetree like feature Co-authored-by: Lorenzo Mangani <[email protected]>
1 parent f8c9234 commit 751d1a4

12 files changed

+454
-33
lines changed

CMakeLists.txt

+3-20
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,13 @@
11
cmake_minimum_required(VERSION 3.5)
2-
32
# Set extension name here
43
set(TARGET_NAME chsql)
5-
64
# DuckDB's extension distribution supports vcpkg. As such, dependencies can be added in ./vcpkg.json and then
75
# used in cmake with find_package. Feel free to remove or replace with other dependencies.
86
# Note that it should also be removed from vcpkg.json to prevent needlessly installing it..
97
find_package(OpenSSL REQUIRED)
10-
118
set(EXTENSION_NAME ${TARGET_NAME}_extension)
129
set(LOADABLE_EXTENSION_NAME ${TARGET_NAME}_loadable_extension)
13-
1410
project(${TARGET_NAME})
15-
include_directories(src/include)
16-
17-
set(EXTENSION_SOURCES src/chsql_extension.cpp)
18-
19-
build_static_extension(${TARGET_NAME} ${EXTENSION_SOURCES})
20-
build_loadable_extension(${TARGET_NAME} " " ${EXTENSION_SOURCES})
21-
22-
# Link OpenSSL in both the static library as the loadable extension
23-
target_link_libraries(${EXTENSION_NAME} OpenSSL::SSL OpenSSL::Crypto)
24-
target_link_libraries(${LOADABLE_EXTENSION_NAME} OpenSSL::SSL OpenSSL::Crypto)
25-
26-
install(
27-
TARGETS ${EXTENSION_NAME}
28-
EXPORT "${DUCKDB_EXPORT_SET}"
29-
LIBRARY DESTINATION "${INSTALL_LIB_DIR}"
30-
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}")
11+
set(EXT_NAME chsql)
12+
set(DUCKDB_EXTENSION_CONFIGS ../chsql/extension_config.cmake)
13+
add_subdirectory(./duckdb)

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PROJ_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
1+
PROJ_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))chsql/
22

33
# Configuration of extension
44
EXT_NAME=chsql

chsql/CMakeLists.txt

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
# Set extension name here
3+
set(TARGET_NAME chsql)
4+
# DuckDB's extension distribution supports vcpkg. As such, dependencies can be added in ./vcpkg.json and then
5+
# used in cmake with find_package. Feel free to remove or replace with other dependencies.
6+
# Note that it should also be removed from vcpkg.json to prevent needlessly installing it..
7+
find_package(OpenSSL REQUIRED)
8+
set(EXTENSION_NAME ${TARGET_NAME}_extension)
9+
set(LOADABLE_EXTENSION_NAME ${TARGET_NAME}_loadable_extension)
10+
project(${TARGET_NAME})
11+
12+
include_directories(
13+
./src/include
14+
./src
15+
${CMAKE_CURRENT_SOURCE_DIR}/../duckdb/extension/parquet/include
16+
../duckdb/third_party/lz4
17+
../duckdb/third_party/parquet
18+
../duckdb/third_party/thrift
19+
../duckdb/third_party/snappy
20+
../duckdb/third_party/zstd/include
21+
../duckdb/third_party/mbedtls
22+
../duckdb/third_party/mbedtls/include
23+
../duckdb/third_party/brotli/include)
24+
set(EXTENSION_SOURCES src/chsql_extension.cpp)
25+
build_static_extension(${TARGET_NAME} ${EXTENSION_SOURCES})
26+
build_loadable_extension(${TARGET_NAME} " " ${EXTENSION_SOURCES})
27+
# Link OpenSSL in both the static library as the loadable extension
28+
target_link_libraries(${EXTENSION_NAME} OpenSSL::SSL OpenSSL::Crypto)
29+
target_link_libraries(${LOADABLE_EXTENSION_NAME} OpenSSL::SSL OpenSSL::Crypto)
30+
install(
31+
TARGETS ${EXTENSION_NAME}
32+
EXPORT "${DUCKDB_EXPORT_SET}"
33+
LIBRARY DESTINATION "${INSTALL_LIB_DIR}"
34+
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}")

chsql/extension_config.cmake

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# This file is included by DuckDB's build system. It specifies which extension to load
2+
3+
include_directories(
4+
./src/include
5+
${CMAKE_CURRENT_SOURCE_DIR}/../duckdb/extension/parquet/include
6+
../duckdb/third_party/lz4
7+
../duckdb/third_party/parquet
8+
../duckdb/third_party/thrift
9+
../duckdb/third_party/snappy
10+
../duckdb/third_party/zstd/include
11+
../duckdb/third_party/mbedtls
12+
../duckdb/third_party/mbedtls/include
13+
../duckdb/third_party/brotli/include)
14+
15+
# Extension from this repo
16+
duckdb_extension_load(chsql
17+
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}
18+
LOAD_TESTS
19+
)
20+
21+
# Any extra extensions that should be built
22+
# e.g.: duckdb_extension_load(json)

src/chsql_extension.cpp chsql/src/chsql_extension.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
// OpenSSL linked through vcpkg
1414
#include <openssl/opensslv.h>
15-
15+
#include "parquet_ordered_scan.cpp"
1616
namespace duckdb {
1717

1818
// To add a new scalar SQL macro, add a new macro to this array!
@@ -188,6 +188,7 @@ static void LoadInternal(DatabaseInstance &instance) {
188188
auto table_info = DefaultTableFunctionGenerator::CreateTableMacroInfo(chsql_table_macros[index]);
189189
ExtensionUtil::RegisterFunction(instance, *table_info);
190190
}
191+
ExtensionUtil::RegisterFunction(instance, ReadParquetOrderedFunction());
191192
}
192193

193194
void ChsqlExtension::Load(DuckDB &db) {

src/include/chsql_extension.hpp chsql/src/include/chsql_extension.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ class ChsqlExtension : public Extension {
1010
std::string Name() override;
1111
std::string Version() const override;
1212
};
13-
13+
duckdb::TableFunction ReadParquetOrderedFunction();
14+
static void RegisterSillyBTreeStore(DatabaseInstance &instance);
1415
} // namespace duckdb

0 commit comments

Comments
 (0)