mortar 0.15.31 → 0.15.32
Sign up to get free protection for your applications and to get access to all the features.
data/lib/mortar/command/local.rb
CHANGED
@@ -17,6 +17,7 @@
|
|
17
17
|
require "mortar/local/controller"
|
18
18
|
require "mortar/command/base"
|
19
19
|
require "mortar/generators/characterize_generator"
|
20
|
+
require "shellwords"
|
20
21
|
|
21
22
|
# run select pig commands on your local machine
|
22
23
|
#
|
@@ -78,10 +79,10 @@ class Mortar::Command::Local < Mortar::Command::Base
|
|
78
79
|
|
79
80
|
# local:characterize -f PARAMFILE
|
80
81
|
#
|
81
|
-
# Characterize will inspect your input data, inferring a schema and
|
82
|
+
# Characterize will inspect your input data, inferring a schema and
|
82
83
|
# generating keys, if needed. It will output CSV containing various
|
83
84
|
# statistics about your data (most common values, percent null, etc.)
|
84
|
-
#
|
85
|
+
#
|
85
86
|
# -f, --param-file PARAMFILE # Load pig parameter values from a file
|
86
87
|
# -g, --pigversion PIG_VERSION # Set pig version. Options are <PIG_VERSION_OPTIONS>.
|
87
88
|
#
|
@@ -217,7 +218,7 @@ class Mortar::Command::Local < Mortar::Command::Base
|
|
217
218
|
validate_arguments!
|
218
219
|
|
219
220
|
params = config_parameters.concat(pig_parameters)
|
220
|
-
|
221
|
+
|
221
222
|
ctrl = Mortar::Local::Controller.new
|
222
223
|
ctrl.repl(pig_version, params)
|
223
224
|
end
|
@@ -241,7 +242,7 @@ class Mortar::Command::Local < Mortar::Command::Base
|
|
241
242
|
unless script_name
|
242
243
|
error("Usage: mortar local:luigi SCRIPT\nMust specify SCRIPT.")
|
243
244
|
end
|
244
|
-
|
245
|
+
|
245
246
|
# cd into the project root
|
246
247
|
project_root = options[:project_root] ||= Dir.getwd
|
247
248
|
unless File.directory?(project_root)
|
@@ -250,7 +251,7 @@ class Mortar::Command::Local < Mortar::Command::Base
|
|
250
251
|
Dir.chdir(project_root)
|
251
252
|
|
252
253
|
script = validate_luigiscript!(script_name)
|
253
|
-
|
254
|
+
|
254
255
|
#Set git ref as environment variable for mortar-luigi to use when
|
255
256
|
#running a MortarTask
|
256
257
|
git_ref = sync_code_with_cloud()
|
@@ -286,6 +287,7 @@ class Mortar::Command::Local < Mortar::Command::Base
|
|
286
287
|
# -j, --jdbcdriver COM.DRIVER.BAR # Name of the JDBC driver class
|
287
288
|
# -d, --direct # Use a direct import path
|
288
289
|
# -r, --driverjar JARFILE # Path to the jar containing the jdbc driver
|
290
|
+
# -c, --jdbcconnectionstring CONNECTION_STRING # The JDBC connection string override
|
289
291
|
#
|
290
292
|
#Examples:
|
291
293
|
#
|
@@ -311,7 +313,7 @@ class Mortar::Command::Local < Mortar::Command::Base
|
|
311
313
|
validate_arguments!
|
312
314
|
|
313
315
|
dbhost = options[:host] || "localhost"
|
314
|
-
connstr = jdbc_conn(dbtype, dbhost, physdb)
|
316
|
+
connstr = Shellwords.escape(options[:jdbcconnectionstring] || jdbc_conn(dbtype, dbhost, physdb))
|
315
317
|
|
316
318
|
ctrl = Mortar::Local::Controller.new
|
317
319
|
ctrl.sqoop_export_table(pig_version, connstr, dbtable, s3dest, options)
|
@@ -327,6 +329,7 @@ class Mortar::Command::Local < Mortar::Command::Base
|
|
327
329
|
# -j, --jdbcdriver COM.DRIVER.BAR # Name of the JDBC driver class
|
328
330
|
# -d, --direct # Use a direct import path
|
329
331
|
# -r, --driverjar JARFILE # Path to the jar containing the jdbc driver
|
332
|
+
# -c, --jdbcconnectionstring CONNECTION_STRING # The JDBC connection string override
|
330
333
|
#
|
331
334
|
#Examples:
|
332
335
|
#
|
@@ -352,7 +355,7 @@ class Mortar::Command::Local < Mortar::Command::Base
|
|
352
355
|
validate_arguments!
|
353
356
|
|
354
357
|
dbhost = options[:host] || "localhost"
|
355
|
-
connstr = jdbc_conn(dbtype, dbhost, physdb)
|
358
|
+
connstr = Shellwords.escape(options[:jdbcconnectionstring] || jdbc_conn(dbtype, dbhost, physdb))
|
356
359
|
|
357
360
|
ctrl = Mortar::Local::Controller.new
|
358
361
|
ctrl.sqoop_export_query(pig_version, connstr, query, s3dest, options)
|
@@ -368,6 +371,7 @@ class Mortar::Command::Local < Mortar::Command::Base
|
|
368
371
|
# -j, --jdbcdriver COM.DRIVER.BAR # Name of the JDBC driver class
|
369
372
|
# -d, --direct # Use a direct import path
|
370
373
|
# -r, --driverjar JARFILE # Path to the jar containing the jdbc driver
|
374
|
+
# -c, --jdbcconnectionstring CONNECTION_STRING # The JDBC connection string override
|
371
375
|
#
|
372
376
|
#Examples:
|
373
377
|
#
|
@@ -401,7 +405,7 @@ class Mortar::Command::Local < Mortar::Command::Base
|
|
401
405
|
validate_arguments!
|
402
406
|
|
403
407
|
dbhost = options[:host] || "localhost"
|
404
|
-
connstr = jdbc_conn(dbtype, dbhost, physdb)
|
408
|
+
connstr = Shellwords.escape(options[:jdbcconnectionstring] || jdbc_conn(dbtype, dbhost, physdb))
|
405
409
|
|
406
410
|
ctrl = Mortar::Local::Controller.new
|
407
411
|
ctrl.sqoop_export_incremental(pig_version, connstr, table, column, max_value, s3dest, options)
|
@@ -26,8 +26,6 @@ mortar luigi luigiscripts/<%= project_name %>_luigi.py \
|
|
26
26
|
--output-base-path "s3://mortar-example-output-data/<your_username_here>/<%= project_name %>"
|
27
27
|
"""
|
28
28
|
|
29
|
-
MORTAR_PROJECT = '<%= project_name %>'
|
30
|
-
|
31
29
|
"""
|
32
30
|
This logger outputs logs to Mortar Logs. An example of it's usage can be seen
|
33
31
|
in the ShutdownClusters function.
|
@@ -71,12 +69,6 @@ class RunMyExamplePigScript(mortartask.MortarProjectPigscriptTask):
|
|
71
69
|
"""
|
72
70
|
return [S3PathTask(self.input_path)]
|
73
71
|
|
74
|
-
def project(self):
|
75
|
-
"""
|
76
|
-
Name of Mortar Project to run.
|
77
|
-
"""
|
78
|
-
return MORTAR_PROJECT
|
79
|
-
|
80
72
|
def script_output(self):
|
81
73
|
"""
|
82
74
|
The script_output method is how you define where the output from this task
|
data/lib/mortar/version.rb
CHANGED
@@ -19,6 +19,7 @@ require 'fakefs/spec_helpers'
|
|
19
19
|
require 'mortar/command/local'
|
20
20
|
require 'launchy'
|
21
21
|
require 'fileutils'
|
22
|
+
require 'shellwords'
|
22
23
|
|
23
24
|
module Mortar::Command
|
24
25
|
describe Local do
|
@@ -155,7 +156,7 @@ PARAMS
|
|
155
156
|
File.exists?("Test/macros/characterize_macro.pig").should be_false
|
156
157
|
File.exists?("Test/udfs/jython/top_5_tuple.py").should be_false
|
157
158
|
File.exists?("Test/controlscripts/lib/characterize_control.py").should be_false
|
158
|
-
File.delete("test.params")
|
159
|
+
File.delete("test.params")
|
159
160
|
end
|
160
161
|
|
161
162
|
end
|
@@ -397,7 +398,7 @@ STDERR
|
|
397
398
|
end
|
398
399
|
|
399
400
|
it "sends everything to the controller" do
|
400
|
-
connstr = "jdbc:mysql://foobar.com/mydb?zeroDateTimeBehavior=convertToNull"
|
401
|
+
connstr = Shellwords.escape("jdbc:mysql://foobar.com/mydb?zeroDateTimeBehavior=convertToNull")
|
401
402
|
dbtable = "customers"
|
402
403
|
s3dest = "s3n://a-bucket/a-directory"
|
403
404
|
any_instance_of(Mortar::Local::Controller) do |c|
|
@@ -407,7 +408,7 @@ STDERR
|
|
407
408
|
end
|
408
409
|
|
409
410
|
it "defaults to 'localhost' if no host specified" do
|
410
|
-
connstr = "jdbc:mysql://localhost/mydb?zeroDateTimeBehavior=convertToNull"
|
411
|
+
connstr = Shellwords.escape("jdbc:mysql://localhost/mydb?zeroDateTimeBehavior=convertToNull")
|
411
412
|
dbtable = "customers"
|
412
413
|
s3dest = "s3n://a-bucket/a-directory"
|
413
414
|
any_instance_of(Mortar::Local::Controller) do |c|
|
@@ -416,6 +417,16 @@ STDERR
|
|
416
417
|
stderr, stdout = execute "local:sqoop_table mysql mydb #{dbtable} #{s3dest}"
|
417
418
|
end
|
418
419
|
|
420
|
+
it "overrides the JDBC connection string if one is specified" do
|
421
|
+
connstr = Shellwords.escape("jdbc:mysql://localhost/mydbother?zeroDateTimeBehavior=convertToNull")
|
422
|
+
dbtable = "customers"
|
423
|
+
s3dest = "s3n://a-bucket/a-directory"
|
424
|
+
any_instance_of(Mortar::Local::Controller) do |c|
|
425
|
+
mock(c).sqoop_export_table(is_a(Mortar::PigVersion::Pig09), connstr, dbtable, s3dest, {})
|
426
|
+
end
|
427
|
+
stderr, stdout = execute "local:sqoop_table mysql mydb #{dbtable} #{s3dest} -c jdbc:mysql://localhost/mydbother?zeroDateTimeBehavior=convertToNull"
|
428
|
+
end
|
429
|
+
|
419
430
|
end
|
420
431
|
|
421
432
|
context "local:sqoop_query" do
|
@@ -452,7 +463,7 @@ STDERR
|
|
452
463
|
end
|
453
464
|
|
454
465
|
it "sends everything to the controller" do
|
455
|
-
connstr = "jdbc:mysql://foobar.com/mydb?zeroDateTimeBehavior=convertToNull"
|
466
|
+
connstr = Shellwords.escape("jdbc:mysql://foobar.com/mydb?zeroDateTimeBehavior=convertToNull")
|
456
467
|
query = "select_*_from_customers"
|
457
468
|
s3dest = "s3n://a-bucket/a-directory"
|
458
469
|
any_instance_of(Mortar::Local::Controller) do |c|
|
@@ -463,7 +474,7 @@ STDERR
|
|
463
474
|
end
|
464
475
|
|
465
476
|
it "defaults to 'localhost' if no host specified" do
|
466
|
-
connstr = "jdbc:mysql://localhost/mydb?zeroDateTimeBehavior=convertToNull"
|
477
|
+
connstr = Shellwords.escape("jdbc:mysql://localhost/mydb?zeroDateTimeBehavior=convertToNull")
|
467
478
|
query = "select_*_from_customers"
|
468
479
|
s3dest = "s3n://a-bucket/a-directory"
|
469
480
|
any_instance_of(Mortar::Local::Controller) do |c|
|
@@ -473,6 +484,17 @@ STDERR
|
|
473
484
|
stderr.should == ''
|
474
485
|
end
|
475
486
|
|
487
|
+
it "overrides the JDBC connection string if one is specified" do
|
488
|
+
connstr = Shellwords.escape("jdbc:mysql://localhost/mydbother?zeroDateTimeBehavior=convertToNull")
|
489
|
+
query = "select_*_from_customers"
|
490
|
+
s3dest = "s3n://a-bucket/a-directory"
|
491
|
+
any_instance_of(Mortar::Local::Controller) do |c|
|
492
|
+
mock(c).sqoop_export_query(is_a(Mortar::PigVersion::Pig09), connstr, query, s3dest, {})
|
493
|
+
end
|
494
|
+
stderr, stdout = execute "local:sqoop_query mysql mydb #{query} #{s3dest} -c jdbc:mysql://localhost/mydbother?zeroDateTimeBehavior=convertToNull"
|
495
|
+
stderr.should == ''
|
496
|
+
end
|
497
|
+
|
476
498
|
end
|
477
499
|
|
478
500
|
context "local:sqoop_incremental" do
|
@@ -525,7 +547,7 @@ STDERR
|
|
525
547
|
end
|
526
548
|
|
527
549
|
it "sends everything to the controller" do
|
528
|
-
connstr = "jdbc:mysql://foobar.com/mydb?zeroDateTimeBehavior=convertToNull"
|
550
|
+
connstr = Shellwords.escape("jdbc:mysql://foobar.com/mydb?zeroDateTimeBehavior=convertToNull")
|
529
551
|
dbtable = "customers"
|
530
552
|
column = "customer_id"
|
531
553
|
column_value = "12345"
|
@@ -537,7 +559,7 @@ STDERR
|
|
537
559
|
end
|
538
560
|
|
539
561
|
it "defaults to 'localhost' if no host specified" do
|
540
|
-
connstr = "jdbc:mysql://localhost/mydb?zeroDateTimeBehavior=convertToNull"
|
562
|
+
connstr = Shellwords.escape("jdbc:mysql://localhost/mydb?zeroDateTimeBehavior=convertToNull")
|
541
563
|
dbtable = "customers"
|
542
564
|
column = "customer_id"
|
543
565
|
column_value = "12345"
|
@@ -548,10 +570,21 @@ STDERR
|
|
548
570
|
stderr, stdout = execute "local:sqoop_incremental mysql mydb #{dbtable} #{column} #{column_value} #{s3dest}"
|
549
571
|
end
|
550
572
|
|
573
|
+
it "overrides the JDBC connection string if one is specified" do
|
574
|
+
connstr = Shellwords.escape("jdbc:mysql://localhost/mydbother?zeroDateTimeBehavior=convertToNull")
|
575
|
+
dbtable = "customers"
|
576
|
+
column = "customer_id"
|
577
|
+
column_value = "12345"
|
578
|
+
s3dest = "s3n://a-bucket/a-directory"
|
579
|
+
any_instance_of(Mortar::Local::Controller) do |c|
|
580
|
+
mock(c).sqoop_export_incremental(is_a(Mortar::PigVersion::Pig09), connstr, dbtable, column, column_value, s3dest, {})
|
581
|
+
end
|
582
|
+
stderr, stdout = execute "local:sqoop_incremental mysql mydb #{dbtable} #{column} #{column_value} #{s3dest} -c jdbc:mysql://localhost/mydbother?zeroDateTimeBehavior=convertToNull"
|
583
|
+
end
|
584
|
+
|
551
585
|
end
|
552
586
|
|
553
587
|
|
554
588
|
|
555
589
|
end
|
556
590
|
end
|
557
|
-
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mortar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 99
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 15
|
9
|
-
-
|
10
|
-
version: 0.15.
|
9
|
+
- 32
|
10
|
+
version: 0.15.32
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mortar Data
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2014-
|
18
|
+
date: 2014-11-11 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rdoc
|