Skip to content

Commit 4d3a847

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

File tree

10 files changed

+69
-18
lines changed

10 files changed

+69
-18
lines changed
Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#
2-
# This workflow calls the main distribution pipeline from DuckDB to build, test and (optionally) release the extension
3-
#
41
name: Main Extension Distribution Pipeline
52
on:
63
push:
@@ -12,17 +9,17 @@ concurrency:
129
cancel-in-progress: true
1310

1411
jobs:
15-
duckdb-next-build:
12+
duckdb-stable-build:
1613
name: Build extension binaries
17-
uses: duckdb/extension-ci-tools/.github/workflows/_extension_distribution.yml@main
18-
if: false # extension-template is currently not compatible with main
14+
uses: duckdb/extension-ci-tools/.github/workflows/[email protected]
1915
with:
20-
duckdb_version: main
21-
ci_tools_version: main
16+
duckdb_version: v1.4.0
17+
ci_tools_version: v1.4.0
2218
enable_rust: true
19+
exclude_archs: windows_amd64;windows_amd64_mingw;wasm_mvp;wasm_eh;wasm_threads
2320
extension_name: mooncake
2421

25-
duckdb-stable-build:
22+
duckdb-oldstable-build:
2623
name: Build extension binaries
2724
uses: duckdb/extension-ci-tools/.github/workflows/[email protected]
2825
with:
@@ -36,7 +33,7 @@ jobs:
3633
name: Code Quality Check
3734
uses: duckdb/extension-ci-tools/.github/workflows/_extension_code_quality.yml@main
3835
with:
39-
duckdb_version: v1.3.2
36+
duckdb_version: main
4037
ci_tools_version: main
4138
extension_name: mooncake
42-
format_checks: format
39+
format_checks: format;tidy

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
PROJ_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
22

3-
# Configuration of extension
43
EXT_NAME=mooncake
54
EXT_CONFIG=${PROJ_DIR}extension_config.cmake
65

7-
# Include the Makefile from extension-ci-tools
6+
DUCKDB_MINOR_VERSION = $(if $(wildcard duckdb/src/include/duckdb/main/extension/extension_loader.hpp),4,3)
7+
export CXXFLAGS += -DDUCKDB_MINOR_VERSION=$(DUCKDB_MINOR_VERSION)
8+
89
include extension-ci-tools/makefiles/duckdb_extension.Makefile
910

1011
format-all:

duckdb

Submodule duckdb updated 3343 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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,24 @@
22

33
#include "duckdb/main/connection.hpp"
44
#include "duckdb/main/database.hpp"
5+
#if DUCKDB_MINOR_VERSION > 3
6+
#include "duckdb/main/extension_helper.hpp"
7+
#endif
58
#include "mooncake_extension.hpp"
69
#include "pgmooncake.hpp"
710
#include "storage/mooncake_storage.hpp"
811

912
namespace duckdb {
1013

14+
#if DUCKDB_MINOR_VERSION == 3
1115
void MooncakeExtension::Load(DuckDB &db) {
1216
auto &config = DBConfig::GetConfig(*db.instance);
17+
#else
18+
void MooncakeExtension::Load(ExtensionLoader &loader) {
19+
auto &db = loader.GetDatabaseInstance();
20+
ExtensionHelper::AutoLoadExtension(db, "parquet");
21+
auto &config = DBConfig::GetConfig(db);
22+
#endif
1323
config.storage_extensions["mooncake"] = make_uniq<MooncakeStorageExtension>();
1424

1525
string init_query = Pgmooncake::GetInitQuery();
@@ -33,6 +43,7 @@ string MooncakeExtension::Version() const {
3343
} // namespace duckdb
3444

3545
extern "C" {
46+
#if DUCKDB_MINOR_VERSION == 3
3647
DUCKDB_EXTENSION_API void mooncake_init(duckdb::DatabaseInstance &db) {
3748
duckdb::DuckDB db_wrapper(db);
3849
db_wrapper.LoadExtension<duckdb::MooncakeExtension>();
@@ -41,4 +52,9 @@ DUCKDB_EXTENSION_API void mooncake_init(duckdb::DatabaseInstance &db) {
4152
DUCKDB_EXTENSION_API const char *mooncake_version() {
4253
return duckdb::DuckDB::LibraryVersion();
4354
}
55+
#else
56+
DUCKDB_CPP_EXTENSION_ENTRY(mooncake, loader) {
57+
duckdb::MooncakeExtension().Load(loader);
58+
}
59+
#endif
4460
}

src/storage/mooncake_scan.cpp

Lines changed: 13 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/extension_loader.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,12 @@ 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+
ExtensionLoader loader(*context.db, "mooncake");
150+
return loader.GetTableFunction("parquet_scan").functions.GetFunctionReferenceByOffset(0);
151+
#endif
139152
}
140153

141154
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

vcpkg.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
"vcpkg-configuration": {
66
"overlay-ports": [
77
"./extension-ci-tools/vcpkg_ports"
8+
],
9+
"overlay-triplets": [
10+
"./extension-ci-tools/toolchains"
811
]
912
}
1013
}

0 commit comments

Comments
 (0)