infobright-loader 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +19 -0
  3. data/LICENSE-2.0.txt +202 -0
  4. data/README.md +232 -0
  5. data/Rakefile +2 -0
  6. data/bin/infobright-loader +45 -0
  7. data/control-file/template.yml +23 -0
  8. data/infobright-loader.gemspec +35 -0
  9. data/lib/infobright-loader.rb +5 -0
  10. data/lib/infobright-loader/cli/config.rb +204 -0
  11. data/lib/infobright-loader/cli/loader.rb +66 -0
  12. data/lib/infobright-loader/db.rb +90 -0
  13. data/lib/infobright-loader/loader.rb +175 -0
  14. data/lib/infobright-loader/version.rb +4 -0
  15. data/tests/manual/bad-files/.gitignore +1 -0
  16. data/tests/manual/bad-files/control-file-raw.yml +50 -0
  17. data/tests/manual/bad-files/data/b/b_1.txt +6 -0
  18. data/tests/manual/bad-files/data/b/b_2.txt +6 -0
  19. data/tests/manual/bad-files/data/b/b_3.txt +6 -0
  20. data/tests/manual/bad-files/data/b/b_4.txt +6 -0
  21. data/tests/manual/bad-files/data/b/b_5.txt +6 -0
  22. data/tests/manual/bad-files/data/b/b_6.txt +6 -0
  23. data/tests/manual/bad-files/data/c/c_1.txt +6 -0
  24. data/tests/manual/bad-files/data/c/c_2.txt +6 -0
  25. data/tests/manual/bad-files/data/c/c_3.txt +6 -0
  26. data/tests/manual/bad-files/data/c/c_4.txt +6 -0
  27. data/tests/manual/bad-files/data/c/c_5.txt +6 -0
  28. data/tests/manual/bad-files/data/c/c_6.txt +6 -0
  29. data/tests/manual/bad-files/data/d/d_1.txt +6 -0
  30. data/tests/manual/bad-files/data/d/d_2.txt +6 -0
  31. data/tests/manual/bad-files/data/d/d_3.txt +6 -0
  32. data/tests/manual/bad-files/data/d/d_4.txt +6 -0
  33. data/tests/manual/bad-files/data/d/d_5.txt +6 -0
  34. data/tests/manual/bad-files/data/d/d_6.txt +6 -0
  35. data/tests/manual/bad-files/data/e/e_1.txt +6 -0
  36. data/tests/manual/bad-files/data/e/e_2.txt +6 -0
  37. data/tests/manual/bad-files/data/e/e_3.txt +6 -0
  38. data/tests/manual/bad-files/data/e/e_4.txt +6 -0
  39. data/tests/manual/bad-files/data/e/e_5.txt +6 -0
  40. data/tests/manual/bad-files/data/e/e_6.txt +6 -0
  41. data/tests/manual/bad-files/data/f/f_1.txt +6 -0
  42. data/tests/manual/bad-files/data/f/f_2.txt +6 -0
  43. data/tests/manual/bad-files/data/f/f_3.txt +6 -0
  44. data/tests/manual/bad-files/data/f/f_4.txt +6 -0
  45. data/tests/manual/bad-files/data/f/f_5.txt +6 -0
  46. data/tests/manual/bad-files/data/f/f_6.txt +6 -0
  47. data/tests/manual/bad-files/run_test.sh +40 -0
  48. data/tests/manual/bad-files/setup.sql +8 -0
  49. data/tests/manual/bad-files/verify.sql +10 -0
  50. data/tests/manual/control-file/.gitignore +1 -0
  51. data/tests/manual/control-file/control-file-raw.yml +50 -0
  52. data/tests/manual/control-file/data/b/b_1.txt +6 -0
  53. data/tests/manual/control-file/data/b/b_2.txt +6 -0
  54. data/tests/manual/control-file/data/b/b_3.txt +6 -0
  55. data/tests/manual/control-file/data/b/b_4.txt +6 -0
  56. data/tests/manual/control-file/data/b/b_5.txt +6 -0
  57. data/tests/manual/control-file/data/b/b_6.txt +6 -0
  58. data/tests/manual/control-file/data/c/c_1.txt +6 -0
  59. data/tests/manual/control-file/data/c/c_2.txt +6 -0
  60. data/tests/manual/control-file/data/c/c_3.txt +6 -0
  61. data/tests/manual/control-file/data/c/c_4.txt +6 -0
  62. data/tests/manual/control-file/data/c/c_5.txt +6 -0
  63. data/tests/manual/control-file/data/c/c_6.txt +6 -0
  64. data/tests/manual/control-file/data/d/d_1.txt +6 -0
  65. data/tests/manual/control-file/data/d/d_2.txt +6 -0
  66. data/tests/manual/control-file/data/d/d_3.txt +6 -0
  67. data/tests/manual/control-file/data/d/d_4.txt +6 -0
  68. data/tests/manual/control-file/data/d/d_5.txt +6 -0
  69. data/tests/manual/control-file/data/d/d_6.txt +6 -0
  70. data/tests/manual/control-file/data/e/e_1.txt +6 -0
  71. data/tests/manual/control-file/data/e/e_2.txt +6 -0
  72. data/tests/manual/control-file/data/e/e_3.txt +6 -0
  73. data/tests/manual/control-file/data/e/e_4.txt +6 -0
  74. data/tests/manual/control-file/data/e/e_5.txt +6 -0
  75. data/tests/manual/control-file/data/e/e_6.txt +6 -0
  76. data/tests/manual/control-file/data/f/f_1.txt +6 -0
  77. data/tests/manual/control-file/data/f/f_2.txt +6 -0
  78. data/tests/manual/control-file/data/f/f_3.txt +6 -0
  79. data/tests/manual/control-file/data/f/f_4.txt +6 -0
  80. data/tests/manual/control-file/data/f/f_5.txt +6 -0
  81. data/tests/manual/control-file/data/f/f_6.txt +6 -0
  82. data/tests/manual/control-file/run_test.sh +40 -0
  83. data/tests/manual/control-file/setup.sql +8 -0
  84. data/tests/manual/control-file/verify.sql +10 -0
  85. data/tests/manual/folder/data/a/a_1.txt +6 -0
  86. data/tests/manual/folder/data/a/a_2.txt +6 -0
  87. data/tests/manual/folder/data/a/a_3.txt +6 -0
  88. data/tests/manual/folder/data/a/a_4.txt +6 -0
  89. data/tests/manual/folder/data/a/a_5.txt +6 -0
  90. data/tests/manual/folder/data/a/a_6.txt +6 -0
  91. data/tests/manual/folder/run_test.sh +37 -0
  92. data/tests/manual/folder/setup.sql +4 -0
  93. data/tests/manual/folder/verify.sql +2 -0
  94. metadata +158 -0
@@ -0,0 +1,6 @@
1
+ "19"|"F.19"
2
+ "20"|"F.20"
3
+ "21"|"F.21"
4
+ "22"|"F.22"
5
+ "23"|"F.23"
6
+ "24"|"F.24"
@@ -0,0 +1,6 @@
1
+ "25"|"F.25"
2
+ "26"|"F.26"
3
+ "27"|"F.27"
4
+ "28"|"F.28"
5
+ "29"|"F.29"
6
+ "30"|"F.30"
@@ -0,0 +1,6 @@
1
+ "31"|"F.31"
2
+ "32"|"F.32"
3
+ "33"|"F.33"
4
+ "34"|"F.34"
5
+ "35"|"F.35"
6
+ "36"|"F.36"
@@ -0,0 +1,40 @@
1
+ #!/bin/bash
2
+ # Copyright (c) 2012 SnowPlow Analytics Ltd. All rights reserved.
3
+ #
4
+ # This program is licensed to you under the Apache License Version 2.0,
5
+ # and you may not use this file except in compliance with the Apache License Version 2.0.
6
+ # You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
7
+ #
8
+ # Unless required by applicable law or agreed to in writing,
9
+ # software distributed under the Apache License Version 2.0 is distributed on an
10
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ # See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
12
+
13
+ # Author:: Alex Dean (mailto:support@snowplowanalytics.com)
14
+ # Copyright:: Copyright (c) 2012 SnowPlow Analytics Ltd
15
+ # License:: Apache License Version 2.0
16
+
17
+ # input parameters
18
+ if [ $# != 2 ]; then
19
+ echo; echo 'syntax: '$0' <username> <password>'; echo
20
+ exit 1
21
+ else
22
+ # assign parameters
23
+ USERNAME=$1
24
+ PASSWORD=$2
25
+ fi
26
+
27
+ echo "Running folder-based test..."
28
+ SQL=`locate mysql-ib`
29
+ PWD=`pwd`
30
+
31
+ echo "Setting up Infobright"
32
+ cat setup.sql | ${SQL} -u ${USERNAME} --password=${PASSWORD}
33
+
34
+ echo "Running Infobright Ruby Loader in control file mode"
35
+ sed "s|<<USERNAME>>|$USERNAME|;s|<<PASSWORD>>|$PASSWORD|;s|<<PATH>>|$PWD|" ./control-file-raw.yml > ./control-file-out.yml
36
+ bundle exec infobright-loader -c control-file-out.yml -d irl_tests -e \" # Override a couple of args to test that too
37
+ rm ./control-file-out.yml
38
+
39
+ echo "Verifying the load into Infobright - please visually inspect:"
40
+ cat verify.sql | ${SQL} -u ${USERNAME} --password=${PASSWORD}
@@ -0,0 +1,8 @@
1
+ drop database if exists irl_tests;
2
+ create database irl_tests;
3
+ use irl_tests;
4
+ create table b (id int, description varchar(255)) engine=brighthouse;
5
+ create table c (id int, description varchar(255)) engine=brighthouse;
6
+ create table d (id int, description varchar(255)) engine=brighthouse;
7
+ create table e (id int, description varchar(255)) engine=brighthouse;
8
+ create table f (id int, description varchar(255)) engine=brighthouse;
@@ -0,0 +1,10 @@
1
+ use irl_tests;
2
+
3
+ -- We should be able to make a nice table joining up all the rows in each table
4
+ select b.id as row, b.description as b_desc, c.description as c_desc, d.description as d_desc, e.description as e_desc, f.description as f_desc
5
+ from b
6
+ left join c on b.id = c.id
7
+ left join d on b.id = d.id
8
+ left join e on b.id = e.id
9
+ left join f on b.id = f.id
10
+ order by b.id;
@@ -0,0 +1 @@
1
+ control-file-out.yml
@@ -0,0 +1,50 @@
1
+ # Control file for Infobright Ruby Loader control file test
2
+ #
3
+ # Is processed with sed to finalise <<x>> variables before
4
+ # the test is run
5
+
6
+ :load:
7
+ :processes: 3 # Test with 3 processes populating 5 tables
8
+ :database:
9
+ :name: wrong # Will override at the command line to irl_tests
10
+ :username: <<USERNAME>>
11
+ :password: <<PASSWORD>>
12
+ :data_format:
13
+ :separator: \|
14
+ :encloser: \' # Will override at the command line to "
15
+ :data_loads:
16
+ b:
17
+ - <<PATH>>/data/b/b_1.txt
18
+ - <<PATH>>/data/b/b_2.txt
19
+ - <<PATH>>/data/b/b_3.txt
20
+ - <<PATH>>/data/b/b_4.txt
21
+ - <<PATH>>/data/b/b_5.txt
22
+ - <<PATH>>/data/b/b_6.txt
23
+ c:
24
+ - <<PATH>>/data/c/c_1.txt
25
+ - <<PATH>>/data/c/c_2.txt
26
+ - <<PATH>>/data/c/c_3.txt
27
+ - <<PATH>>/data/c/c_4.txt
28
+ - <<PATH>>/data/c/c_5.txt
29
+ - <<PATH>>/data/c/c_6.txt
30
+ d:
31
+ - <<PATH>>/data/d/d_1.txt
32
+ - <<PATH>>/data/d/d_2.txt
33
+ - <<PATH>>/data/d/d_3.txt
34
+ - <<PATH>>/data/d/d_4.txt
35
+ - <<PATH>>/data/d/d_5.txt
36
+ - <<PATH>>/data/d/d_6.txt
37
+ e:
38
+ - <<PATH>>/data/e/e_1.txt
39
+ - <<PATH>>/data/e/e_2.txt
40
+ - <<PATH>>/data/e/e_3.txt
41
+ - <<PATH>>/data/e/e_4.txt
42
+ - <<PATH>>/data/e/e_5.txt
43
+ - <<PATH>>/data/e/e_6.txt
44
+ f:
45
+ - <<PATH>>/data/f/f_1.txt
46
+ - <<PATH>>/data/f/f_2.txt
47
+ - <<PATH>>/data/f/f_3.txt
48
+ - <<PATH>>/data/f/f_4.txt
49
+ - <<PATH>>/data/f/f_5.txt
50
+ - <<PATH>>/data/f/f_6.txt
@@ -0,0 +1,6 @@
1
+ "1"|"B.1"
2
+ "2"|"B.2"
3
+ "3"|"B.3"
4
+ "4"|"B.4"
5
+ "5"|"B.5"
6
+ "6"|"B.6"
@@ -0,0 +1,6 @@
1
+ "7"|"B.7"
2
+ "8"|"B.8"
3
+ "9"|"B.9"
4
+ "10"|"B.10"
5
+ "11"|"B.11"
6
+ "12"|"B.12"
@@ -0,0 +1,6 @@
1
+ "13"|"B.13"
2
+ "14"|"B.14"
3
+ "15"|"B.15"
4
+ "16"|"B.16"
5
+ "17"|"B.17"
6
+ "18"|"B.18"
@@ -0,0 +1,6 @@
1
+ "19"|"B.19"
2
+ "20"|"B.20"
3
+ "21"|"B.21"
4
+ "22"|"B.22"
5
+ "23"|"B.23"
6
+ "24"|"B.24"
@@ -0,0 +1,6 @@
1
+ "25"|"B.25"
2
+ "26"|"B.26"
3
+ "27"|"B.27"
4
+ "28"|"B.28"
5
+ "29"|"B.29"
6
+ "30"|"B.30"
@@ -0,0 +1,6 @@
1
+ "31"|"B.31"
2
+ "32"|"B.32"
3
+ "33"|"B.33"
4
+ "34"|"B.34"
5
+ "35"|"B.35"
6
+ "36"|"B.36"
@@ -0,0 +1,6 @@
1
+ "1"|"C.1"
2
+ "2"|"C.2"
3
+ "3"|"C.3"
4
+ "4"|"C.4"
5
+ "5"|"C.5"
6
+ "6"|"C.6"
@@ -0,0 +1,6 @@
1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|"F.22"
5
+ "23"|"F.23"
6
+ "24"|"F.24"
@@ -0,0 +1,6 @@
1
+ "25"|"F.25"
2
+ "26"|"F.26"
3
+ "27"|"F.27"
4
+ "28"|"F.28"
5
+ "29"|"F.29"
6
+ "30"|"F.30"
@@ -0,0 +1,6 @@
1
+ "31"|"F.31"
2
+ "32"|"F.32"
3
+ "33"|"F.33"
4
+ "34"|"F.34"
5
+ "35"|"F.35"
6
+ "36"|"F.36"
@@ -0,0 +1,40 @@
1
+ #!/bin/bash
2
+ # Copyright (c) 2012 SnowPlow Analytics Ltd. All rights reserved.
3
+ #
4
+ # This program is licensed to you under the Apache License Version 2.0,
5
+ # and you may not use this file except in compliance with the Apache License Version 2.0.
6
+ # You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
7
+ #
8
+ # Unless required by applicable law or agreed to in writing,
9
+ # software distributed under the Apache License Version 2.0 is distributed on an
10
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ # See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
12
+
13
+ # Author:: Alex Dean (mailto:support@snowplowanalytics.com)
14
+ # Copyright:: Copyright (c) 2012 SnowPlow Analytics Ltd
15
+ # License:: Apache License Version 2.0
16
+
17
+ # input parameters
18
+ if [ $# != 2 ]; then
19
+ echo; echo 'syntax: '$0' <username> <password>'; echo
20
+ exit 1
21
+ else
22
+ # assign parameters
23
+ USERNAME=$1
24
+ PASSWORD=$2
25
+ fi
26
+
27
+ echo "Running folder-based test..."
28
+ SQL=`locate mysql-ib`
29
+ PWD=`pwd`
30
+
31
+ echo "Setting up Infobright"
32
+ cat setup.sql | ${SQL} -u ${USERNAME} --password=${PASSWORD}
33
+
34
+ echo "Running Infobright Ruby Loader in control file mode"
35
+ sed "s|<<USERNAME>>|$USERNAME|;s|<<PASSWORD>>|$PASSWORD|;s|<<PATH>>|$PWD|" ./control-file-raw.yml > ./control-file-out.yml
36
+ bundle exec infobright-loader -c control-file-out.yml -d irl_tests -e \" # Override a couple of args to test that too
37
+ rm ./control-file-out.yml
38
+
39
+ echo "Verifying the load into Infobright - please visually inspect:"
40
+ cat verify.sql | ${SQL} -u ${USERNAME} --password=${PASSWORD}
@@ -0,0 +1,8 @@
1
+ drop database if exists irl_tests;
2
+ create database irl_tests;
3
+ use irl_tests;
4
+ create table b (id int, description varchar(255)) engine=brighthouse;
5
+ create table c (id int, description varchar(255)) engine=brighthouse;
6
+ create table d (id int, description varchar(255)) engine=brighthouse;
7
+ create table e (id int, description varchar(255)) engine=brighthouse;
8
+ create table f (id int, description varchar(255)) engine=brighthouse;
@@ -0,0 +1,10 @@
1
+ use irl_tests;
2
+
3
+ -- We should be able to make a nice table joining up all the rows in each table
4
+ select b.id as row, b.description as b_desc, c.description as c_desc, d.description as d_desc, e.description as e_desc, f.description as f_desc
5
+ from b
6
+ left join c on b.id = c.id
7
+ left join d on b.id = d.id
8
+ left join e on b.id = e.id
9
+ left join f on b.id = f.id
10
+ order by b.id;
@@ -0,0 +1,6 @@
1
+ "1"|"row 1"
2
+ "2"|"row 2"
3
+ "3"|"row 3"
4
+ "4"|"row 4"
5
+ "5"|"row 5"
6
+ "6"|"row 6"