You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature Request]: mo-dump supports dumping database and table definitions only without data #10091
Is there an existing issue for the same feature request?
I have checked the existing issues.
Is your feature request related to a problem?
Currently mo-dump supports 2 ways of dumping. One is dumping data with ddl and insert statements, and the other is dumping data with ddl and load statements along with csv data files. However mo-dump does not yet support dumping the definitions of database and/or tables only, without any data.
Describe the feature you'd like
mo-dump supports dumping database and table definitions only without data
Describe implementation you've considered
Support statement like this, with a --nodata option which indicates export database/table structure only.
root@test0:/data/mo/20231030_1050/matrixone# mo_ctl get_cid
2023-10-30 11:04:35.405 UTC+0800 [INFO] Try get mo commit id
commit 0175397c3d933aff66b3fa950f85d92fc05cab2c
Author: LiuBo <[email protected]>
Date: Mon Oct 30 10:22:47 2023 +0800
[bug] util: fix a user casein address manager. (#12273)
2023-10-30 11:04:35.482 UTC+0800 [INFO] Get commit id succeeded
3 Test process and result:
3.1 Test case 1 : tpch_1g
3.1.1 Step 1. Load tpch 1g data into a newly installed mo with latest commit id 3.1.2 Step 2. Execute below command to export the whole database with all tables
command:
results:
3 tables are exported with no database definition, which meets our expectation.
3.1.4 Step 4. Restore the database using the backups with no-data
command:
mo_ctl sql 'drop database tpch_1g;'
mo_ctl sql 'show databases;'
mo_ctl sql /data/mo-backup/20231030_1058/tpch_1g_nodata_test.sql
mo_ctl sql 'show databases;'
mo_ctl sql 'show tables in tpch_1g;'
mo_ctl sql "select 'nation' as table_name, count(*) from tpch_1g.nation union select 'region' as table_name, count(*) from tpch_1g.region union select 'part' as table_name, count(*) from tpch_1g.part union select 'supplier' as table_name, count(*) from tpch_1g.supplier union select 'partsupp' as table_name, count(*) from tpch_1g.partsupp union select 'customer' as table_name, count(*) from tpch_1g.customer union select 'orders' as table_name, count(*) from tpch_1g.orders union select 'lineitem' as table_name, count(*) from tpch_1g.lineitem;"
results: tpch_1g database is created with all 8 tables in it and no data are loaded into any of these tables, which meets our expectation.
3.1.4 Step 4. Restore the tables using the backups with no-data
command:
# add database definition to the backup files
sed -i '1iuse test;' /data/mo-backup/20231030_1058/tpch_1g_nodata_test_2.sql
sed -i '1icreate database if not exists test;' /data/mo-backup/20231030_1058/tpch_1g_nodata_test_2.sql
cat /data/mo-backup/20231030_1058/tpch_1g_nodata_test_2.sql
mo_ctl sql 'show databases'
mo_ctl sql /data/mo-backup/20231030_1058/tpch_1g_nodata_test_2.sql
mo_ctl sql 'show databases; show tables in test;'
mo_ctl sql "select 'nation' as table_name, count(*) as count from test.nation union select 'part' as table_name, count(*) as count from test.part union select 'customer' as table_name, count(*) as count from test.customer;"
result:
3 tables nation, part and customer are created in test database with no data, which meets our expectation.
**3.2 ** Test case 2: create some sample data
Steps are similar, with data defined as below, which can be used as bvt case
3.2.1 prepare data
-- test_data.sqlcreatedatabaseif not exists `modump_nodata_test`;
use `modump_nodata_test`;
createtable `t1` (id int);
insert into`t1`values (1),(2),(3);
select*from`t1`;
createtable `t2` (name varchar(10));
insert into`t2`values ('A'),('B'),('C');
select*from`t2`;
mo_ctl sql 'drop database if exists `modump_nodata_test`;'
mo_ctl sql 'show databases;'
mo_ctl sql "${BK_PATH}/test_1.sql"
mo_ctl sql "show databases; show tables in modump_nodata_test; select 't1' as table_name, count(*) from modump_nodata_test.t1 union select 't2' as table_name, count(*) from modump_nodata_test.t2;"
mo_ctl sql 'show databases;'
sed -i '1iuse modump_nodata_test_2;'${BK_PATH}/test_2.sql
sed -i '1icreate database if not exists modump_nodata_test_2;'${BK_PATH}/test_2.sql
cat ${BK_PATH}/test_2.sql
mo_ctl sql 'show databases;'
mo_ctl sql "${BK_PATH}/test_2.sql"
mo_ctl sql "show databases; show tables in modump_nodata_test; select 't1' as table_name, count(*) from modump_nodata_test.t1 union select 't2' as table_name, count(*) from modump_nodata_test.t2;"
Activity
xmh1011 commentedon Oct 16, 2023
I'll try it.
xmh1011 commentedon Oct 16, 2023
What is the data format supposed to be exported? Like
SHOW TABLESandSHOW COLUMNS?xmh1011 commentedon Oct 27, 2023
I think this issue can be closed now.
aronchanisme commentedon Oct 30, 2023
1 Test date: 2023/10/30
2 MO commit id:
3 Test process and result:
3.1 Test case 1 : tpch_1g
3.1.1 Step 1. Load tpch 1g data into a newly installed mo with latest commit id
3.1.2 Step 2. Execute below command to export the whole database with all tables
command:
results:

8 tables are exported with tpch_1g database definition, which meets our expectation.
3.1.3 Step 3. Execute below command to export a few table within tpch_1g
command:
results:


3 tables are exported with no database definition, which meets our expectation.
3.1.4 Step 4. Restore the database using the backups with no-data
command:
results:





tpch_1gdatabase is created with all 8 tables in it and no data are loaded into any of these tables, which meets our expectation.3.1.4 Step 4. Restore the tables using the backups with no-data
command:
result:




3 tables
nation,partandcustomerare created intestdatabase with no data, which meets our expectation.**3.2 ** Test case 2: create some sample data
Steps are similar, with data defined as below, which can be used as bvt case
3.2.1 prepare data
mo_ctl sql 'test_data.sql'
3.2.2 backup test:
3.2.3 restore test
Results: the result meets our expectation










aronchanisme commentedon Oct 30, 2023
PS: Since mo-tested does not yet support executing external commands like mo-dump but not sql statement , bvt case is not added as of now. Will cover the test case in MO release test workflow in the future.
https://github.com/matrixorigin/mo-nightly-regression/actions/workflows/mo-release-test-standalone.yml