Skip to content

Upgrade to DuckDB 1.3.0 #754

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ OBJS += $(subst .c,.o, $(C_SRCS))
# set to `make` to disable ninja
DUCKDB_GEN ?= ninja
# used to know what version of extensions to download
DUCKDB_VERSION = v1.2.2
DUCKDB_VERSION = v1.3.0
# duckdb build tweaks
DUCKDB_CMAKE_VARS = -DBUILD_SHELL=0 -DBUILD_PYTHON=0 -DBUILD_UNITTESTS=0
# set to 1 to disable asserts in DuckDB. This is particularly useful in combinition with MotherDuck.
Expand Down
2 changes: 1 addition & 1 deletion docs/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ UPDATE duckdb.extensions SET enabled = (false|true) WHERE name = 'iceberg';
-- remove an extension
DELETE FROM duckdb.extensions WHERE name = 'iceberg';
-- You can also install community extensions
SELECT duckdb.install_extension('duckpgq', 'community');
SELECT duckdb.install_extension('prql', 'community');
```

There is currently no practical difference between a disabled and uninstalled extension.
Expand Down
26 changes: 13 additions & 13 deletions include/pgduckdb/catalog/pgduckdb_catalog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@ class PostgresCatalog : public duckdb::Catalog {
duckdb::string GetCatalogType() override;
duckdb::optional_ptr<duckdb::CatalogEntry> CreateSchema(duckdb::CatalogTransaction transaction,
duckdb::CreateSchemaInfo &info) override;
duckdb::optional_ptr<duckdb::SchemaCatalogEntry>
GetSchema(duckdb::CatalogTransaction transaction, const duckdb::string &schema_name,
duckdb::OnEntryNotFound if_not_found,
duckdb::QueryErrorContext error_context = duckdb::QueryErrorContext()) override;
duckdb::optional_ptr<duckdb::SchemaCatalogEntry> LookupSchema(duckdb::CatalogTransaction transaction,
const duckdb::EntryLookupInfo &schema_lookup,
const duckdb::OnEntryNotFound if_not_found) override;
void ScanSchemas(duckdb::ClientContext &context,
std::function<void(duckdb::SchemaCatalogEntry &)> callback) override;
duckdb::unique_ptr<duckdb::PhysicalOperator>
PlanCreateTableAs(duckdb::ClientContext &context, duckdb::LogicalCreateTable &op,
duckdb::unique_ptr<duckdb::PhysicalOperator> plan) override;
duckdb::unique_ptr<duckdb::PhysicalOperator> PlanInsert(duckdb::ClientContext &context, duckdb::LogicalInsert &op,
duckdb::unique_ptr<duckdb::PhysicalOperator> plan) override;
duckdb::unique_ptr<duckdb::PhysicalOperator> PlanDelete(duckdb::ClientContext &context, duckdb::LogicalDelete &op,
duckdb::unique_ptr<duckdb::PhysicalOperator> plan) override;
duckdb::unique_ptr<duckdb::PhysicalOperator> PlanUpdate(duckdb::ClientContext &context, duckdb::LogicalUpdate &op,
duckdb::unique_ptr<duckdb::PhysicalOperator> plan) override;
duckdb::PhysicalOperator &PlanCreateTableAs(duckdb::ClientContext &context, duckdb::PhysicalPlanGenerator &planner,
duckdb::LogicalCreateTable &op,
duckdb::PhysicalOperator &plan) override;
duckdb::PhysicalOperator &PlanInsert(duckdb::ClientContext &context, duckdb::PhysicalPlanGenerator &planner,
duckdb::LogicalInsert &op,
duckdb::optional_ptr<duckdb::PhysicalOperator> plan) override;
duckdb::PhysicalOperator &PlanDelete(duckdb::ClientContext &context, duckdb::PhysicalPlanGenerator &planner,
duckdb::LogicalDelete &op, duckdb::PhysicalOperator &plan) override;
duckdb::PhysicalOperator &PlanUpdate(duckdb::ClientContext &context, duckdb::PhysicalPlanGenerator &planner,
duckdb::LogicalUpdate &op, duckdb::PhysicalOperator &plan) override;
duckdb::unique_ptr<duckdb::LogicalOperator>
BindCreateIndex(duckdb::Binder &binder, duckdb::CreateStatement &stmt, duckdb::TableCatalogEntry &table,
duckdb::unique_ptr<duckdb::LogicalOperator> plan) override;
Expand Down
4 changes: 2 additions & 2 deletions include/pgduckdb/catalog/pgduckdb_schema.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class PostgresSchema : public duckdb::SchemaCatalogEntry {
duckdb::CreateCollationInfo &info) override;
duckdb::optional_ptr<duckdb::CatalogEntry> CreateType(duckdb::CatalogTransaction transaction,
duckdb::CreateTypeInfo &info) override;
duckdb::optional_ptr<duckdb::CatalogEntry> GetEntry(duckdb::CatalogTransaction transaction,
duckdb::CatalogType type, const duckdb::string &name) override;
duckdb::optional_ptr<duckdb::CatalogEntry> LookupEntry(duckdb::CatalogTransaction transaction,
const duckdb::EntryLookupInfo &lookup_info) override;
void DropEntry(duckdb::ClientContext &context, duckdb::DropInfo &info) override;
void Alter(duckdb::CatalogTransaction transaction, duckdb::AlterInfo &info) override;

Expand Down
35 changes: 20 additions & 15 deletions src/catalog/pgduckdb_catalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,15 @@ PostgresCatalog::CreateSchema(duckdb::CatalogTransaction, duckdb::CreateSchemaIn
}

duckdb::optional_ptr<duckdb::SchemaCatalogEntry>
PostgresCatalog::GetSchema(duckdb::CatalogTransaction catalog_transaction, const duckdb::string &schema_name,
duckdb::OnEntryNotFound, duckdb::QueryErrorContext) {
PostgresCatalog::LookupSchema(duckdb::CatalogTransaction catalog_transaction,
const duckdb::EntryLookupInfo &schema_lookup, duckdb::OnEntryNotFound) {
auto &pg_transaction = catalog_transaction.transaction->Cast<PostgresTransaction>();
auto res = pg_transaction.GetCatalogEntry(duckdb::CatalogType::SCHEMA_ENTRY, schema_name, "");
const auto catalog_type = schema_lookup.GetCatalogType();
if (catalog_type != duckdb::CatalogType::SCHEMA_ENTRY) {
throw duckdb::NotImplementedException("LookupSchema only supports SCHEMA_ENTRY");
}

auto res = pg_transaction.GetCatalogEntry(catalog_type, schema_lookup.GetEntryName(), "");
D_ASSERT(res);
D_ASSERT(res->type == duckdb::CatalogType::SCHEMA_ENTRY);
return (duckdb::SchemaCatalogEntry *)res.get();
Expand All @@ -50,27 +55,27 @@ void
PostgresCatalog::ScanSchemas(duckdb::ClientContext &, std::function<void(duckdb::SchemaCatalogEntry &)>) {
}

duckdb::unique_ptr<duckdb::PhysicalOperator>
PostgresCatalog::PlanCreateTableAs(duckdb::ClientContext &, duckdb::LogicalCreateTable &,
duckdb::unique_ptr<duckdb::PhysicalOperator>) {
duckdb::PhysicalOperator &
PostgresCatalog::PlanCreateTableAs(duckdb::ClientContext &, duckdb::PhysicalPlanGenerator &,
duckdb::LogicalCreateTable &, duckdb::PhysicalOperator &) {
throw duckdb::NotImplementedException("PlanCreateTableAs not supported yet");
}

duckdb::unique_ptr<duckdb::PhysicalOperator>
PostgresCatalog::PlanInsert(duckdb::ClientContext &, duckdb::LogicalInsert &,
duckdb::unique_ptr<duckdb::PhysicalOperator>) {
duckdb::PhysicalOperator &
PostgresCatalog::PlanInsert(duckdb::ClientContext &, duckdb::PhysicalPlanGenerator &, duckdb::LogicalInsert &,
duckdb::optional_ptr<duckdb::PhysicalOperator>) {
throw duckdb::NotImplementedException("PlanInsert not supported yet");
}

duckdb::unique_ptr<duckdb::PhysicalOperator>
PostgresCatalog::PlanDelete(duckdb::ClientContext &, duckdb::LogicalDelete &,
duckdb::unique_ptr<duckdb::PhysicalOperator>) {
duckdb::PhysicalOperator &
PostgresCatalog::PlanDelete(duckdb::ClientContext &, duckdb::PhysicalPlanGenerator &, duckdb::LogicalDelete &,
duckdb::PhysicalOperator &) {
throw duckdb::NotImplementedException("PlanDelete not supported yet");
}

duckdb::unique_ptr<duckdb::PhysicalOperator>
PostgresCatalog::PlanUpdate(duckdb::ClientContext &, duckdb::LogicalUpdate &,
duckdb::unique_ptr<duckdb::PhysicalOperator>) {
duckdb::PhysicalOperator &
PostgresCatalog::PlanUpdate(duckdb::ClientContext &, duckdb::PhysicalPlanGenerator &, duckdb::LogicalUpdate &,
duckdb::PhysicalOperator &) {
throw duckdb::NotImplementedException("PlanUpdate not supported yet");
}

Expand Down
6 changes: 3 additions & 3 deletions src/catalog/pgduckdb_schema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ PostgresSchema::CreateType(duckdb::CatalogTransaction, duckdb::CreateTypeInfo &)
}

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

void
Expand Down
8 changes: 4 additions & 4 deletions test/pycheck/non_superuser_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,26 @@ def test_community_extensions(pg: Postgres):
match="Permission Error: File system LocalFileSystem has been disabled by configuration",
):
cur.sql(
"SELECT * FROM duckdb.raw_query($$ INSTALL duckpgq FROM community; $$)"
"SELECT * FROM duckdb.raw_query($$ INSTALL prql FROM community; $$)"
)

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

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

# And that setting is only changeable by superusers
with pg.cur() as cur:
Expand Down
2 changes: 1 addition & 1 deletion test/regression/expected/execution_error.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ INSERT INTO int_as_varchar SELECT * from (
('abc')
) t(a);
SELECT a::INTEGER FROM int_as_varchar;
ERROR: (PGDuckDB/Duckdb_ExecCustomScan_Cpp) Conversion Error: Could not convert string 'abc' to INT32
ERROR: (PGDuckDB/Duckdb_ExecCustomScan_Cpp) Conversion Error: Could not convert string 'abc' to INT32 when casting from source column a

LINE 1: SELECT (a)::integer AS a FROM pgduckdb.public.int_as_varchar
^
Expand Down
4 changes: 2 additions & 2 deletions test/regression/expected/extensions.out
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ SELECT * FROM duckdb.query($$ SELECT extension_name, loaded, installed, installe
pgduckdb | t | f |
(7 rows)

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

Expand All @@ -131,12 +131,12 @@ SELECT * FROM duckdb.query($$ SELECT extension_name, loaded, installed, installe
----------------+--------+-----------+----------------
aws | t | t | core
core_functions | t | t |
duckpgq | t | t | community
httpfs | t | t |
icu | t | t |
json | t | t |
parquet | t | t |
pgduckdb | t | f |
prql | t | t | community
(8 rows)

-- cleanup
Expand Down
30 changes: 27 additions & 3 deletions test/regression/expected/temporary_tables.out
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,18 @@ EXPLAIN VERBOSE INSERT INTO tc(c) SELECT md5('ta');
┌─────────────┴─────────────┐
│ PROJECTION │
│ ──────────────────── │
│ CAST(3 AS INTEGER) │
│ NULL │
│ #0 │
│ (CAST('a' AS VARCHAR) || │
│ CAST('b' AS VARCHAR)) │
│ (1 + 2) │
│ │
│ ~1 Rows │
└─────────────┬─────────────┘
┌─────────────┴─────────────┐
│ PROJECTION │
│ ──────────────────── │
│ md5 │
│ │
│ ~1 Rows │
Expand All @@ -489,7 +501,7 @@ EXPLAIN VERBOSE INSERT INTO tc(c) SELECT md5('ta');
└───────────────────────────┘


(19 rows)
(31 rows)

INSERT INTO tc(c) SELECT md5('ta');
EXPLAIN VERBOSE INSERT INTO tc(d) SELECT md5('test');
Expand All @@ -505,6 +517,18 @@ EXPLAIN VERBOSE INSERT INTO tc(d) SELECT md5('test');
┌─────────────┴─────────────┐
│ PROJECTION │
│ ──────────────────── │
│ CAST(3 AS INTEGER) │
│ NULL │
│ CAST('pg_duckdb' AS │
│ VARCHAR) │
│ #0 │
│ (1 + 2) │
│ │
│ ~1 Rows │
└─────────────┬─────────────┘
┌─────────────┴─────────────┐
│ PROJECTION │
│ ──────────────────── │
│ md5 │
│ │
│ ~1 Rows │
Expand All @@ -514,7 +538,7 @@ EXPLAIN VERBOSE INSERT INTO tc(d) SELECT md5('test');
└───────────────────────────┘


(19 rows)
(31 rows)

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

LINE 1: INSERT INTO pg_temp.main.ta (a) SELECT generate_series(1, 3) AS generate_series
^
Expand Down
2 changes: 1 addition & 1 deletion test/regression/expected/transaction_errors.out
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CREATE TABLE foo AS SELECT 'bar'::text AS t;
BEGIN; SET duckdb.force_execution = true; SELECT t::integer AS t1 FROM foo; ROLLBACK;
ERROR: (PGDuckDB/Duckdb_ExecCustomScan_Cpp) Conversion Error: Could not convert string 'bar' to INT32
ERROR: (PGDuckDB/Duckdb_ExecCustomScan_Cpp) Conversion Error: Could not convert string 'bar' to INT32 when casting from source column t

LINE 1: SELECT (t)::integer AS t1 FROM pgduckdb.public.foo
^
Expand Down
2 changes: 1 addition & 1 deletion test/regression/sql/extensions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ SELECT last_value FROM duckdb.extensions_table_seq;

SELECT * FROM duckdb.query($$ SELECT extension_name, loaded, installed, installed_from FROM duckdb_extensions() WHERE loaded and extension_name != 'jemalloc' $$);

SELECT duckdb.install_extension('duckpgq', 'community');
SELECT duckdb.install_extension('prql', 'community');

SELECT last_value FROM duckdb.extensions_table_seq;

Expand Down
2 changes: 1 addition & 1 deletion third_party/duckdb
Submodule duckdb updated 2380 files
2 changes: 1 addition & 1 deletion third_party/pg_duckdb_extensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ duckdb_extension_load(json)
duckdb_extension_load(icu)
duckdb_extension_load(httpfs
GIT_URL https://github.com/duckdb/duckdb-httpfs
GIT_TAG cf3584b48ddabdfb58ef69d2649896da2e466405
GIT_TAG 217ec8e04f6ed419c866a6d2496aa15aace4382f
INCLUDE_DIR extension/httpfs/include
)
Loading