-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #261 from duckdb/copyfromdatabase
Add copy from database test - plus throw an error with unsupported CAST_FROM_VARCHAR composite column types
- Loading branch information
Showing
7 changed files
with
90 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# name: test/sql/storage/attach_copy_from_database.test | ||
# description: Test copy from database | ||
# group: [storage] | ||
|
||
require postgres_scanner | ||
|
||
require-env POSTGRES_TEST_DATABASE_AVAILABLE | ||
|
||
statement ok | ||
PRAGMA enable_verification | ||
|
||
statement ok | ||
ATTACH 'dbname=postgresscanner' AS s1 (TYPE POSTGRES) | ||
|
||
statement ok | ||
DROP SCHEMA IF EXISTS s1.copy_schema CASCADE | ||
|
||
statement ok | ||
CREATE SCHEMA s1.copy_schema | ||
|
||
statement ok | ||
USE s1.copy_schema | ||
|
||
foreach table_name pg_numtypes pg_bytetypes pg_datetypes | ||
|
||
statement ok | ||
CREATE TABLE ${table_name} AS FROM public.${table_name} | ||
|
||
endloop | ||
|
||
statement ok | ||
USE memory | ||
|
||
statement ok | ||
DETACH s1 | ||
|
||
statement ok | ||
ATTACH 'dbname=postgresscanner' AS s1 (TYPE POSTGRES, SCHEMA 'copy_schema') | ||
|
||
statement ok | ||
USE s1.copy_schema | ||
|
||
statement ok | ||
create table big_tbl as from range(100000) t(id) | ||
|
||
statement ok | ||
create index i_index on big_tbl(id) | ||
|
||
statement ok | ||
create view my_view as select min(id) from copy_schema.big_tbl | ||
|
||
statement ok | ||
ATTACH '__TEST_DIR__/copy_database.db' AS new_db; | ||
|
||
statement ok | ||
COPY FROM DATABASE s1 TO new_db | ||
|
||
foreach table_name pg_numtypes pg_bytetypes pg_datetypes big_tbl my_view | ||
|
||
query I | ||
SELECT COUNT(*) FROM (FROM new_db.copy_schema.${table_name} EXCEPT FROM ${table_name}) | ||
---- | ||
0 | ||
|
||
endloop |