Skip to content

bugfixing #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions run_airline_ontime_data_mysql_to_ch_migration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
# migrate data from MySQL to ClickHouse

# put csv files in this dir
CSV_FILES_DIR="/var/lib/mysql-files"

# dump CSV files into CSV_FILES_DIR
sudo mysqldump \
-u root \
--tz-utc \
--quick \
--fields-terminated-by=, \
--fields-optionally-enclosed-by=\" \
--fields-escaped-by=\\ \
--tab="$CSV_FILES_DIR"/ \
airline ontime

# replay CSV files from CSV_FILES_DIR
sudo cat "$CSV_FILES_DIR"/ontime.txt | clickhouse-client --query="INSERT INTO airline.ontime FORMAT CSV"
10 changes: 5 additions & 5 deletions src/tablebuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,30 +264,30 @@ def map_type(self, mysql_type, nullable=False):
ch_type = 'String'
elif mysql_type.startswith('TINYINT'):
ch_type = 'UInt8' if mysql_type.endswith('UNSIGNED') else 'Int8'
elif mysql_type.startswith('BOOL') or mysql_type.startswith('BOOLEAN'):
elif mysql_type.startswith('BOOLEAN') or mysql_type.startswith('BOOL'):
ch_type = 'UInt8'
elif mysql_type.startswith('SMALLINT'):
ch_type = 'UInt16' if mysql_type.endswith('UNSIGNED') else 'Int16'
elif mysql_type.startswith('MEDIUMINT'):
ch_type = 'UInt32' if mysql_type.endswith('UNSIGNED') else 'Int32'
elif mysql_type.startswith('INT') or mysql_type.startswith('INTEGER'):
elif mysql_type.startswith('INTEGER') or mysql_type.startswith('INT'):
ch_type = 'UInt32' if mysql_type.endswith('UNSIGNED') else 'Int32'
elif mysql_type.startswith('BIGINT'):
ch_type = 'UInt64' if mysql_type.endswith('UNSIGNED') else 'Int64'
elif mysql_type.startswith('SERIAL'):
ch_type = 'UInt64'
elif mysql_type.startswith('DEC') or mysql_type.startswith('DECIMAL') or mysql_type.startswith('FIXED') or mysql_type.startswith('NUMERIC'):
elif mysql_type.startswith('DECIMAL') or mysql_type.startswith('DEC') or mysql_type.startswith('FIXED') or mysql_type.startswith('NUMERIC'):
ch_type = 'String'
elif mysql_type.startswith('FLOAT'):
ch_type = 'Float32'
elif mysql_type.startswith('DOUBLE') or mysql_type.startswith('REAL'):
ch_type = 'Float64'

# Date and Time Types
elif mysql_type.startswith('DATE'):
ch_type = 'Date'
elif mysql_type.startswith('DATETIME'):
ch_type = 'DateTime'
elif mysql_type.startswith('DATE'):
ch_type = 'Date'
elif mysql_type.startswith('TIMESTAMP'):
ch_type = 'DateTime'
elif mysql_type.startswith('TIME'):
Expand Down