Skip to content

Commit 3a6fcd7

Browse files
committed
Support DuckDB v1.4
1 parent 44a4dc4 commit 3a6fcd7

File tree

9 files changed

+56
-6
lines changed

9 files changed

+56
-6
lines changed

.github/workflows/MainDistributionPipeline.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ jobs:
1515
duckdb-next-build:
1616
name: Build extension binaries
1717
uses: duckdb/extension-ci-tools/.github/workflows/_extension_distribution.yml@main
18-
if: false # extension-template is currently not compatible with main
1918
with:
2019
duckdb_version: main
2120
ci_tools_version: main
2221
enable_rust: true
22+
exclude_archs: windows_amd64;windows_amd64_mingw;wasm_mvp;wasm_eh;wasm_threads
2323
extension_name: mooncake
2424

2525
duckdb-stable-build:

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ set(LINK_LIBRARIES
5858
nanoarrow::nanoarrow_ipc
5959
roaring::roaring)
6060

61+
target_compile_definitions(${EXTENSION_NAME} PRIVATE DUCKDB_MINOR_VERSION=${DUCKDB_MINOR_VERSION})
62+
target_compile_definitions(${LOADABLE_EXTENSION_NAME} PRIVATE DUCKDB_MINOR_VERSION=${DUCKDB_MINOR_VERSION})
63+
6164
target_link_libraries(${EXTENSION_NAME} moonlink_ffi-static ${LINK_LIBRARIES})
6265
target_link_libraries(${LOADABLE_EXTENSION_NAME} moonlink_ffi ${LINK_LIBRARIES})
6366

duckdb

Submodule duckdb updated 3358 files

src/include/mooncake_extension.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ namespace duckdb {
66

77
class MooncakeExtension : public Extension {
88
public:
9+
#if DUCKDB_MINOR_VERSION == 3
910
void Load(DuckDB &db) override;
11+
#else
12+
void Load(ExtensionLoader &loader) override;
13+
#endif
1014

1115
string Name() override;
1216

src/mooncake_extension.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@
88

99
namespace duckdb {
1010

11+
#if DUCKDB_MINOR_VERSION == 3
1112
void MooncakeExtension::Load(DuckDB &db) {
1213
auto &config = DBConfig::GetConfig(*db.instance);
14+
#else
15+
void MooncakeExtension::Load(ExtensionLoader &loader) {
16+
auto &db = loader.GetDatabaseInstance();
17+
auto &config = DBConfig::GetConfig(db);
18+
#endif
1319
config.storage_extensions["mooncake"] = make_uniq<MooncakeStorageExtension>();
1420

1521
string init_query = Pgmooncake::GetInitQuery();
@@ -33,6 +39,7 @@ string MooncakeExtension::Version() const {
3339
} // namespace duckdb
3440

3541
extern "C" {
42+
#if DUCKDB_MINOR_VERSION == 3
3643
DUCKDB_EXTENSION_API void mooncake_init(duckdb::DatabaseInstance &db) {
3744
duckdb::DuckDB db_wrapper(db);
3845
db_wrapper.LoadExtension<duckdb::MooncakeExtension>();
@@ -41,4 +48,9 @@ DUCKDB_EXTENSION_API void mooncake_init(duckdb::DatabaseInstance &db) {
4148
DUCKDB_EXTENSION_API const char *mooncake_version() {
4249
return duckdb::DuckDB::LibraryVersion();
4350
}
51+
#else
52+
DUCKDB_CPP_EXTENSION_ENTRY(mooncake, loader) {
53+
duckdb::MooncakeExtension().Load(loader);
54+
}
55+
#endif
4456
}

src/storage/mooncake_scan.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#include "duckdb/catalog/catalog_entry/table_function_catalog_entry.hpp"
22
#include "duckdb/common/multi_file/multi_file_reader.hpp"
3+
#if DUCKDB_MINOR_VERSION == 3
34
#include "duckdb/main/extension_util.hpp"
5+
#else
6+
#include "duckdb/main/extension_helper.hpp"
7+
#endif
48
#include "duckdb/parser/tableref/table_function_ref.hpp"
59
#include "parquet_reader.hpp"
610
#include "storage/mooncake_table.hpp"
@@ -106,7 +110,11 @@ struct MooncakeMultiFileReader : public MultiFileReader {
106110
return make_uniq<MooncakeMultiFileReader>(table_function.function_info->Cast<MooncakeFunctionInfo>().table);
107111
}
108112

113+
#if DUCKDB_MINOR_VERSION == 3
109114
shared_ptr<MultiFileList> CreateFileList(ClientContext &, const vector<string> &, FileGlobOptions) override {
115+
#else
116+
shared_ptr<MultiFileList> CreateFileList(ClientContext &, const vector<string> &, const FileGlobInput &) override {
117+
#endif
110118
return make_shared_ptr<MooncakeMultiFileList>(table);
111119
}
112120

@@ -135,7 +143,13 @@ struct MooncakeMultiFileReader : public MultiFileReader {
135143
};
136144

137145
static TableFunction &GetParquetScan(ClientContext &context) {
146+
#if DUCKDB_MINOR_VERSION == 3
138147
return ExtensionUtil::GetTableFunction(*context.db, "parquet_scan").functions.GetFunctionReferenceByOffset(0);
148+
#else
149+
ExtensionHelper::AutoLoadExtension(*context.db, "parquet");
150+
ExtensionLoader loader(*context.db, "mooncake");
151+
return loader.GetTableFunction("parquet_scan").functions.GetFunctionReferenceByOffset(0);
152+
#endif
139153
}
140154

141155
static unique_ptr<GlobalTableFunctionState> MooncakeScanInitGlobal(ClientContext &context,

src/storage/mooncake_schema.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,22 @@ optional_ptr<CatalogEntry> MooncakeSchema::LookupEntry(CatalogTransaction transa
8686
throw InternalException("Error decoding schema: %s", ArrowErrorMessage(&error));
8787
}
8888

89+
#if DUCKDB_MINOR_VERSION == 3
8990
ArrowTableType arrow_table;
9091
vector<string> names;
91-
vector<LogicalType> return_types;
92-
ArrowTableFunction::PopulateArrowTableType(transaction.db->config, arrow_table, schema, names, return_types);
92+
vector<LogicalType> types;
93+
ArrowTableFunction::PopulateArrowTableType(transaction.db->config, arrow_table, schema, names, types);
94+
#else
95+
ArrowTableSchema arrow_table;
96+
ArrowTableFunction::PopulateArrowTableSchema(transaction.db->config, arrow_table, schema.arrow_schema);
97+
auto &names = arrow_table.GetNames();
98+
auto &types = arrow_table.GetTypes();
99+
#endif
93100

94101
CreateTableInfo table_info;
95102
table_info.table = table_name;
96103
for (idx_t i = 0; i < names.size(); i++) {
97-
table_info.columns.AddColumn(ColumnDefinition(names[i], return_types[i]));
104+
table_info.columns.AddColumn(ColumnDefinition(names[i], types[i]));
98105
}
99106
tables[table_name] = make_uniq<MooncakeTable>(catalog, *this, table_info, lsn, moonlink);
100107
return *tables[table_name];

src/storage/mooncake_storage.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44

55
namespace duckdb {
66

7+
#if DUCKDB_MINOR_VERSION == 3
78
unique_ptr<Catalog> MooncakeAttach(StorageExtensionInfo *storage_info, ClientContext &context, AttachedDatabase &db,
89
const string &name, AttachInfo &info, AccessMode access_mode) {
10+
#else
11+
unique_ptr<Catalog> MooncakeAttach(optional_ptr<StorageExtensionInfo> storage_info, ClientContext &context,
12+
AttachedDatabase &db, const string &name, AttachInfo &info, AttachOptions &options) {
13+
#endif
914
string uri;
1015
string database;
1116
for (auto &entry : info.options) {
@@ -29,8 +34,13 @@ unique_ptr<Catalog> MooncakeAttach(StorageExtensionInfo *storage_info, ClientCon
2934
return make_uniq<MooncakeCatalog>(db, std::move(uri), std::move(database));
3035
}
3136

37+
#if DUCKDB_MINOR_VERSION == 3
3238
unique_ptr<TransactionManager> MooncakeCreateTransactionManager(StorageExtensionInfo *storage_info,
3339
AttachedDatabase &db, Catalog &catalog) {
40+
#else
41+
unique_ptr<TransactionManager> MooncakeCreateTransactionManager(optional_ptr<StorageExtensionInfo> storage_info,
42+
AttachedDatabase &db, Catalog &catalog) {
43+
#endif
3444
return make_uniq<MooncakeTransactionManager>(db, catalog);
3545
}
3646

0 commit comments

Comments
 (0)