flydata 0.3.16 → 0.3.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/flydata-core/lib/flydata-core/record/record.rb +13 -0
- data/flydata-core/lib/flydata-core/table_def/mysql_table_def.rb +107 -5
- data/flydata-core/lib/flydata-core/table_def/redshift_table_def.rb +62 -11
- data/flydata-core/spec/table_def/mysql_table_def_spec.rb +37 -1
- data/flydata-core/spec/table_def/mysql_to_redshift_table_def_spec.rb +120 -0
- data/flydata-core/spec/table_def/mysqldump_test_column_charset.dump +45 -0
- data/flydata-core/spec/table_def/redshift_table_def_spec.rb +70 -88
- data/flydata.gemspec +13 -8
- data/lib/flydata/command/setup.rb +4 -4
- data/lib/flydata/command/sync.rb +18 -29
- data/lib/flydata/compatibility_check.rb +2 -2
- data/lib/flydata/fluent-plugins/in_mysql_binlog_flydata.rb +15 -10
- data/lib/flydata/fluent-plugins/mysql/binlog_record_handler.rb +6 -3
- data/lib/flydata/fluent-plugins/mysql/dml_record_handler.rb +15 -8
- data/lib/flydata/fluent-plugins/mysql/table_meta.rb +6 -34
- data/lib/flydata/{fluent-plugins/mysql → mysql}/binlog_position.rb +2 -0
- data/lib/flydata/{util → mysql}/mysql_util.rb +34 -1
- data/lib/flydata/mysql/table_ddl.rb +118 -0
- data/lib/flydata/parser/mysql/dump_parser.rb +5 -5
- data/lib/flydata/parser/mysql/mysql_alter_table.treetop +29 -5
- data/lib/flydata/sync_file_manager.rb +15 -2
- data/spec/flydata/command/sync_spec.rb +22 -1
- data/spec/flydata/fluent-plugins/in_mysql_binlog_flydata_spec.rb +7 -2
- data/spec/flydata/fluent-plugins/mysql/dml_record_handler_spec.rb +130 -0
- data/spec/flydata/fluent-plugins/mysql/shared_query_handler_context.rb +1 -0
- data/spec/flydata/fluent-plugins/mysql/table_meta_spec.rb +14 -8
- data/spec/flydata/fluent-plugins/mysql/truncate_query_handler_spec.rb +2 -1
- data/spec/flydata/{fluent-plugins/mysql → mysql}/binlog_position_spec.rb +3 -2
- data/spec/flydata/{util → mysql}/mysql_util_spec.rb +2 -2
- data/spec/flydata/mysql/table_ddl_spec.rb +193 -0
- data/spec/flydata/parser/mysql/alter_table_parser_spec.rb +37 -9
- data/spec/flydata/sync_file_manager_spec.rb +102 -27
- metadata +12 -7
@@ -0,0 +1,45 @@
|
|
1
|
+
-- MySQL dump 10.13 Distrib 5.6.21, for debian-linux-gnu (x86_64)
|
2
|
+
--
|
3
|
+
-- Host: ubertas Database: mak_development
|
4
|
+
-- ------------------------------------------------------
|
5
|
+
-- Server version 5.6.21-1+deb.sury.org~precise+1-log
|
6
|
+
|
7
|
+
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
8
|
+
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
9
|
+
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
10
|
+
/*!40101 SET NAMES utf8 */;
|
11
|
+
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
12
|
+
/*!40103 SET TIME_ZONE='+00:00' */;
|
13
|
+
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
14
|
+
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
15
|
+
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
16
|
+
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
17
|
+
|
18
|
+
--
|
19
|
+
-- Table structure for table `items`
|
20
|
+
--
|
21
|
+
|
22
|
+
DROP TABLE IF EXISTS `items`;
|
23
|
+
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
24
|
+
/*!40101 SET character_set_client = utf8 */;
|
25
|
+
CREATE TABLE `items` (
|
26
|
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
27
|
+
`name` varchar(40) CHARACTER SET latin1 DEFAULT NULL,
|
28
|
+
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
|
29
|
+
`bin` binary(34) DEFAULT NULL,
|
30
|
+
`bin2` blob,
|
31
|
+
`varbin` varchar(34) DEFAULT NULL,
|
32
|
+
PRIMARY KEY (`id`)
|
33
|
+
) ENGINE=InnoDB AUTO_INCREMENT=57 DEFAULT CHARSET=utf8;
|
34
|
+
/*!40101 SET character_set_client = @saved_cs_client */;
|
35
|
+
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
36
|
+
|
37
|
+
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
38
|
+
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
39
|
+
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
40
|
+
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
41
|
+
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
42
|
+
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
43
|
+
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
44
|
+
|
45
|
+
-- Dump completed on 2015-03-26 23:36:52
|
@@ -7,43 +7,47 @@ module TableDef
|
|
7
7
|
describe RedshiftTableDef do
|
8
8
|
|
9
9
|
describe '.from_flydata_tabledef' do
|
10
|
+
subject { described_class.from_flydata_tabledef(flydata_tabledef, option) }
|
11
|
+
|
12
|
+
let(:value_column_hash) { { column: "value", type: "text" } }
|
13
|
+
let(:value_column) { value_column_hash }
|
14
|
+
let(:value_type_body) { 'text' }
|
15
|
+
let(:value_type) { value_type_body }
|
10
16
|
let(:flydata_tabledef) { {
|
11
17
|
table_name: "test_table",
|
12
18
|
columns: [
|
13
19
|
{ column: "id", type: "int4(11)", not_null: true, primary_key: true },
|
14
20
|
{ column: "age", type: "int4(11) unsigned" },
|
15
|
-
|
21
|
+
value_column,
|
16
22
|
],
|
17
|
-
default_charset: "
|
23
|
+
default_charset: "UTF_8"} }
|
18
24
|
let(:option) { { flydata_ctl_table: false } }
|
19
25
|
|
20
|
-
|
26
|
+
let(:schema_prefix) { "" }
|
21
27
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
DROP TABLE IF EXISTS "test_table";
|
26
|
-
CREATE TABLE "test_table" (
|
28
|
+
let(:create_table_queries) { <<EOT.strip }
|
29
|
+
DROP TABLE IF EXISTS #{schema_prefix}"test_table";
|
30
|
+
CREATE TABLE #{schema_prefix}"test_table" (
|
27
31
|
"id" int4 NOT NULL,
|
28
32
|
"age" int8,
|
29
33
|
"value" varchar(max),
|
30
34
|
PRIMARY KEY (id)
|
31
35
|
) DISTKEY(id) SORTKEY(id);
|
32
|
-
|
33
|
-
|
36
|
+
EOT
|
37
|
+
let(:flydata_ctl_update) { <<EOT.strip }
|
38
|
+
DELETE FROM #{schema_prefix}"flydata_ctl_columns" WHERE table_name = 'test_table';
|
39
|
+
INSERT INTO #{schema_prefix}"flydata_ctl_columns" (table_name, column_name, src_data_type, ordinal_position) VALUES
|
34
40
|
('test_table', 'id', 'int4(11)', 1),
|
35
41
|
('test_table', 'age', 'int4(11) unsigned', 2),
|
36
|
-
('test_table', 'value', '
|
42
|
+
('test_table', 'value', '#{value_type}', 3);
|
43
|
+
DELETE FROM #{schema_prefix}"flydata_ctl_tables" WHERE table_name = 'test_table';
|
44
|
+
INSERT INTO #{schema_prefix}"flydata_ctl_tables" (table_name, attribute, value) VALUES
|
45
|
+
('test_table', 'cs', 'UTF_8'),
|
46
|
+
('test_table', 'revision', 1);
|
37
47
|
EOT
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context 'with flydata_ctl_columns option true' do
|
42
|
-
let(:option) { { flydata_ctl_columns: true } }
|
43
48
|
|
44
|
-
|
45
|
-
|
46
|
-
CREATE TABLE IF NOT EXISTS "flydata_ctl_columns"(
|
49
|
+
let(:flydata_ctl_create) { <<EOT.strip }
|
50
|
+
CREATE TABLE IF NOT EXISTS #{schema_prefix}"flydata_ctl_columns"(
|
47
51
|
id integer NOT NULL IDENTITY(1,1),
|
48
52
|
table_name varchar(128) NOT NULL,
|
49
53
|
column_name varchar(128) NOT NULL,
|
@@ -52,92 +56,70 @@ CREATE TABLE IF NOT EXISTS "flydata_ctl_columns"(
|
|
52
56
|
ordinal_position int NOT NULL,
|
53
57
|
PRIMARY KEY(id)
|
54
58
|
) DISTKEY(table_name) SORTKEY(table_name);
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
(
|
66
|
-
|
59
|
+
CREATE TABLE IF NOT EXISTS #{schema_prefix}"flydata_ctl_tables"(
|
60
|
+
id integer NOT NULL IDENTITY(1,1),
|
61
|
+
table_name varchar(128) NOT NULL,
|
62
|
+
attribute varchar(128) NOT NULL,
|
63
|
+
value varchar(max),
|
64
|
+
created_at timestamp DEFAULT SYSDATE,
|
65
|
+
PRIMARY KEY(id)
|
66
|
+
) DISTKEY(table_name) SORTKEY(table_name);
|
67
|
+
EOT
|
68
|
+
|
69
|
+
let(:comment_subquery) { <<EOT.strip }
|
70
|
+
COMMENT ON COLUMN #{schema_prefix}"test_table"."value"
|
71
|
+
IS 'helloworld';
|
72
|
+
EOT
|
73
|
+
|
74
|
+
let(:create_schema_query) { <<EOT.strip }
|
75
|
+
CREATE SCHEMA IF NOT EXISTS "test_schema";
|
67
76
|
EOT
|
77
|
+
|
78
|
+
context 'with simple flydatadef' do
|
79
|
+
it 'should return ddl' do
|
80
|
+
expect(subject).to eq "#{create_table_queries}\n#{flydata_ctl_update}"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'with flydata_ctl_columns option true' do
|
85
|
+
let(:option) { { flydata_ctl_columns: true } }
|
86
|
+
|
87
|
+
it 'should return ddl including flydata_ctl_columns creation' do
|
88
|
+
expect(subject).to eq "#{flydata_ctl_create}\n#{create_table_queries}\n#{flydata_ctl_update}"
|
68
89
|
end
|
69
90
|
end
|
70
91
|
|
71
92
|
context 'with flydatadef with comment' do
|
72
|
-
let(:
|
73
|
-
table_name: "test_table",
|
74
|
-
columns: [
|
75
|
-
{ column: "id", type: "int4(11)", not_null: true, primary_key: true },
|
76
|
-
{ column: "value", type: "text" },
|
77
|
-
{ column: "cmnt", type: "text", comment: "helloworld" },
|
78
|
-
],
|
79
|
-
default_charset: "utf8;"} }
|
93
|
+
let(:value_column) { value_column_hash.merge(comment: "helloworld") }
|
80
94
|
|
81
95
|
it 'should add comment creation ddl' do
|
82
|
-
expect(subject).to eq
|
83
|
-
DROP TABLE IF EXISTS "test_table";
|
84
|
-
CREATE TABLE "test_table" (
|
85
|
-
"id" int4 NOT NULL,
|
86
|
-
"value" varchar(max),
|
87
|
-
"cmnt" varchar(max),
|
88
|
-
PRIMARY KEY (id)
|
89
|
-
) DISTKEY(id) SORTKEY(id);
|
90
|
-
COMMENT ON COLUMN "test_table"."cmnt"
|
91
|
-
IS 'helloworld';
|
92
|
-
DELETE FROM "flydata_ctl_columns" WHERE table_name = 'test_table';
|
93
|
-
INSERT INTO "flydata_ctl_columns" (table_name, column_name, src_data_type, ordinal_position) VALUES
|
94
|
-
('test_table', 'id', 'int4(11)', 1),
|
95
|
-
('test_table', 'value', 'text', 2),
|
96
|
-
('test_table', 'cmnt', 'text', 3);
|
97
|
-
EOT
|
96
|
+
expect(subject).to eq "#{create_table_queries}\n#{comment_subquery}\n#{flydata_ctl_update}"
|
98
97
|
end
|
99
98
|
end
|
100
99
|
|
101
100
|
context 'with schema_name' do
|
102
|
-
let(:
|
103
|
-
table_name: "test_table",
|
104
|
-
columns: [
|
105
|
-
{ column: "id", type: "int4(11)", not_null: true, primary_key: true },
|
106
|
-
{ column: "value", type: "text" },
|
107
|
-
{ column: "cmnt", type: "text", comment: "helloworld" },
|
108
|
-
],
|
109
|
-
default_charset: "utf8;"} }
|
101
|
+
let(:value_column) { value_column_hash.merge(comment: "helloworld") }
|
110
102
|
let(:option) { { flydata_ctl_table: true, schema_name: 'test_schema' } }
|
103
|
+
let(:schema_prefix) { '"test_schema".' }
|
111
104
|
|
112
105
|
it 'should preappend schema name to table name' do
|
113
|
-
expect(subject).to eq
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
src_data_type varchar(1024) NOT NULL,
|
120
|
-
revision int NOT NULL DEFAULT 1,
|
121
|
-
ordinal_position int NOT NULL,
|
122
|
-
PRIMARY KEY(id)
|
123
|
-
) DISTKEY(table_name) SORTKEY(table_name);
|
124
|
-
DROP TABLE IF EXISTS "test_schema"."test_table";
|
125
|
-
CREATE TABLE "test_schema"."test_table" (
|
126
|
-
"id" int4 NOT NULL,
|
127
|
-
"value" varchar(max),
|
128
|
-
"cmnt" varchar(max),
|
129
|
-
PRIMARY KEY (id)
|
130
|
-
) DISTKEY(id) SORTKEY(id);
|
131
|
-
COMMENT ON COLUMN "test_schema"."test_table"."cmnt"
|
132
|
-
IS 'helloworld';
|
133
|
-
DELETE FROM "test_schema"."flydata_ctl_columns" WHERE table_name = 'test_table';
|
134
|
-
INSERT INTO "test_schema"."flydata_ctl_columns" (table_name, column_name, src_data_type, ordinal_position) VALUES
|
135
|
-
('test_table', 'id', 'int4(11)', 1),
|
136
|
-
('test_table', 'value', 'text', 2),
|
137
|
-
('test_table', 'cmnt', 'text', 3);
|
106
|
+
expect(subject).to eq <<EOT.strip
|
107
|
+
#{create_schema_query}
|
108
|
+
#{flydata_ctl_create}
|
109
|
+
#{create_table_queries}
|
110
|
+
#{comment_subquery}
|
111
|
+
#{flydata_ctl_update}
|
138
112
|
EOT
|
139
113
|
end
|
140
114
|
end
|
115
|
+
|
116
|
+
context 'with column charset' do
|
117
|
+
let(:value_column) { value_column_hash.merge(charset: "ISO_8859_1") }
|
118
|
+
let(:value_type) { "#{value_type_body} cs:ISO_8859_1" }
|
119
|
+
it 'should return ddl' do
|
120
|
+
expect(subject).to eq "#{create_table_queries}\n#{flydata_ctl_update}"
|
121
|
+
end
|
122
|
+
end
|
141
123
|
end
|
142
124
|
|
143
125
|
describe '.column_def_sql' do
|
data/flydata.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: flydata 0.3.
|
5
|
+
# stub: flydata 0.3.17 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "flydata"
|
9
|
-
s.version = "0.3.
|
9
|
+
s.version = "0.3.17"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Koichi Fujikawa", "Masashi Miyazaki", "Matthew Luu", "Mak Inada", "Sriram NS"]
|
14
|
-
s.date = "2015-04-
|
14
|
+
s.date = "2015-04-22"
|
15
15
|
s.description = "FlyData Agent"
|
16
16
|
s.email = "sysadmin@flydata.com"
|
17
17
|
s.executables = ["fdmysqldump", "flydata", "serverinfo"]
|
@@ -47,6 +47,7 @@ Gem::Specification.new do |s|
|
|
47
47
|
"flydata-core/lib/flydata-core/fluent-plugins/multi_buffer.rb",
|
48
48
|
"flydata-core/lib/flydata-core/fluent/config_helper.rb",
|
49
49
|
"flydata-core/lib/flydata-core/logger.rb",
|
50
|
+
"flydata-core/lib/flydata-core/record/record.rb",
|
50
51
|
"flydata-core/lib/flydata-core/table_def.rb",
|
51
52
|
"flydata-core/lib/flydata-core/table_def/mysql_table_def.rb",
|
52
53
|
"flydata-core/lib/flydata-core/table_def/redshift_table_def.rb",
|
@@ -58,6 +59,7 @@ Gem::Specification.new do |s|
|
|
58
59
|
"flydata-core/spec/table_def/mysql_table_def_spec.rb",
|
59
60
|
"flydata-core/spec/table_def/mysql_to_redshift_table_def_spec.rb",
|
60
61
|
"flydata-core/spec/table_def/mysqldump_test_bit_table.dump",
|
62
|
+
"flydata-core/spec/table_def/mysqldump_test_column_charset.dump",
|
61
63
|
"flydata-core/spec/table_def/mysqldump_test_foreign_key.dump",
|
62
64
|
"flydata-core/spec/table_def/mysqldump_test_table_all.dump",
|
63
65
|
"flydata-core/spec/table_def/mysqldump_test_table_column_comment.dump",
|
@@ -102,7 +104,6 @@ Gem::Specification.new do |s|
|
|
102
104
|
"lib/flydata/fluent-plugins/idle_event_detector.rb",
|
103
105
|
"lib/flydata/fluent-plugins/in_mysql_binlog_flydata.rb",
|
104
106
|
"lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb",
|
105
|
-
"lib/flydata/fluent-plugins/mysql/binlog_position.rb",
|
106
107
|
"lib/flydata/fluent-plugins/mysql/binlog_position_file.rb",
|
107
108
|
"lib/flydata/fluent-plugins/mysql/binlog_query_dispatcher.rb",
|
108
109
|
"lib/flydata/fluent-plugins/mysql/binlog_query_handler.rb",
|
@@ -121,6 +122,9 @@ Gem::Specification.new do |s|
|
|
121
122
|
"lib/flydata/heroku/configuration_methods.rb",
|
122
123
|
"lib/flydata/heroku/instance_methods.rb",
|
123
124
|
"lib/flydata/log_monitor.rb",
|
125
|
+
"lib/flydata/mysql/binlog_position.rb",
|
126
|
+
"lib/flydata/mysql/mysql_util.rb",
|
127
|
+
"lib/flydata/mysql/table_ddl.rb",
|
124
128
|
"lib/flydata/output/forwarder.rb",
|
125
129
|
"lib/flydata/parser/mysql/dump_parser.rb",
|
126
130
|
"lib/flydata/parser/mysql/mysql_alter_table.treetop",
|
@@ -129,7 +133,6 @@ Gem::Specification.new do |s|
|
|
129
133
|
"lib/flydata/proxy.rb",
|
130
134
|
"lib/flydata/sync_file_manager.rb",
|
131
135
|
"lib/flydata/util/encryptor.rb",
|
132
|
-
"lib/flydata/util/mysql_util.rb",
|
133
136
|
"spec/fluent_plugins_spec_helper.rb",
|
134
137
|
"spec/fly_data_model_spec.rb",
|
135
138
|
"spec/flydata/api/data_entry_spec.rb",
|
@@ -155,26 +158,28 @@ Gem::Specification.new do |s|
|
|
155
158
|
"spec/flydata/fluent-plugins/idle_event_detector_spec.rb",
|
156
159
|
"spec/flydata/fluent-plugins/in_mysql_binlog_flydata_spec.rb",
|
157
160
|
"spec/flydata/fluent-plugins/mysql/alter_table_query_handler_spec.rb",
|
158
|
-
"spec/flydata/fluent-plugins/mysql/binlog_position_spec.rb",
|
159
161
|
"spec/flydata/fluent-plugins/mysql/binlog_query_dispatcher_spec.rb",
|
160
162
|
"spec/flydata/fluent-plugins/mysql/ddl_query_handler_spec.rb",
|
163
|
+
"spec/flydata/fluent-plugins/mysql/dml_record_handler_spec.rb",
|
161
164
|
"spec/flydata/fluent-plugins/mysql/shared_query_handler_context.rb",
|
162
165
|
"spec/flydata/fluent-plugins/mysql/table_meta_spec.rb",
|
163
166
|
"spec/flydata/fluent-plugins/mysql/truncate_query_handler_spec.rb",
|
164
167
|
"spec/flydata/heroku_spec.rb",
|
168
|
+
"spec/flydata/mysql/binlog_position_spec.rb",
|
169
|
+
"spec/flydata/mysql/mysql_util_spec.rb",
|
170
|
+
"spec/flydata/mysql/table_ddl_spec.rb",
|
165
171
|
"spec/flydata/output/forwarder_spec.rb",
|
166
172
|
"spec/flydata/parser/mysql/alter_table_parser_spec.rb",
|
167
173
|
"spec/flydata/parser/mysql/dump_parser_spec.rb",
|
168
174
|
"spec/flydata/sync_file_manager_spec.rb",
|
169
175
|
"spec/flydata/util/encryptor_spec.rb",
|
170
|
-
"spec/flydata/util/mysql_util_spec.rb",
|
171
176
|
"spec/flydata_spec.rb",
|
172
177
|
"spec/spec_helper.rb",
|
173
178
|
"tmpl/redshift_mysql_data_entry.conf.tmpl"
|
174
179
|
]
|
175
180
|
s.homepage = "http://flydata.com/"
|
176
181
|
s.licenses = ["All right reserved."]
|
177
|
-
s.rubygems_version = "2.4.
|
182
|
+
s.rubygems_version = "2.4.3"
|
178
183
|
s.summary = "FlyData Agent"
|
179
184
|
|
180
185
|
if s.respond_to? :specification_version then
|
@@ -40,7 +40,7 @@ What's next?
|
|
40
40
|
- To manage the FlyData Agent, use the 'flydata' command (type 'flydata' for
|
41
41
|
help)
|
42
42
|
- If you encounter an issue,
|
43
|
-
please check our documentation (https://www.flydata.com/
|
43
|
+
please check our documentation (https://www.flydata.com/resources/) or
|
44
44
|
contact our customer support team (support@flydata.com)
|
45
45
|
|
46
46
|
Thank you for using FlyData!
|
@@ -67,13 +67,13 @@ What's next?
|
|
67
67
|
3. Start Sync
|
68
68
|
Run the following command on your server. The command will start synchronizing data between MySQL and Redshift!
|
69
69
|
|
70
|
-
$ flydata
|
70
|
+
$ flydata start
|
71
71
|
|
72
72
|
EOM
|
73
73
|
|
74
74
|
NO_DE_CANCEL_MESSAGE_TEMPLATE = <<-EOM
|
75
|
-
FlyData Agent has been installed on your
|
76
|
-
However, you need to create at least a data entry before start using FlyData.
|
75
|
+
FlyData Agent has been installed on your server successfully.
|
76
|
+
However, you need to create at least a data entry before you can start using FlyData.
|
77
77
|
|
78
78
|
What's next?
|
79
79
|
|
data/lib/flydata/command/sync.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'fiber'
|
2
2
|
require 'msgpack'
|
3
|
-
require 'open3'
|
4
3
|
require 'mysql2'
|
5
4
|
require 'rest_client'
|
6
5
|
require 'sys/filesystem'
|
@@ -14,8 +13,9 @@ require 'flydata/output/forwarder'
|
|
14
13
|
require 'flydata/parser/mysql/dump_parser'
|
15
14
|
require 'flydata/preference/data_entry_preference'
|
16
15
|
require 'flydata/sync_file_manager'
|
17
|
-
require 'flydata/
|
16
|
+
require 'flydata/mysql/mysql_util'
|
18
17
|
require 'flydata-core/table_def'
|
18
|
+
require 'flydata/mysql/table_ddl'
|
19
19
|
#require 'ruby-prof'
|
20
20
|
|
21
21
|
module Flydata
|
@@ -534,6 +534,7 @@ EOM
|
|
534
534
|
Proc.new { |mysql_table, values_set|
|
535
535
|
mysql_table_name = mysql_table.table_name
|
536
536
|
records = values_set.collect do |values|
|
537
|
+
values = convert_to_flydata_values(mysql_table, values)
|
537
538
|
json = generate_json(mysql_table, values)
|
538
539
|
{table_name: mysql_table_name, log: json}
|
539
540
|
end
|
@@ -673,6 +674,11 @@ EOM
|
|
673
674
|
sync_fm.close
|
674
675
|
end
|
675
676
|
|
677
|
+
def convert_to_flydata_values(mysql_table, values)
|
678
|
+
types = mysql_table.columns.each_value.collect{|col_attrs| col_attrs[:format_type]}
|
679
|
+
types.size.times.collect{|i| FlydataCore::TableDef::MysqlTableDef.convert_to_flydata_value(values[i], types[i]) }
|
680
|
+
end
|
681
|
+
|
676
682
|
def generate_json(mysql_table, values)
|
677
683
|
h = {}
|
678
684
|
mysql_table.columns.each_key.with_index do |k, i|
|
@@ -739,33 +745,16 @@ EOM
|
|
739
745
|
raise "`tables` (or `tables_append_only`) is neither defined in the data entry nor the local config file"
|
740
746
|
end
|
741
747
|
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
while !stdout.eof?
|
749
|
-
begin
|
750
|
-
mysql_tabledef = FlydataCore::TableDef::MysqlTableDef.create(stdout, skip_primary_key_check: opts.skip_primary_key_check?)
|
751
|
-
if mysql_tabledef.nil?
|
752
|
-
# stream had no more create table definition
|
753
|
-
break
|
754
|
-
end
|
755
|
-
flydata_tabledef = mysql_tabledef.to_flydata_tabledef
|
756
|
-
puts FlydataCore::TableDef::RedshiftTableDef.from_flydata_tabledef(flydata_tabledef, flydata_ctl_table: create_flydata_ctl_table, schema_name: schema_name, ctl_only: opts.ctl_only?)
|
757
|
-
rescue FlydataCore::TableDefError=> e
|
758
|
-
error_list << e.err_hash
|
759
|
-
next
|
760
|
-
end
|
761
|
-
create_flydata_ctl_table = false
|
762
|
-
end
|
763
|
-
errors = ""
|
764
|
-
while !stderr.eof?
|
765
|
-
line = stderr.gets.gsub('mysqldump: ', '')
|
766
|
-
errors << line unless /Warning: Using a password on the command line interface can be insecure./ === line
|
748
|
+
create_flydata_ctl_table = true
|
749
|
+
option = {skip_parimay_key_check: opts.skip_primary_key_check?}.merge(mp)
|
750
|
+
Mysql::MysqlUtil.each_mysql_tabledef(tables, option) do |mysql_tabledef, error|
|
751
|
+
if error
|
752
|
+
error_list << error.err_hash
|
753
|
+
next
|
767
754
|
end
|
768
|
-
|
755
|
+
flydata_tabledef = mysql_tabledef.to_flydata_tabledef
|
756
|
+
puts FlydataCore::TableDef::RedshiftTableDef.from_flydata_tabledef(flydata_tabledef, flydata_ctl_table: create_flydata_ctl_table, schema_name: schema_name, ctl_only: opts.ctl_only?)
|
757
|
+
create_flydata_ctl_table = false
|
769
758
|
end
|
770
759
|
unless error_list.empty?
|
771
760
|
log_error_stderr("We have noticed the following error(s):")
|
@@ -781,7 +770,7 @@ EOM
|
|
781
770
|
tables_without_error = tables - error_list.inject([]){|arr, err| arr << err[:table] if err[:table]}
|
782
771
|
|
783
772
|
sync_fm = create_sync_file_manager(de)
|
784
|
-
sync_fm.
|
773
|
+
sync_fm.save_generated_ddl(tables_without_error, Mysql::TableDdl::VERSION)
|
785
774
|
sync_fm.close
|
786
775
|
end
|
787
776
|
|