Class: Hadupils::Runners::Hive

Inherits:
Base
  • Object
show all
Defined in:
lib/hadupils/runners.rb

Class Attribute Summary collapse

Attributes inherited from Base

#last_status, #last_stderr, #last_stdout, #params

Instance Method Summary collapse

Methods inherited from Base

#execute!, #last_exitstatus, run, #wait!

Constructor Details

#initialize(params, hive_aux_jars_path = '') ⇒ Hive

Returns a new instance of Hive.



76
77
78
79
# File 'lib/hadupils/runners.rb', line 76

def initialize(params, hive_aux_jars_path='')
  super(params)
  @hive_aux_jars_path = hive_aux_jars_path
end

Class Attribute Details

.base_runnerObject



81
82
83
# File 'lib/hadupils/runners.rb', line 81

def self.base_runner
  @base_runner || ::File.join(ENV['HIVE_HOME'], 'bin', 'hive')
end

Instance Method Details

#commandObject



85
86
87
88
89
90
91
92
93
# File 'lib/hadupils/runners.rb', line 85

def command
  params.inject([env_overrides, self.class.base_runner]) do |result, param|
    if param.respond_to? :hive_opts
      result + param.hive_opts
    else
      result << param
    end
  end
end

#env_overridesObject



95
96
97
98
99
100
101
102
103
104
# File 'lib/hadupils/runners.rb', line 95

def env_overrides
  env = {}
  settings = [@hive_aux_jars_path, ::ENV['HIVE_AUX_JARS_PATH']].reject do |val|
    val.nil? || val.strip.empty?
  end
  if settings.length > 0
    env['HIVE_AUX_JARS_PATH'] = settings.join(',')
  end
  env
end