Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into draft-release-0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JelteF committed Dec 10, 2024
2 parents 521170a + 39a5ffd commit e49d9a5
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 11 deletions.
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,7 @@ Querying data stored in Parquet, CSV, JSON, Iceberg and Delta format can be done
LIMIT 100;
```

Note, for Azure, you will need to first install the Azure extension:
```sql
SELECT duckdb.install_extension('azure');
```

You may then store a secret using the `connection_string` parameter as such:
Note, for Azure, you may store a secret using the `connection_string` parameter as such:
```sql
INSERT INTO duckdb.secrets
(type, connection_string)
Expand Down
2 changes: 2 additions & 0 deletions include/pgduckdb/pgduckdb_guc.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ extern char *duckdb_maximum_memory;
extern char *duckdb_disabled_filesystems;
extern bool duckdb_enable_external_access;
extern bool duckdb_allow_unsigned_extensions;
extern bool duckdb_autoinstall_known_extensions;
extern bool duckdb_autoload_known_extensions;
extern int duckdb_max_threads_per_postgres_scan;
extern char *duckdb_motherduck_postgres_database;
extern int duckdb_motherduck_enabled;
Expand Down
10 changes: 10 additions & 0 deletions src/pgduckdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ char *duckdb_maximum_memory = strdup("4GB");
char *duckdb_disabled_filesystems = strdup("LocalFileSystem");
bool duckdb_enable_external_access = true;
bool duckdb_allow_unsigned_extensions = false;
bool duckdb_autoinstall_known_extensions = true;
bool duckdb_autoload_known_extensions = true;

extern "C" {
PG_MODULE_MAGIC;
Expand Down Expand Up @@ -131,6 +133,14 @@ DuckdbInitGUC(void) {
"Allow DuckDB to load extensions with invalid or missing signatures",
&duckdb_allow_unsigned_extensions, PGC_SUSET);

DefineCustomVariable("duckdb.autoinstall_known_extensions",
"Whether known extensions are allowed to be automatically installed when a DuckDB query depends on them",
&duckdb_autoinstall_known_extensions, PGC_SUSET);

DefineCustomVariable("duckdb.autoload_known_extensions",
"Whether known extensions are allowed to be automatically loaded when a DuckDB query depends on them",
&duckdb_autoload_known_extensions, PGC_SUSET);

DefineCustomVariable("duckdb.max_memory", "The maximum memory DuckDB can use (e.g., 1GB)", &duckdb_maximum_memory,
PGC_SUSET);
DefineCustomVariable("duckdb.memory_limit",
Expand Down
2 changes: 2 additions & 0 deletions src/pgduckdb_duckdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ DuckDBManager::Initialize() {
config.replacement_scans.emplace_back(pgduckdb::PostgresReplacementScan);
SET_DUCKDB_OPTION(allow_unsigned_extensions);
SET_DUCKDB_OPTION(enable_external_access);
SET_DUCKDB_OPTION(autoinstall_known_extensions);
SET_DUCKDB_OPTION(autoload_known_extensions);

if (duckdb_maximum_memory != NULL) {
config.options.maximum_memory = duckdb::DBConfig::ParseMemoryLimit(duckdb_maximum_memory);
Expand Down
92 changes: 88 additions & 4 deletions test/regression/expected/temporary_tables.out
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,6 @@ SELECT * FROM ta;
3 | 1
(4 rows)

INSERT INTO ta (a) SELECT generate_series(1, 3); -- no support
ERROR: (PGDuckDB/Duckdb_ExecCustomScan) Conversion Error: Unimplemented type for cast (BIGINT[] -> INTEGER)
LINE 1: INSERT INTO pg_temp.main.ta (a) SELECT generate_series(1, 3) AS generate_serie...
^
TRUNCATE TABLE tb;
INSERT INTO tb (a) SELECT 789;
INSERT INTO tb (b) SELECT 789;
Expand Down Expand Up @@ -388,4 +384,92 @@ SELECT a FROM td;
1
(1 row)

-- Single Row Function
TRUNCATE TABLE td;
INSERT INTO td (ts) SELECT now();
SELECT count(*) FROM td;
count
-------
1
(1 row)

TRUNCATE TABLE tc;
EXPLAIN VERBOSE INSERT INTO tc(c) SELECT md5('ta');
QUERY PLAN
--------------------------------------------------------------
Custom Scan (DuckDBScan) (cost=0.00..0.00 rows=0 width=0)
Output: duckdb_scan.explain_key, duckdb_scan.explain_value
DuckDB Execution Plan:

┌───────────────────────────┐
│ INSERT │
└─────────────┬─────────────┘
┌─────────────┴─────────────┐
│ PROJECTION │
│ ──────────────────── │
│'fec8f2a3f2e808ccb17c4d278b│
│ 4fa469' │
│ │
│ ~1 Rows │
└─────────────┬─────────────┘
┌─────────────┴─────────────┐
│ DUMMY_SCAN │
└───────────────────────────┘


(20 rows)

INSERT INTO tc(c) SELECT md5('ta');
EXPLAIN VERBOSE INSERT INTO tc(d) SELECT md5('test');
QUERY PLAN
--------------------------------------------------------------
Custom Scan (DuckDBScan) (cost=0.00..0.00 rows=0 width=0)
Output: duckdb_scan.explain_key, duckdb_scan.explain_value
DuckDB Execution Plan:

┌───────────────────────────┐
│ INSERT │
└─────────────┬─────────────┘
┌─────────────┴─────────────┐
│ PROJECTION │
│ ──────────────────── │
│'098f6bcd4621d373cade4e8326│
│ 27b4f6' │
│ │
│ ~1 Rows │
└─────────────┬─────────────┘
┌─────────────┴─────────────┐
│ DUMMY_SCAN │
└───────────────────────────┘


(20 rows)

INSERT INTO tc(d) SELECT md5('test');
SELECT * FROM tc;
a | b | c | d | e
---+---+----------------------------------+----------------------------------+---
3 | | fec8f2a3f2e808ccb17c4d278b4fa469 | ab | 3
3 | | pg_duckdb | 098f6bcd4621d373cade4e832627b4f6 | 3
(2 rows)

-- 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) Conversion Error: Unimplemented type for cast (BIGINT[] -> INTEGER)
LINE 1: INSERT INTO pg_temp.main.ta (a) SELECT generate_series(1, 3) AS generate_serie...
^
INSERT INTO ta (a) SELECT * FROM generate_series(1, 3); -- OK
INSERT INTO ta (b) SELECT * FROM generate_series(1, 3); -- OK
SELECT * FROM ta;
a | b
---+---
1 |
2 |
3 |
3 | 1
3 | 2
3 | 3
(6 rows)

DROP TABLE webpages, t, t_heap, t_heap2, ta, tb, tc, td;
21 changes: 20 additions & 1 deletion test/regression/sql/temporary_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ INSERT INTO ta (b) SELECT 789;
INSERT INTO ta (a) SELECT * FROM t_heap;
INSERT INTO ta (b) SELECT * FROM t_heap;
SELECT * FROM ta;
INSERT INTO ta (a) SELECT generate_series(1, 3); -- no support

TRUNCATE TABLE tb;
INSERT INTO tb (a) SELECT 789;
Expand Down Expand Up @@ -231,4 +230,24 @@ CREATE TEMP TABLE td (a int, ts timestamp default now()) USING duckdb;
INSERT INTO td (a) SELECT 1;
SELECT a FROM td;

-- Single Row Function
TRUNCATE TABLE td;
INSERT INTO td (ts) SELECT now();
SELECT count(*) FROM td;

TRUNCATE TABLE tc;
EXPLAIN VERBOSE INSERT INTO tc(c) SELECT md5('ta');
INSERT INTO tc(c) SELECT md5('ta');
EXPLAIN VERBOSE INSERT INTO tc(d) SELECT md5('test');
INSERT INTO tc(d) SELECT md5('test');
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)"

INSERT INTO ta (a) SELECT * FROM generate_series(1, 3); -- OK
INSERT INTO ta (b) SELECT * FROM generate_series(1, 3); -- OK
SELECT * FROM ta;

DROP TABLE webpages, t, t_heap, t_heap2, ta, tb, tc, td;

0 comments on commit e49d9a5

Please sign in to comment.