Skip to content

Commit

Permalink
Fix temporary tables CTAS test
Browse files Browse the repository at this point in the history
It was [pointed out][1] by @dpxcc that one of our tests was not testing what
it was describing to test. This fixes that. To be clear the
functionality was already working.

[1]: #241 (comment)
  • Loading branch information
JelteF committed Jan 7, 2025
1 parent 0add577 commit b7afa40
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
13 changes: 11 additions & 2 deletions test/regression/expected/temporary_tables.out
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,22 @@ SELECT * FROM t;
(1 row)

-- CTAS from DuckDB table to postgres table
CREATE TEMP TABLE t_heap2(c) USING heap AS SELECT * FROM t_heap;
CREATE TEMP TABLE t_heap2(c) USING heap AS SELECT * FROM t;
SELECT * FROM t_heap2;
c
---
1
(1 row)

-- CTAS from postgres table to postgres table (not actually handled by
-- pg_duckdb, but should still work)
CREATE TEMP TABLE t_heap3(c) USING heap AS SELECT * FROM t_heap;
SELECT * FROM t_heap3;
c
---
1
(1 row)

SELECT duckdb.raw_query($$ SELECT database_name, schema_name, sql FROM duckdb_tables() $$);
NOTICE: result: database_name schema_name sql
VARCHAR VARCHAR VARCHAR
Expand Down Expand Up @@ -472,4 +481,4 @@ SELECT * FROM ta;
3 | 3
(6 rows)

DROP TABLE webpages, t, t_heap, t_heap2, ta, tb, tc, td;
DROP TABLE webpages, t, t_heap, t_heap2, t_heap3, ta, tb, tc, td;
9 changes: 7 additions & 2 deletions test/regression/sql/temporary_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,14 @@ CREATE TEMP TABLE t(b) USING duckdb AS SELECT * FROM t_heap;
SELECT * FROM t;

-- CTAS from DuckDB table to postgres table
CREATE TEMP TABLE t_heap2(c) USING heap AS SELECT * FROM t_heap;
CREATE TEMP TABLE t_heap2(c) USING heap AS SELECT * FROM t;
SELECT * FROM t_heap2;

-- CTAS from postgres table to postgres table (not actually handled by
-- pg_duckdb, but should still work)
CREATE TEMP TABLE t_heap3(c) USING heap AS SELECT * FROM t_heap;
SELECT * FROM t_heap3;

SELECT duckdb.raw_query($$ SELECT database_name, schema_name, sql FROM duckdb_tables() $$);

-- multi-VALUES
Expand Down Expand Up @@ -250,4 +255,4 @@ 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;
DROP TABLE webpages, t, t_heap, t_heap2, t_heap3, ta, tb, tc, td;

0 comments on commit b7afa40

Please sign in to comment.