Skip to content

Commit 51de781

Browse files
JelteFY--
andauthored
Upgrade to DuckDB 1.3.0 (#754)
Fixes #712 --------- Co-authored-by: Yves <[email protected]>
1 parent 49cd676 commit 51de781

File tree

15 files changed

+88
-53
lines changed

15 files changed

+88
-53
lines changed

Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ OBJS += $(subst .c,.o, $(C_SRCS))
1313
# set to `make` to disable ninja
1414
DUCKDB_GEN ?= ninja
1515
# used to know what version of extensions to download
16-
DUCKDB_VERSION = v1.2.2
16+
DUCKDB_VERSION = v1.3.0
1717
# duckdb build tweaks
1818
DUCKDB_CMAKE_VARS = -DBUILD_SHELL=0 -DBUILD_PYTHON=0 -DBUILD_UNITTESTS=0
1919
# set to 1 to disable asserts in DuckDB. This is particularly useful in combinition with MotherDuck.
@@ -38,17 +38,19 @@ else
3838
DUCKDB_MAKE_TARGET = release
3939
endif
4040

41-
PG_DUCKDB_LINK_FLAGS = -Wl,-rpath,$(PG_LIB)/ -Lthird_party/duckdb/build/$(DUCKDB_BUILD_TYPE)/src -L$(PG_LIB) -lstdc++ -llz4
4241
DUCKDB_BUILD_DIR = third_party/duckdb/build/$(DUCKDB_BUILD_TYPE)
4342

4443
ifeq ($(DUCKDB_BUILD), ReleaseStatic)
4544
FULL_DUCKDB_LIB = $(DUCKDB_BUILD_DIR)/libduckdb_bundle.a
46-
PG_DUCKDB_LINK_FLAGS += $(FULL_DUCKDB_LIB)
45+
PG_DUCKDB_LINK_FLAGS = $(FULL_DUCKDB_LIB)
4746
else
4847
FULL_DUCKDB_LIB = $(DUCKDB_BUILD_DIR)/src/libduckdb$(DLSUFFIX)
49-
PG_DUCKDB_LINK_FLAGS += -lduckdb
48+
PG_DUCKDB_LINK_FLAGS = -lduckdb
5049
endif
5150

51+
52+
PG_DUCKDB_LINK_FLAGS += -Wl,-rpath,$(PG_LIB)/ -L$(DUCKDB_BUILD_DIR)/src -L$(PG_LIB) -lstdc++ -llz4
53+
5254
ERROR_ON_WARNING ?=
5355
ifeq ($(ERROR_ON_WARNING), 1)
5456
ERROR_ON_WARNING = -Werror

docs/extensions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ SELECT duckdb.auotoload_extension('iceberg', false);
3636
-- For such extensions, you can still load them manually in a session
3737
SELECT duckdb.load_extension('iceberg');
3838
-- You can also install community extensions
39-
SELECT duckdb.install_extension('duckpgq', 'community');
39+
SELECT duckdb.install_extension('prql', 'community');
4040
```
4141

4242
## Supported Extensions

include/pgduckdb/catalog/pgduckdb_catalog.hpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,21 @@ class PostgresCatalog : public duckdb::Catalog {
3030
duckdb::string GetCatalogType() override;
3131
duckdb::optional_ptr<duckdb::CatalogEntry> CreateSchema(duckdb::CatalogTransaction transaction,
3232
duckdb::CreateSchemaInfo &info) override;
33-
duckdb::optional_ptr<duckdb::SchemaCatalogEntry>
34-
GetSchema(duckdb::CatalogTransaction transaction, const duckdb::string &schema_name,
35-
duckdb::OnEntryNotFound if_not_found,
36-
duckdb::QueryErrorContext error_context = duckdb::QueryErrorContext()) override;
33+
duckdb::optional_ptr<duckdb::SchemaCatalogEntry> LookupSchema(duckdb::CatalogTransaction transaction,
34+
const duckdb::EntryLookupInfo &schema_lookup,
35+
const duckdb::OnEntryNotFound if_not_found) override;
3736
void ScanSchemas(duckdb::ClientContext &context,
3837
std::function<void(duckdb::SchemaCatalogEntry &)> callback) override;
39-
duckdb::unique_ptr<duckdb::PhysicalOperator>
40-
PlanCreateTableAs(duckdb::ClientContext &context, duckdb::LogicalCreateTable &op,
41-
duckdb::unique_ptr<duckdb::PhysicalOperator> plan) override;
42-
duckdb::unique_ptr<duckdb::PhysicalOperator> PlanInsert(duckdb::ClientContext &context, duckdb::LogicalInsert &op,
43-
duckdb::unique_ptr<duckdb::PhysicalOperator> plan) override;
44-
duckdb::unique_ptr<duckdb::PhysicalOperator> PlanDelete(duckdb::ClientContext &context, duckdb::LogicalDelete &op,
45-
duckdb::unique_ptr<duckdb::PhysicalOperator> plan) override;
46-
duckdb::unique_ptr<duckdb::PhysicalOperator> PlanUpdate(duckdb::ClientContext &context, duckdb::LogicalUpdate &op,
47-
duckdb::unique_ptr<duckdb::PhysicalOperator> plan) override;
38+
duckdb::PhysicalOperator &PlanCreateTableAs(duckdb::ClientContext &context, duckdb::PhysicalPlanGenerator &planner,
39+
duckdb::LogicalCreateTable &op,
40+
duckdb::PhysicalOperator &plan) override;
41+
duckdb::PhysicalOperator &PlanInsert(duckdb::ClientContext &context, duckdb::PhysicalPlanGenerator &planner,
42+
duckdb::LogicalInsert &op,
43+
duckdb::optional_ptr<duckdb::PhysicalOperator> plan) override;
44+
duckdb::PhysicalOperator &PlanDelete(duckdb::ClientContext &context, duckdb::PhysicalPlanGenerator &planner,
45+
duckdb::LogicalDelete &op, duckdb::PhysicalOperator &plan) override;
46+
duckdb::PhysicalOperator &PlanUpdate(duckdb::ClientContext &context, duckdb::PhysicalPlanGenerator &planner,
47+
duckdb::LogicalUpdate &op, duckdb::PhysicalOperator &plan) override;
4848
duckdb::unique_ptr<duckdb::LogicalOperator>
4949
BindCreateIndex(duckdb::Binder &binder, duckdb::CreateStatement &stmt, duckdb::TableCatalogEntry &table,
5050
duckdb::unique_ptr<duckdb::LogicalOperator> plan) override;

include/pgduckdb/catalog/pgduckdb_schema.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ class PostgresSchema : public duckdb::SchemaCatalogEntry {
3737
duckdb::CreateCollationInfo &info) override;
3838
duckdb::optional_ptr<duckdb::CatalogEntry> CreateType(duckdb::CatalogTransaction transaction,
3939
duckdb::CreateTypeInfo &info) override;
40-
duckdb::optional_ptr<duckdb::CatalogEntry> GetEntry(duckdb::CatalogTransaction transaction,
41-
duckdb::CatalogType type, const duckdb::string &name) override;
40+
duckdb::optional_ptr<duckdb::CatalogEntry> LookupEntry(duckdb::CatalogTransaction transaction,
41+
const duckdb::EntryLookupInfo &lookup_info) override;
4242
void DropEntry(duckdb::ClientContext &context, duckdb::DropInfo &info) override;
4343
void Alter(duckdb::CatalogTransaction transaction, duckdb::AlterInfo &info) override;
4444

src/catalog/pgduckdb_catalog.cpp

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,15 @@ PostgresCatalog::CreateSchema(duckdb::CatalogTransaction, duckdb::CreateSchemaIn
3737
}
3838

3939
duckdb::optional_ptr<duckdb::SchemaCatalogEntry>
40-
PostgresCatalog::GetSchema(duckdb::CatalogTransaction catalog_transaction, const duckdb::string &schema_name,
41-
duckdb::OnEntryNotFound, duckdb::QueryErrorContext) {
40+
PostgresCatalog::LookupSchema(duckdb::CatalogTransaction catalog_transaction,
41+
const duckdb::EntryLookupInfo &schema_lookup, duckdb::OnEntryNotFound) {
4242
auto &pg_transaction = catalog_transaction.transaction->Cast<PostgresTransaction>();
43-
auto res = pg_transaction.GetCatalogEntry(duckdb::CatalogType::SCHEMA_ENTRY, schema_name, "");
43+
const auto catalog_type = schema_lookup.GetCatalogType();
44+
if (catalog_type != duckdb::CatalogType::SCHEMA_ENTRY) {
45+
throw duckdb::NotImplementedException("LookupSchema only supports SCHEMA_ENTRY");
46+
}
47+
48+
auto res = pg_transaction.GetCatalogEntry(catalog_type, schema_lookup.GetEntryName(), "");
4449
D_ASSERT(res);
4550
D_ASSERT(res->type == duckdb::CatalogType::SCHEMA_ENTRY);
4651
return (duckdb::SchemaCatalogEntry *)res.get();
@@ -50,27 +55,27 @@ void
5055
PostgresCatalog::ScanSchemas(duckdb::ClientContext &, std::function<void(duckdb::SchemaCatalogEntry &)>) {
5156
}
5257

53-
duckdb::unique_ptr<duckdb::PhysicalOperator>
54-
PostgresCatalog::PlanCreateTableAs(duckdb::ClientContext &, duckdb::LogicalCreateTable &,
55-
duckdb::unique_ptr<duckdb::PhysicalOperator>) {
58+
duckdb::PhysicalOperator &
59+
PostgresCatalog::PlanCreateTableAs(duckdb::ClientContext &, duckdb::PhysicalPlanGenerator &,
60+
duckdb::LogicalCreateTable &, duckdb::PhysicalOperator &) {
5661
throw duckdb::NotImplementedException("PlanCreateTableAs not supported yet");
5762
}
5863

59-
duckdb::unique_ptr<duckdb::PhysicalOperator>
60-
PostgresCatalog::PlanInsert(duckdb::ClientContext &, duckdb::LogicalInsert &,
61-
duckdb::unique_ptr<duckdb::PhysicalOperator>) {
64+
duckdb::PhysicalOperator &
65+
PostgresCatalog::PlanInsert(duckdb::ClientContext &, duckdb::PhysicalPlanGenerator &, duckdb::LogicalInsert &,
66+
duckdb::optional_ptr<duckdb::PhysicalOperator>) {
6267
throw duckdb::NotImplementedException("PlanInsert not supported yet");
6368
}
6469

65-
duckdb::unique_ptr<duckdb::PhysicalOperator>
66-
PostgresCatalog::PlanDelete(duckdb::ClientContext &, duckdb::LogicalDelete &,
67-
duckdb::unique_ptr<duckdb::PhysicalOperator>) {
70+
duckdb::PhysicalOperator &
71+
PostgresCatalog::PlanDelete(duckdb::ClientContext &, duckdb::PhysicalPlanGenerator &, duckdb::LogicalDelete &,
72+
duckdb::PhysicalOperator &) {
6873
throw duckdb::NotImplementedException("PlanDelete not supported yet");
6974
}
7075

71-
duckdb::unique_ptr<duckdb::PhysicalOperator>
72-
PostgresCatalog::PlanUpdate(duckdb::ClientContext &, duckdb::LogicalUpdate &,
73-
duckdb::unique_ptr<duckdb::PhysicalOperator>) {
76+
duckdb::PhysicalOperator &
77+
PostgresCatalog::PlanUpdate(duckdb::ClientContext &, duckdb::PhysicalPlanGenerator &, duckdb::LogicalUpdate &,
78+
duckdb::PhysicalOperator &) {
7479
throw duckdb::NotImplementedException("PlanUpdate not supported yet");
7580
}
7681

src/catalog/pgduckdb_schema.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ PostgresSchema::CreateType(duckdb::CatalogTransaction, duckdb::CreateTypeInfo &)
7171
}
7272

7373
duckdb::optional_ptr<duckdb::CatalogEntry>
74-
PostgresSchema::GetEntry(duckdb::CatalogTransaction _catalog_transaction, duckdb::CatalogType _type,
75-
const duckdb::string &_entry_name) {
74+
PostgresSchema::LookupEntry(duckdb::CatalogTransaction _catalog_transaction,
75+
const duckdb::EntryLookupInfo &lookup_info) {
7676
auto &pg_transaction = _catalog_transaction.transaction->Cast<PostgresTransaction>();
77-
return pg_transaction.GetCatalogEntry(_type, name, _entry_name);
77+
return pg_transaction.GetCatalogEntry(lookup_info.GetCatalogType(), name, lookup_info.GetEntryName());
7878
}
7979

8080
void

test/pycheck/non_superuser_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,26 @@ def test_community_extensions(pg: Postgres):
1818
match="Permission Error: File system LocalFileSystem has been disabled by configuration",
1919
):
2020
cur.sql(
21-
"SELECT * FROM duckdb.raw_query($$ INSTALL duckpgq FROM community; $$)"
21+
"SELECT * FROM duckdb.raw_query($$ INSTALL prql FROM community; $$)"
2222
)
2323

2424
# Even if such community extensions somehow get installed, it's not possible
2525
# to load them without changing allow_community_extensions. Not even for a
2626
# superuser.
2727
with pg.cur() as cur:
2828
cur.sql("SET duckdb.force_execution = false")
29-
cur.sql("SELECT * FROM duckdb.raw_query($$ INSTALL duckpgq FROM community; $$)")
29+
cur.sql("SELECT * FROM duckdb.raw_query($$ INSTALL prql FROM community; $$)")
3030
with pytest.raises(
3131
Exception,
3232
match="IO Error: Extension .* could not be loaded because its signature is either missing or invalid and unsigned extensions are disabled by configuration",
3333
):
34-
cur.sql("SELECT * FROM duckdb.raw_query($$ LOAD duckpgq; $$)")
34+
cur.sql("SELECT * FROM duckdb.raw_query($$ LOAD prql; $$)")
3535

3636
# But it should be possible to load them after changing that setting.
3737
with pg.cur() as cur:
3838
cur.sql("SET duckdb.allow_community_extensions = true")
3939
cur.sql("SET duckdb.force_execution = false")
40-
cur.sql("SELECT * FROM duckdb.raw_query($$ LOAD duckpgq; $$)")
40+
cur.sql("SELECT * FROM duckdb.raw_query($$ LOAD prql; $$)")
4141

4242
# And that setting is only changeable by superusers
4343
with pg.cur() as cur:

test/pycheck/utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,11 @@ def restart(self):
793793

794794
def reset(self):
795795
os.truncate(self.pgdata / "postgresql.auto.conf", 0)
796-
self.sql("TRUNCATE duckdb.extensions")
796+
try:
797+
self.sql("TRUNCATE duckdb.extensions")
798+
except psycopg.errors.InvalidSchemaName:
799+
# pg_duckdb is not installed, so no need to reset the extensions
800+
pass
797801

798802
# If a previous test restarted postgres, it was probably because of some
799803
# config that could only be changed across restarts. To reset those, we'll

test/regression/expected/execution_error.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ INSERT INTO int_as_varchar SELECT * from (
44
('abc')
55
) t(a);
66
SELECT a::INTEGER FROM int_as_varchar;
7-
ERROR: (PGDuckDB/Duckdb_ExecCustomScan_Cpp) Conversion Error: Could not convert string 'abc' to INT32
7+
ERROR: (PGDuckDB/Duckdb_ExecCustomScan_Cpp) Conversion Error: Could not convert string 'abc' to INT32 when casting from source column a
88

99
LINE 1: SELECT (a)::integer AS a FROM pgduckdb.public.int_as_varchar
1010
^

test/regression/expected/extensions.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ SELECT * FROM duckdb.query($$ SELECT extension_name, loaded, installed, installe
177177
pgduckdb | t | f |
178178
(6 rows)
179179

180-
SELECT duckdb.install_extension('duckpgq', 'community');
180+
SELECT duckdb.install_extension('prql', 'community');
181181
install_extension
182182
-------------------
183183

@@ -193,12 +193,12 @@ SELECT * FROM duckdb.query($$ SELECT extension_name, loaded, installed, installe
193193
extension_name | loaded | installed | installed_from
194194
----------------+--------+-----------+----------------
195195
core_functions | t | t |
196-
duckpgq | t | t | community
197196
httpfs | t | t |
198197
icu | t | t |
199198
json | t | t |
200199
parquet | t | t |
201200
pgduckdb | t | f |
201+
prql | t | t | community
202202
(7 rows)
203203

204204
-- cleanup

test/regression/expected/temporary_tables.out

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,18 @@ EXPLAIN VERBOSE INSERT INTO tc(c) SELECT md5('ta');
480480
┌─────────────┴─────────────┐
481481
│ PROJECTION │
482482
│ ──────────────────── │
483+
│ CAST(3 AS INTEGER) │
484+
│ NULL │
485+
│ #0 │
486+
│ (CAST('a' AS VARCHAR) || │
487+
│ CAST('b' AS VARCHAR)) │
488+
│ (1 + 2) │
489+
│ │
490+
│ ~1 Rows │
491+
└─────────────┬─────────────┘
492+
┌─────────────┴─────────────┐
493+
│ PROJECTION │
494+
│ ──────────────────── │
483495
│ md5 │
484496
│ │
485497
│ ~1 Rows │
@@ -489,7 +501,7 @@ EXPLAIN VERBOSE INSERT INTO tc(c) SELECT md5('ta');
489501
└───────────────────────────┘
490502

491503

492-
(19 rows)
504+
(31 rows)
493505

494506
INSERT INTO tc(c) SELECT md5('ta');
495507
EXPLAIN VERBOSE INSERT INTO tc(d) SELECT md5('test');
@@ -505,6 +517,18 @@ EXPLAIN VERBOSE INSERT INTO tc(d) SELECT md5('test');
505517
┌─────────────┴─────────────┐
506518
│ PROJECTION │
507519
│ ──────────────────── │
520+
│ CAST(3 AS INTEGER) │
521+
│ NULL │
522+
│ CAST('pg_duckdb' AS │
523+
│ VARCHAR) │
524+
│ #0 │
525+
│ (1 + 2) │
526+
│ │
527+
│ ~1 Rows │
528+
└─────────────┬─────────────┘
529+
┌─────────────┴─────────────┐
530+
│ PROJECTION │
531+
│ ──────────────────── │
508532
│ md5 │
509533
│ │
510534
│ ~1 Rows │
@@ -514,7 +538,7 @@ EXPLAIN VERBOSE INSERT INTO tc(d) SELECT md5('test');
514538
└───────────────────────────┘
515539

516540

517-
(19 rows)
541+
(31 rows)
518542

519543
INSERT INTO tc(d) SELECT md5('test');
520544
SELECT * FROM tc;
@@ -527,7 +551,7 @@ SELECT * FROM tc;
527551
-- Set Returning Function
528552
TRUNCATE TABLE ta;
529553
INSERT INTO ta (a) SELECT generate_series(1, 3); -- failed. DuckDB expects this "INSERT INTO ta (a) FROM generate_series(1, 3)"
530-
ERROR: (PGDuckDB/Duckdb_ExecCustomScan_Cpp) Conversion Error: Unimplemented type for cast (BIGINT[] -> INTEGER)
554+
ERROR: (PGDuckDB/Duckdb_ExecCustomScan_Cpp) Conversion Error: Unimplemented type for cast (BIGINT[] -> INTEGER) when casting from source column generate_series
531555

532556
LINE 1: INSERT INTO pg_temp.main.ta (a) SELECT generate_series(1, 3) AS generate_series
533557
^

test/regression/expected/transaction_errors.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CREATE TABLE foo AS SELECT 'bar'::text AS t;
22
BEGIN; SET duckdb.force_execution = true; SELECT t::integer AS t1 FROM foo; ROLLBACK;
3-
ERROR: (PGDuckDB/Duckdb_ExecCustomScan_Cpp) Conversion Error: Could not convert string 'bar' to INT32
3+
ERROR: (PGDuckDB/Duckdb_ExecCustomScan_Cpp) Conversion Error: Could not convert string 'bar' to INT32 when casting from source column t
44

55
LINE 1: SELECT (t)::integer AS t1 FROM pgduckdb.public.foo
66
^

test/regression/sql/extensions.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ SELECT * FROM duckdb.query($$ SELECT extension_name, loaded, installed, installe
6161
CALL duckdb.recycle_ddb();
6262
SELECT * FROM duckdb.query($$ SELECT extension_name, loaded, installed, installed_from FROM duckdb_extensions() WHERE loaded and extension_name != 'jemalloc' $$);
6363

64-
SELECT duckdb.install_extension('duckpgq', 'community');
64+
SELECT duckdb.install_extension('prql', 'community');
6565

6666
SELECT last_value FROM duckdb.extensions_table_seq;
6767

third_party/duckdb

Submodule duckdb updated 2380 files

third_party/pg_duckdb_extensions.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ duckdb_extension_load(json)
22
duckdb_extension_load(icu)
33
duckdb_extension_load(httpfs
44
GIT_URL https://github.com/duckdb/duckdb-httpfs
5-
GIT_TAG cf3584b48ddabdfb58ef69d2649896da2e466405
5+
GIT_TAG 7ce5308ed8fe48b593538dbd54344a2fc0695bc7
66
INCLUDE_DIR extension/httpfs/include
77
)

0 commit comments

Comments
 (0)