should be it
This commit is contained in:
9
external/duckdb/test/sql/export/empty_export.test
vendored
Normal file
9
external/duckdb/test/sql/export/empty_export.test
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
# name: test/sql/export/empty_export.test
|
||||
# description: Export an empty database
|
||||
# group: [export]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
EXPORT DATABASE '__TEST_DIR__/empty_export' (FORMAT CSV)
|
||||
40
external/duckdb/test/sql/export/export_compression_level.test
vendored
Normal file
40
external/duckdb/test/sql/export/export_compression_level.test
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
# name: test/sql/export/export_compression_level.test
|
||||
# description: Test export with parameters that are only supported on export, not on import
|
||||
# group: [export]
|
||||
|
||||
require parquet
|
||||
|
||||
statement ok
|
||||
CREATE TABLE test_table (
|
||||
id INTEGER,
|
||||
name VARCHAR,
|
||||
value DOUBLE,
|
||||
created_at TIMESTAMP
|
||||
);
|
||||
|
||||
statement ok
|
||||
INSERT INTO test_table VALUES
|
||||
(1, 'Alice', 123.45, '2024-01-01 10:00:00'),
|
||||
(2, 'Bob', 67.89, '2024-01-02 11:30:00'),
|
||||
(3, 'Charlie', 234.56, '2024-01-03 14:15:00');
|
||||
|
||||
statement ok
|
||||
EXPORT DATABASE '__TEST_DIR__/my_duckdb' (
|
||||
FORMAT parquet,
|
||||
COMPRESSION zstd,
|
||||
COMPRESSION_LEVEL 12,
|
||||
ROW_GROUP_SIZE 100_000
|
||||
);
|
||||
|
||||
statement ok
|
||||
DROP TABLE test_table;
|
||||
|
||||
statement ok
|
||||
IMPORT DATABASE '__TEST_DIR__/my_duckdb';
|
||||
|
||||
query IIII
|
||||
FROM test_table;
|
||||
----
|
||||
1 Alice 123.45 2024-01-01 10:00:00
|
||||
2 Bob 67.89 2024-01-02 11:30:00
|
||||
3 Charlie 234.56 2024-01-03 14:15:00
|
||||
290
external/duckdb/test/sql/export/export_database.test
vendored
Normal file
290
external/duckdb/test/sql/export/export_database.test
vendored
Normal file
@@ -0,0 +1,290 @@
|
||||
# name: test/sql/export/export_database.test
|
||||
# description: Test export database
|
||||
# group: [export]
|
||||
|
||||
statement ok
|
||||
SET default_null_order='nulls_first';
|
||||
|
||||
# create a bunch of tables with data and views
|
||||
|
||||
statement ok
|
||||
BEGIN TRANSACTION
|
||||
|
||||
statement ok
|
||||
CREATE TABLE integers(i INTEGER, j INTEGER, CHECK(i+j<10))
|
||||
|
||||
statement ok
|
||||
CREATE TABLE strings(v VARCHAR, d DATE, PRIMARY KEY(d))
|
||||
|
||||
statement ok
|
||||
CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy');
|
||||
|
||||
statement ok
|
||||
CREATE TABLE enums(current_mood mood)
|
||||
|
||||
statement ok
|
||||
INSERT INTO integers VALUES (1, 3), (4, 2), (NULL, 1)
|
||||
|
||||
statement ok
|
||||
INSERT INTO strings VALUES ('NULL', DATE '1992-01-01'), (NULL, DATE '1993-01-01');
|
||||
|
||||
statement ok
|
||||
INSERT INTO enums VALUES ('sad'),('ok'),('sad'),('happy')
|
||||
|
||||
statement ok
|
||||
CREATE TABLE "table.with-symbols"(i INTEGER)
|
||||
|
||||
statement ok
|
||||
INSERT INTO "table.with-symbols" VALUES (1), (4), (NULL)
|
||||
|
||||
statement ok
|
||||
CREATE TABLE "table ""." ( "col ""." TEXT)
|
||||
|
||||
statement ok
|
||||
INSERT INTO "table ""." ("col "".") VALUES ('quote_escaped_quote_''')
|
||||
|
||||
statement ok
|
||||
CREATE TABLE "SAME_NAME"(i INTEGER, j INTEGER);
|
||||
|
||||
statement error
|
||||
CREATE TABLE "same_name"(i INTEGER, j INTEGER);
|
||||
----
|
||||
|
||||
statement ok
|
||||
INSERT INTO "SAME_NAME" VALUES (1, 1), (2, 2)
|
||||
|
||||
statement ok
|
||||
CREATE VIEW v1 AS SELECT * FROM integers WHERE i>3; --
|
||||
CREATE VIEW v2 AS SELECT * FROM integers WHERE i < 3;
|
||||
CREATE VIEW "view.with-symbols" AS SELECT * FROM "table.with-symbols" WHERE i < 3;
|
||||
CREATE VIEW "view ""." AS SELECT * FROM "table.with-symbols" WHERE i < 3;
|
||||
|
||||
statement ok
|
||||
CREATE VIEW v3 AS SELECT * FROM integers WHERE i IS NULL --
|
||||
|
||||
statement ok
|
||||
CREATE SEQUENCE seq
|
||||
|
||||
query I
|
||||
SELECT nextval('seq')
|
||||
----
|
||||
1
|
||||
|
||||
query II
|
||||
SELECT * FROM v2 ORDER BY 1
|
||||
----
|
||||
1 3
|
||||
|
||||
# check data
|
||||
query II
|
||||
SELECT * FROM integers ORDER BY 1
|
||||
----
|
||||
NULL 1
|
||||
1 3
|
||||
4 2
|
||||
|
||||
query I
|
||||
SELECT * FROM enums ORDER BY 1
|
||||
----
|
||||
sad
|
||||
sad
|
||||
ok
|
||||
happy
|
||||
|
||||
query II
|
||||
SELECT * FROM strings ORDER BY 1
|
||||
----
|
||||
NULL 1993-01-01
|
||||
NULL 1992-01-01
|
||||
|
||||
query II
|
||||
SELECT * FROM v1 ORDER BY 1
|
||||
----
|
||||
4 2
|
||||
|
||||
query II
|
||||
SELECT * FROM v2 ORDER BY 1
|
||||
----
|
||||
1 3
|
||||
|
||||
query II
|
||||
SELECT * FROM v3 ORDER BY 1
|
||||
----
|
||||
NULL 1
|
||||
|
||||
query I
|
||||
SELECT * FROM "table.with-symbols" ORDER BY 1
|
||||
----
|
||||
NULL
|
||||
1
|
||||
4
|
||||
|
||||
query I
|
||||
SELECT * FROM "view.with-symbols" ORDER BY 1
|
||||
----
|
||||
1
|
||||
|
||||
|
||||
query TT
|
||||
SELECT "table ""."."col "".", "col ""." FROM "table "".";
|
||||
----
|
||||
quote_escaped_quote_' quote_escaped_quote_'
|
||||
|
||||
query I
|
||||
SELECT * FROM "view ""." ORDER BY 1
|
||||
----
|
||||
1
|
||||
|
||||
query II
|
||||
SELECT * FROM "SAME_NAME" ORDER BY i
|
||||
----
|
||||
1 1
|
||||
2 2
|
||||
|
||||
statement ok
|
||||
CREATE SCHEMA s1;
|
||||
CREATE SCHEMA s2;
|
||||
|
||||
|
||||
statement ok
|
||||
CREATE TABLE table01(i INTEGER, j INTEGER);
|
||||
CREATE TABLE s1.table01(i INTEGER, j INTEGER);
|
||||
CREATE TABLE s2.table01(i INTEGER, j INTEGER);
|
||||
|
||||
statement ok
|
||||
INSERT INTO table01 VALUES (1, 1), (2, 2);
|
||||
INSERT INTO s1.table01 VALUES (3, 3), (4, 4);
|
||||
INSERT INTO s2.table01 VALUES (5, 5), (6, 6);
|
||||
|
||||
|
||||
query II
|
||||
SELECT * FROM table01 ORDER BY i;
|
||||
----
|
||||
1 1
|
||||
2 2
|
||||
|
||||
query II
|
||||
SELECT * FROM s1.table01 ORDER BY i;
|
||||
----
|
||||
3 3
|
||||
4 4
|
||||
|
||||
query II
|
||||
SELECT * FROM s2.table01 ORDER BY i;
|
||||
----
|
||||
5 5
|
||||
6 6
|
||||
|
||||
statement ok
|
||||
PRAGMA verify_serializer
|
||||
|
||||
# now export the db
|
||||
statement ok
|
||||
EXPORT DATABASE '__TEST_DIR__/export_test' (FORMAT CSV)
|
||||
|
||||
statement ok
|
||||
PRAGMA disable_verification
|
||||
|
||||
statement ok
|
||||
ROLLBACK
|
||||
|
||||
statement ok
|
||||
IMPORT DATABASE '__TEST_DIR__/export_test'
|
||||
|
||||
# check data
|
||||
query II
|
||||
SELECT * FROM integers ORDER BY 1
|
||||
----
|
||||
NULL 1
|
||||
1 3
|
||||
4 2
|
||||
|
||||
query II
|
||||
SELECT * FROM strings ORDER BY 1
|
||||
----
|
||||
NULL 1993-01-01
|
||||
NULL 1992-01-01
|
||||
|
||||
query I
|
||||
SELECT * FROM enums ORDER BY 1
|
||||
----
|
||||
sad
|
||||
sad
|
||||
ok
|
||||
happy
|
||||
|
||||
query II
|
||||
SELECT * FROM v1 ORDER BY 1
|
||||
----
|
||||
4 2
|
||||
|
||||
query II
|
||||
SELECT * FROM v2 ORDER BY 1
|
||||
----
|
||||
1 3
|
||||
|
||||
query II
|
||||
SELECT * FROM v3 ORDER BY 1
|
||||
----
|
||||
NULL 1
|
||||
|
||||
# sequence is not reset to base value, but keeps the value it had
|
||||
query I
|
||||
SELECT nextval('seq')
|
||||
----
|
||||
2
|
||||
|
||||
query I
|
||||
SELECT * FROM "table.with-symbols" ORDER BY 1
|
||||
----
|
||||
NULL
|
||||
1
|
||||
4
|
||||
|
||||
query I
|
||||
SELECT * FROM "view.with-symbols" ORDER BY 1
|
||||
----
|
||||
1
|
||||
|
||||
query TT
|
||||
SELECT "table ""."."col "".", "col ""." FROM "table "".";
|
||||
----
|
||||
quote_escaped_quote_' quote_escaped_quote_'
|
||||
|
||||
query I
|
||||
SELECT * FROM "view ""." ORDER BY 1
|
||||
----
|
||||
1
|
||||
|
||||
query II
|
||||
SELECT * FROM "SAME_NAME" ORDER BY i
|
||||
----
|
||||
1 1
|
||||
2 2
|
||||
|
||||
query II
|
||||
SELECT * FROM table01 ORDER BY i;
|
||||
----
|
||||
1 1
|
||||
2 2
|
||||
|
||||
query II
|
||||
SELECT * FROM s1.table01 ORDER BY i;
|
||||
----
|
||||
3 3
|
||||
4 4
|
||||
|
||||
query II
|
||||
SELECT * FROM s2.table01 ORDER BY i;
|
||||
----
|
||||
5 5
|
||||
6 6
|
||||
|
||||
# verify that constraints are still there
|
||||
statement error
|
||||
INSERT INTO integers VALUES (5, 6)
|
||||
----
|
||||
|
||||
statement error
|
||||
INSERT INTO strings VALUES(NULL, NULL)
|
||||
----
|
||||
29
external/duckdb/test/sql/export/export_external_access.test
vendored
Normal file
29
external/duckdb/test/sql/export/export_external_access.test
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
# name: test/sql/export/export_external_access.test
|
||||
# description: Test export database
|
||||
# group: [export]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
BEGIN TRANSACTION
|
||||
|
||||
statement ok
|
||||
CREATE TABLE integers(i INTEGER, j INTEGER, CHECK(i+j<10))
|
||||
|
||||
statement ok
|
||||
EXPORT DATABASE '__TEST_DIR__/export_permissions_test' (FORMAT CSV)
|
||||
|
||||
statement ok
|
||||
ROLLBACK
|
||||
|
||||
statement ok
|
||||
SET enable_external_access=false
|
||||
|
||||
statement error
|
||||
IMPORT DATABASE '__TEST_DIR__/export_permissions_test'
|
||||
----
|
||||
|
||||
statement error
|
||||
EXPORT DATABASE '__TEST_DIR__/export_permissions_test2' (FORMAT CSV)
|
||||
----
|
||||
32
external/duckdb/test/sql/export/export_functions.test
vendored
Normal file
32
external/duckdb/test/sql/export/export_functions.test
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
# name: test/sql/export/export_functions.test
|
||||
# description: Test export functions
|
||||
# group: [export]
|
||||
|
||||
require icu
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
BEGIN TRANSACTION
|
||||
|
||||
statement ok
|
||||
CREATE TABLE tbl(
|
||||
d DATE DEFAULT CURRENT_DATE,
|
||||
t TIME WITH TIME ZONE DEFAULT CURRENT_TIME,
|
||||
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
cur_user VARCHAR DEFAULT CURRENT_USER,
|
||||
"user" VARCHAR DEFAULT USER,
|
||||
sess_user VARCHAR DEFAULT SESSION_USER,
|
||||
cur_catalog VARCHAR DEFAULT CURRENT_CATALOG,
|
||||
cur_schema VARCHAR DEFAULT CURRENT_SCHEMA
|
||||
);
|
||||
|
||||
statement ok
|
||||
EXPORT DATABASE '__TEST_DIR__/export_special_functions' (FORMAT CSV)
|
||||
|
||||
statement ok
|
||||
ROLLBACK
|
||||
|
||||
statement ok
|
||||
IMPORT DATABASE '__TEST_DIR__/export_special_functions'
|
||||
71
external/duckdb/test/sql/export/export_generated_columns.test
vendored
Normal file
71
external/duckdb/test/sql/export/export_generated_columns.test
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
# name: test/sql/export/export_generated_columns.test
|
||||
# description: Test export of generated columns
|
||||
# group: [export]
|
||||
|
||||
require skip_reload
|
||||
|
||||
statement ok
|
||||
pragma storage_compatibility_version='v1.1.0'
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
BEGIN TRANSACTION
|
||||
|
||||
# Create a macro that the generated column uses
|
||||
statement ok
|
||||
CREATE MACRO my_macro(b) AS b + 5;
|
||||
|
||||
statement ok
|
||||
CREATE TABLE tbl (
|
||||
x INTEGER,
|
||||
gen_x AS (my_macro(x))
|
||||
);
|
||||
|
||||
statement ok
|
||||
INSERT INTO tbl VALUES(5);
|
||||
|
||||
# Generated columns can not be inserted into directly
|
||||
statement error
|
||||
INSERT INTO tbl VALUES(2,3)
|
||||
----
|
||||
<REGEX>:.*Binder Error: table tbl has 1 columns.*
|
||||
|
||||
# 'x' can not be removed, as 'gen_x' depends on it
|
||||
statement error
|
||||
ALTER TABLE tbl DROP COLUMN x;
|
||||
----
|
||||
<REGEX>:.*Catalog Error.*column is a dependency.*
|
||||
|
||||
statement ok
|
||||
EXPORT DATABASE '__TEST_DIR__/export_generated_columns' (FORMAT CSV);
|
||||
|
||||
statement ok
|
||||
ROLLBACK
|
||||
|
||||
statement ok
|
||||
IMPORT DATABASE '__TEST_DIR__/export_generated_columns'
|
||||
|
||||
# We can get the data we exported just now
|
||||
query II
|
||||
SELECT * FROM tbl
|
||||
----
|
||||
5 10
|
||||
|
||||
# Generated columns can not be inserted into directly
|
||||
statement error
|
||||
INSERT INTO tbl VALUES(2,3)
|
||||
----
|
||||
<REGEX>:.*Binder Error: table tbl has 1 columns.*
|
||||
|
||||
statement error
|
||||
drop macro my_macro;
|
||||
----
|
||||
<REGEX>:.*Dependency Error.*Cannot drop entry.*
|
||||
|
||||
# 'x' can not be removed, as 'gen_x' depends on it
|
||||
statement error
|
||||
ALTER TABLE tbl DROP COLUMN x;
|
||||
----
|
||||
<REGEX>:.*Catalog Error.*column is a dependency.*
|
||||
26
external/duckdb/test/sql/export/export_hive_path.test
vendored
Normal file
26
external/duckdb/test/sql/export/export_hive_path.test
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
# name: test/sql/export/export_hive_path.test
|
||||
# description: Test export database to hive path
|
||||
# group: [export]
|
||||
|
||||
statement ok
|
||||
BEGIN
|
||||
|
||||
statement ok
|
||||
CREATE TABLE integers(i INTEGER);
|
||||
|
||||
statement ok
|
||||
INSERT INTO integers VALUES (42);
|
||||
|
||||
statement ok
|
||||
EXPORT DATABASE '__TEST_DIR__/d=1992-01-01'
|
||||
|
||||
statement ok
|
||||
ROLLBACK
|
||||
|
||||
statement ok
|
||||
IMPORT DATABASE '__TEST_DIR__/d=1992-01-01'
|
||||
|
||||
query I
|
||||
FROM integers
|
||||
----
|
||||
42
|
||||
49
external/duckdb/test/sql/export/export_indexes.test
vendored
Normal file
49
external/duckdb/test/sql/export/export_indexes.test
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
# name: test/sql/export/export_indexes.test
|
||||
# description: Test export of macro's
|
||||
# group: [export]
|
||||
|
||||
statement ok
|
||||
BEGIN TRANSACTION
|
||||
|
||||
# scalar macro
|
||||
statement ok
|
||||
CREATE MACRO elaborate_macro(x, y := 7) AS x + y;
|
||||
|
||||
statement ok
|
||||
CREATE TABLE tbl (x integer, y varchar);
|
||||
|
||||
# Index that depends on the 'elaborate_macro' macro function
|
||||
statement ok
|
||||
CREATE UNIQUE INDEX my_index on tbl (elaborate_macro(tbl.x));
|
||||
|
||||
query I
|
||||
select index_name from duckdb_indexes();
|
||||
----
|
||||
my_index
|
||||
|
||||
statement ok
|
||||
EXPORT DATABASE '__TEST_DIR__/export_macros' (FORMAT CSV);
|
||||
|
||||
statement ok
|
||||
ROLLBACK
|
||||
|
||||
statement ok
|
||||
IMPORT DATABASE '__TEST_DIR__/export_macros'
|
||||
|
||||
query I
|
||||
select index_name from duckdb_indexes();
|
||||
----
|
||||
my_index
|
||||
|
||||
query T
|
||||
SELECT elaborate_macro(28, y := 5)
|
||||
----
|
||||
33
|
||||
|
||||
statement ok
|
||||
insert into tbl VALUES (10, 'hello');
|
||||
|
||||
statement error
|
||||
insert into tbl VALUES (10, 'world');
|
||||
----
|
||||
Constraint Error: Duplicate key "(x + 7): 17" violates unique constraint.
|
||||
51
external/duckdb/test/sql/export/export_macros.test
vendored
Normal file
51
external/duckdb/test/sql/export/export_macros.test
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
# name: test/sql/export/export_macros.test
|
||||
# description: Test export of macro's
|
||||
# group: [export]
|
||||
|
||||
statement ok
|
||||
set enable_macro_dependencies=true;
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
BEGIN TRANSACTION
|
||||
|
||||
statement ok
|
||||
CREATE SCHEMA my_schema
|
||||
|
||||
# table macro
|
||||
statement ok
|
||||
CREATE MACRO my_schema.my_range(x, y := 7) AS TABLE SELECT range + x i FROM range(y)
|
||||
|
||||
# scalar macro with the table macro nested in there
|
||||
statement ok
|
||||
CREATE MACRO my_schema.elaborate_macro(x, y := 7) AS x + y + (SELECT max(i) FROM my_schema.my_range(0, y := 10))
|
||||
|
||||
# table macro with nested table macro
|
||||
statement ok
|
||||
CREATE MACRO my_schema.my_other_range(x) AS TABLE SELECT * FROM my_schema.my_range(x, y := 3)
|
||||
|
||||
statement ok
|
||||
EXPORT DATABASE '__TEST_DIR__/export_macros' (FORMAT CSV);
|
||||
|
||||
statement ok
|
||||
ROLLBACK
|
||||
|
||||
statement ok
|
||||
IMPORT DATABASE '__TEST_DIR__/export_macros'
|
||||
|
||||
query T
|
||||
SELECT my_schema.elaborate_macro(28, y := 5)
|
||||
----
|
||||
42
|
||||
|
||||
query T
|
||||
SELECT max(i) FROM my_schema.my_range(33, y := 10)
|
||||
----
|
||||
42
|
||||
|
||||
query T
|
||||
SELECT max(i) FROM my_schema.my_other_range(40)
|
||||
----
|
||||
42
|
||||
24
external/duckdb/test/sql/export/export_quoted_enum.test
vendored
Normal file
24
external/duckdb/test/sql/export/export_quoted_enum.test
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# name: test/sql/export/export_quoted_enum.test
|
||||
# description: Test export of enum with reserved keyword name
|
||||
# group: [export]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
BEGIN TRANSACTION
|
||||
|
||||
statement ok
|
||||
CREATE TYPE "group" AS ENUM ( 'one', 'two');
|
||||
|
||||
statement ok
|
||||
CREATE TABLE table1(col1 "group");
|
||||
|
||||
statement ok
|
||||
EXPORT DATABASE '__TEST_DIR__/export_enum' (FORMAT CSV);
|
||||
|
||||
statement ok
|
||||
ROLLBACK
|
||||
|
||||
statement ok
|
||||
IMPORT DATABASE '__TEST_DIR__/export_enum'
|
||||
60
external/duckdb/test/sql/export/export_quoted_structs.test
vendored
Normal file
60
external/duckdb/test/sql/export/export_quoted_structs.test
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
# name: test/sql/export/export_quoted_structs.test
|
||||
# description: Test export database
|
||||
# group: [export]
|
||||
|
||||
# create a bunch of tables with data and views
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
BEGIN TRANSACTION
|
||||
|
||||
# 'end' is a keyword, this has to be quoted
|
||||
statement ok
|
||||
create table a (s STRUCT("end" VARCHAR));
|
||||
|
||||
statement ok
|
||||
insert into a values ({"end":'hello'});
|
||||
|
||||
query I
|
||||
select * from a
|
||||
----
|
||||
{'end': hello}
|
||||
|
||||
## -- We don't support exporting user defined types yet -- ##
|
||||
#statement ok
|
||||
#create type "table" as varchar;
|
||||
|
||||
## The type of the struct field can also be a user-defined type, which might need quotes
|
||||
#statement ok
|
||||
#create table b (s STRUCT(f1 "table"));
|
||||
|
||||
#statement ok
|
||||
#insert into b values ({'a':'hello'});
|
||||
|
||||
#query I
|
||||
#select * from b;
|
||||
#----
|
||||
#{'f1': hello}
|
||||
|
||||
# now export the db
|
||||
statement ok
|
||||
EXPORT DATABASE '__TEST_DIR__/export_test' (FORMAT CSV)
|
||||
|
||||
statement ok
|
||||
ROLLBACK
|
||||
|
||||
statement ok
|
||||
IMPORT DATABASE '__TEST_DIR__/export_test'
|
||||
|
||||
# Verify that the import was successful
|
||||
query I
|
||||
select * from a
|
||||
----
|
||||
{'end': hello}
|
||||
|
||||
#query I
|
||||
#select * from b;
|
||||
#----
|
||||
#{'f1': hello}
|
||||
48
external/duckdb/test/sql/export/export_quoted_union.test
vendored
Normal file
48
external/duckdb/test/sql/export/export_quoted_union.test
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
# name: test/sql/export/export_quoted_union.test
|
||||
# description: Test export database
|
||||
# group: [export]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
BEGIN TRANSACTION
|
||||
|
||||
statement ok
|
||||
create table a (
|
||||
u UNION(
|
||||
"member name 1" VARCHAR,
|
||||
"member name 2" BOOL
|
||||
)
|
||||
);
|
||||
|
||||
statement ok
|
||||
insert into a values (
|
||||
union_value("member name 1" := 'hello')
|
||||
);
|
||||
|
||||
query I
|
||||
select * from a
|
||||
----
|
||||
hello
|
||||
|
||||
# now export the db
|
||||
statement ok
|
||||
EXPORT DATABASE '__TEST_DIR__/export_test' (FORMAT CSV)
|
||||
|
||||
statement ok
|
||||
ROLLBACK
|
||||
|
||||
statement ok
|
||||
IMPORT DATABASE '__TEST_DIR__/export_test'
|
||||
|
||||
# Verify that the import was successful
|
||||
query I
|
||||
select * from a
|
||||
----
|
||||
hello
|
||||
|
||||
query I
|
||||
select union_tag(COLUMNS(*)) from a;
|
||||
----
|
||||
member name 1
|
||||
61
external/duckdb/test/sql/export/export_types.test
vendored
Normal file
61
external/duckdb/test/sql/export/export_types.test
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
# name: test/sql/export/export_types.test
|
||||
# description: Test export of macro's
|
||||
# group: [export]
|
||||
|
||||
# Because of ordering issues in EXPORT DATABASE we can't IMPORT this database
|
||||
mode skip
|
||||
|
||||
statement ok
|
||||
BEGIN TRANSACTION
|
||||
|
||||
# Populate the database
|
||||
|
||||
# Create a type alias
|
||||
statement ok
|
||||
CREATE TYPE mood AS ENUM ('happy', 'sad', 'curious');
|
||||
|
||||
# Create an alias on 'mood', creating a dependency on 'mood'
|
||||
statement ok
|
||||
CREATE TYPE doom as mood;
|
||||
|
||||
# Create tables that use mood and doom
|
||||
statement ok
|
||||
create table tbl1 (a mood, b doom);
|
||||
|
||||
statement ok
|
||||
create table tbl2 (my_struct STRUCT(a mood, b doom));
|
||||
|
||||
# Create an alias on STRUCT containing mood and doom
|
||||
statement ok
|
||||
CREATE TYPE doom_mood as STRUCT(a mood, b doom);
|
||||
|
||||
# Create an alias on LIST of mood
|
||||
statement ok
|
||||
CREATE TYPE mood_list as mood[];
|
||||
|
||||
# Create an alias on a UNION containing mood and doom
|
||||
statement ok
|
||||
CREATE TYPE my_union as UNION(a doom, b mood);
|
||||
|
||||
# Create an alias on a MAP with mood as key and doom as value
|
||||
statement ok
|
||||
CREATE TYPE mood_map as MAP(doom, mood);
|
||||
|
||||
# Create an alias on a regular type, VARCHAR in this case
|
||||
statement ok
|
||||
CREATE TYPE my_special_type as VARCHAR;
|
||||
|
||||
# Create a table containing the doom_mood type
|
||||
statement ok
|
||||
CREATE TABLE tbl3 (my_struct doom_mood);
|
||||
|
||||
statement ok
|
||||
EXPORT DATABASE '__TEST_DIR__/export_types' (FORMAT CSV);
|
||||
|
||||
statement ok
|
||||
ROLLBACK
|
||||
|
||||
statement ok
|
||||
IMPORT DATABASE '__TEST_DIR__/export_types'
|
||||
|
||||
# Verify that the database was imported properly
|
||||
29
external/duckdb/test/sql/export/parquet/export_parquet_bit.test
vendored
Normal file
29
external/duckdb/test/sql/export/parquet/export_parquet_bit.test
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
# name: test/sql/export/parquet/export_parquet_bit.test
|
||||
# description: Test EXPORT DATABASE with BIT columns
|
||||
# group: [parquet]
|
||||
|
||||
require parquet
|
||||
|
||||
statement ok
|
||||
begin transaction;
|
||||
|
||||
statement ok
|
||||
create table tbl as select "bit" from test_all_types(), range(3);
|
||||
|
||||
query I nosort result
|
||||
select * from tbl;
|
||||
----
|
||||
|
||||
# now export the db
|
||||
statement ok
|
||||
EXPORT DATABASE '__TEST_DIR__/export_test' (FORMAT PARQUET)
|
||||
|
||||
statement ok
|
||||
ROLLBACK
|
||||
|
||||
statement ok
|
||||
IMPORT DATABASE '__TEST_DIR__/export_test'
|
||||
|
||||
query I nosort result
|
||||
select * from tbl;
|
||||
----
|
||||
50
external/duckdb/test/sql/export/parquet/export_parquet_enum.test
vendored
Normal file
50
external/duckdb/test/sql/export/parquet/export_parquet_enum.test
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
# name: test/sql/export/parquet/export_parquet_enum.test
|
||||
# description: Test EXPORT DATABASE with UNION columns
|
||||
# group: [parquet]
|
||||
|
||||
require parquet
|
||||
|
||||
statement ok
|
||||
begin transaction;
|
||||
|
||||
statement ok
|
||||
create type my_enum as enum ('1', '2', '3')
|
||||
|
||||
|
||||
statement ok
|
||||
create table tbl (a my_enum);
|
||||
|
||||
statement ok
|
||||
create table tbl2 as select 'hello''world'::enum('hello''world');
|
||||
|
||||
statement ok
|
||||
insert into tbl VALUES
|
||||
('1'),
|
||||
(NULL),
|
||||
('3');
|
||||
|
||||
query I nosort result1
|
||||
select * from tbl;
|
||||
----
|
||||
|
||||
query I nosort result2
|
||||
select * from tbl2;
|
||||
----
|
||||
|
||||
# now export the db
|
||||
statement ok
|
||||
EXPORT DATABASE '__TEST_DIR__/export_test' (FORMAT PARQUET)
|
||||
|
||||
statement ok
|
||||
ROLLBACK
|
||||
|
||||
statement ok
|
||||
IMPORT DATABASE '__TEST_DIR__/export_test'
|
||||
|
||||
query I nosort result1
|
||||
select * from tbl;
|
||||
----
|
||||
|
||||
query I nosort result2
|
||||
select * from tbl2;
|
||||
----
|
||||
29
external/duckdb/test/sql/export/parquet/export_parquet_hugeint.test
vendored
Normal file
29
external/duckdb/test/sql/export/parquet/export_parquet_hugeint.test
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
# name: test/sql/export/parquet/export_parquet_hugeint.test
|
||||
# description: Test EXPORT DATABASE with BIT columns
|
||||
# group: [parquet]
|
||||
|
||||
require parquet
|
||||
|
||||
statement ok
|
||||
begin transaction;
|
||||
|
||||
statement ok
|
||||
create table tbl as select "hugeint" from test_all_types(), range(3);
|
||||
|
||||
query I nosort result
|
||||
select * from tbl;
|
||||
----
|
||||
|
||||
# now export the db
|
||||
statement ok
|
||||
EXPORT DATABASE '__TEST_DIR__/export_test' (FORMAT PARQUET)
|
||||
|
||||
statement ok
|
||||
ROLLBACK
|
||||
|
||||
statement ok
|
||||
IMPORT DATABASE '__TEST_DIR__/export_test'
|
||||
|
||||
query I nosort result
|
||||
select * from tbl;
|
||||
----
|
||||
31
external/duckdb/test/sql/export/parquet/export_parquet_json.test
vendored
Normal file
31
external/duckdb/test/sql/export/parquet/export_parquet_json.test
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
# name: test/sql/export/parquet/export_parquet_json.test
|
||||
# description: Test EXPORT DATABASE with JSON columns
|
||||
# group: [parquet]
|
||||
|
||||
require parquet
|
||||
|
||||
require json
|
||||
|
||||
statement ok
|
||||
begin transaction;
|
||||
|
||||
statement ok
|
||||
create table tbl as select val from ( select json_structure('{"a": 42}') val), range(3);
|
||||
|
||||
query I nosort result
|
||||
select * from tbl;
|
||||
----
|
||||
|
||||
# now export the db
|
||||
statement ok
|
||||
EXPORT DATABASE '__TEST_DIR__/export_test' (FORMAT PARQUET)
|
||||
|
||||
statement ok
|
||||
ROLLBACK
|
||||
|
||||
statement ok
|
||||
IMPORT DATABASE '__TEST_DIR__/export_test'
|
||||
|
||||
query I nosort result
|
||||
select * from tbl;
|
||||
----
|
||||
31
external/duckdb/test/sql/export/parquet/export_parquet_list.test
vendored
Normal file
31
external/duckdb/test/sql/export/parquet/export_parquet_list.test
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
# name: test/sql/export/parquet/export_parquet_list.test
|
||||
# description: Test EXPORT DATABASE with LIST columns
|
||||
# group: [parquet]
|
||||
|
||||
require parquet
|
||||
|
||||
statement ok
|
||||
begin transaction;
|
||||
|
||||
statement ok
|
||||
create table tbl as select val from (
|
||||
select ['01010101'::BIT, '01011101001'::BIT] val
|
||||
), range(3);
|
||||
|
||||
query I nosort result
|
||||
select * from tbl;
|
||||
----
|
||||
|
||||
# now export the db
|
||||
statement ok
|
||||
EXPORT DATABASE '__TEST_DIR__/export_test' (FORMAT PARQUET)
|
||||
|
||||
statement ok
|
||||
ROLLBACK
|
||||
|
||||
statement ok
|
||||
IMPORT DATABASE '__TEST_DIR__/export_test'
|
||||
|
||||
query I nosort result
|
||||
select * from tbl;
|
||||
----
|
||||
50
external/duckdb/test/sql/export/parquet/export_parquet_map.test
vendored
Normal file
50
external/duckdb/test/sql/export/parquet/export_parquet_map.test
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
# name: test/sql/export/parquet/export_parquet_map.test
|
||||
# description: Test EXPORT DATABASE with MAP columns
|
||||
# group: [parquet]
|
||||
|
||||
require parquet
|
||||
|
||||
statement ok
|
||||
begin transaction;
|
||||
|
||||
statement ok
|
||||
create table unsupported_key as select val from (
|
||||
select MAP {
|
||||
'hello': '01010101000'::BIT,
|
||||
'HELLO': NULL::BIT
|
||||
} val
|
||||
), range(3);
|
||||
|
||||
statement ok
|
||||
create table unsupported_value as select val from (
|
||||
select MAP {
|
||||
'01010101000'::BIT: 'hello',
|
||||
'11110111101'::BIT: 'world'
|
||||
} val
|
||||
), range(3);
|
||||
|
||||
query I nosort key
|
||||
select * from unsupported_key;
|
||||
----
|
||||
|
||||
query I nosort value
|
||||
select * from unsupported_value;
|
||||
----
|
||||
|
||||
# now export the db
|
||||
statement ok
|
||||
EXPORT DATABASE '__TEST_DIR__/export_test' (FORMAT PARQUET)
|
||||
|
||||
statement ok
|
||||
ROLLBACK
|
||||
|
||||
statement ok
|
||||
IMPORT DATABASE '__TEST_DIR__/export_test'
|
||||
|
||||
query I nosort key
|
||||
select * from unsupported_key;
|
||||
----
|
||||
|
||||
query I nosort value
|
||||
select * from unsupported_value;
|
||||
----
|
||||
35
external/duckdb/test/sql/export/parquet/export_parquet_struct.test
vendored
Normal file
35
external/duckdb/test/sql/export/parquet/export_parquet_struct.test
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
# name: test/sql/export/parquet/export_parquet_struct.test
|
||||
# description: Test EXPORT DATABASE with MAP columns
|
||||
# group: [parquet]
|
||||
|
||||
require parquet
|
||||
|
||||
statement ok
|
||||
begin transaction;
|
||||
|
||||
statement ok
|
||||
create table tbl as select val from (
|
||||
select {
|
||||
'a': '01010101000'::BIT,
|
||||
'b': true,
|
||||
'c': NULL
|
||||
} val
|
||||
), range(3);
|
||||
|
||||
query I nosort result
|
||||
select * from tbl;
|
||||
----
|
||||
|
||||
# now export the db
|
||||
statement ok
|
||||
EXPORT DATABASE '__TEST_DIR__/export_test' (FORMAT PARQUET)
|
||||
|
||||
statement ok
|
||||
ROLLBACK
|
||||
|
||||
statement ok
|
||||
IMPORT DATABASE '__TEST_DIR__/export_test'
|
||||
|
||||
query I nosort result
|
||||
select * from tbl;
|
||||
----
|
||||
43
external/duckdb/test/sql/export/parquet/export_parquet_union.test
vendored
Normal file
43
external/duckdb/test/sql/export/parquet/export_parquet_union.test
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
# name: test/sql/export/parquet/export_parquet_union.test
|
||||
# description: Test EXPORT DATABASE with UNION columns
|
||||
# group: [parquet]
|
||||
|
||||
require parquet
|
||||
|
||||
statement ok
|
||||
begin transaction;
|
||||
|
||||
statement ok
|
||||
create table tbl as select "union" from test_all_types(), range(3);
|
||||
|
||||
statement ok
|
||||
create table tbl2 (a UNION(a bit, b bool));
|
||||
|
||||
statement ok
|
||||
insert into tbl2 VALUES ('00101010'::BIT), (True::BOOL), (NULL::BIT);
|
||||
|
||||
query I nosort result1
|
||||
select * from tbl;
|
||||
----
|
||||
|
||||
query I nosort result2
|
||||
select * from tbl2;
|
||||
----
|
||||
|
||||
# now export the db
|
||||
statement ok
|
||||
EXPORT DATABASE '__TEST_DIR__/export_test' (FORMAT PARQUET)
|
||||
|
||||
statement ok
|
||||
ROLLBACK
|
||||
|
||||
statement ok
|
||||
IMPORT DATABASE '__TEST_DIR__/export_test'
|
||||
|
||||
query I nosort result1
|
||||
select * from tbl;
|
||||
----
|
||||
|
||||
query I nosort result2
|
||||
select * from tbl2;
|
||||
----
|
||||
111
external/duckdb/test/sql/export/parquet_export.test
vendored
Normal file
111
external/duckdb/test/sql/export/parquet_export.test
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
# name: test/sql/export/parquet_export.test
|
||||
# description: Test EXPORT/IMPORT database with parquet
|
||||
# group: [export]
|
||||
|
||||
require parquet
|
||||
|
||||
require vector_size 64
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
BEGIN TRANSACTION
|
||||
|
||||
statement ok
|
||||
CREATE TABLE integers(i INTEGER NOT NULL, j INTEGER)
|
||||
|
||||
statement ok
|
||||
INSERT INTO integers SELECT i, i+1 FROM range(0, 1000) tbl(i)
|
||||
|
||||
query II nosort sumresult
|
||||
SELECT SUM(i), SUM(j) FROM integers
|
||||
|
||||
statement ok
|
||||
EXPORT DATABASE '__TEST_DIR__/export_test' (FORMAT PARQUET)
|
||||
|
||||
statement ok
|
||||
ROLLBACK
|
||||
|
||||
statement ok
|
||||
IMPORT DATABASE '__TEST_DIR__/export_test'
|
||||
|
||||
# verify the data is still there
|
||||
query II nosort sumresult
|
||||
SELECT SUM(i), SUM(j) FROM integers
|
||||
|
||||
# verify that the not null constraint is still there
|
||||
statement error
|
||||
INSERT INTO integers VALUES (NULL, NULL)
|
||||
----
|
||||
<REGEX>:.*Constraint Error.*constraint failed.*
|
||||
|
||||
statement ok
|
||||
DROP TABLE integers
|
||||
|
||||
# now do it with a codec specified
|
||||
statement ok
|
||||
BEGIN TRANSACTION
|
||||
|
||||
statement ok
|
||||
CREATE TABLE integers(i INTEGER NOT NULL, j INTEGER)
|
||||
|
||||
statement ok
|
||||
INSERT INTO integers SELECT i, i+1 FROM range(0, 1000) tbl(i)
|
||||
|
||||
query II nosort sumresult
|
||||
SELECT SUM(i), SUM(j) FROM integers
|
||||
|
||||
statement ok
|
||||
EXPORT DATABASE '__TEST_DIR__/export_test' (FORMAT PARQUET, CODEC 'SNAPPY')
|
||||
|
||||
statement ok
|
||||
ROLLBACK
|
||||
|
||||
statement ok
|
||||
IMPORT DATABASE '__TEST_DIR__/export_test'
|
||||
|
||||
# verify the data is still there
|
||||
query II nosort sumresult
|
||||
SELECT SUM(i), SUM(j) FROM integers
|
||||
|
||||
# verify that the not null constraint is still there
|
||||
statement error
|
||||
INSERT INTO integers VALUES (NULL, NULL)
|
||||
----
|
||||
<REGEX>:.*Constraint Error.*constraint failed.*
|
||||
|
||||
statement ok
|
||||
DROP TABLE integers
|
||||
|
||||
# now do it with compression and row group size specified
|
||||
statement ok
|
||||
BEGIN TRANSACTION
|
||||
|
||||
statement ok
|
||||
CREATE TABLE integers(i INTEGER NOT NULL, j INTEGER)
|
||||
|
||||
statement ok
|
||||
INSERT INTO integers SELECT i, i+1 FROM range(0, 1000) tbl(i)
|
||||
|
||||
query II nosort sumresult
|
||||
SELECT SUM(i), SUM(j) FROM integers
|
||||
|
||||
statement ok
|
||||
EXPORT DATABASE '__TEST_DIR__/export_test' (FORMAT PARQUET, COMPRESSION ZSTD, ROW_GROUP_SIZE 100000);
|
||||
|
||||
statement ok
|
||||
ROLLBACK
|
||||
|
||||
statement ok
|
||||
IMPORT DATABASE '__TEST_DIR__/export_test'
|
||||
|
||||
# verify the data is still there
|
||||
query II nosort sumresult
|
||||
SELECT SUM(i), SUM(j) FROM integers
|
||||
|
||||
# verify that the not null constraint is still there
|
||||
statement error
|
||||
INSERT INTO integers VALUES (NULL, NULL)
|
||||
----
|
||||
<REGEX>:.*Constraint Error.*constraint failed.*
|
||||
Reference in New Issue
Block a user