Class: Bricolage::StreamingLoad::JobParams
- Inherits:
-
Object
- Object
- Bricolage::StreamingLoad::JobParams
- Defined in:
- lib/bricolage/streamingload/jobparams.rb
Class Method Summary collapse
- .find_job_file(ctx, schema, table) ⇒ Object
- .load(ctx, job_class, schema, table) ⇒ Object
- .load_bricolage_job(ctx, job_class, schema, table) ⇒ Object
Instance Method Summary collapse
- #ctl_bucket ⇒ Object
- #dest_table ⇒ Object
- #ds ⇒ Object
- #enable_work_table? ⇒ Boolean
-
#initialize(job) ⇒ JobParams
constructor
A new instance of JobParams.
- #load_options_string ⇒ Object
- #sql_source ⇒ Object
- #work_table ⇒ Object
Constructor Details
#initialize(job) ⇒ JobParams
Returns a new instance of JobParams.
42 43 44 45 |
# File 'lib/bricolage/streamingload/jobparams.rb', line 42 def initialize(job) @job = job @params = job.params end |
Class Method Details
.find_job_file(ctx, schema, table) ⇒ Object
32 33 34 35 |
# File 'lib/bricolage/streamingload/jobparams.rb', line 32 def JobParams.find_job_file(ctx, schema, table) paths = Dir.glob("#{ctx.home_path}/#{schema}/#{table}.*") paths.select {|path| File.extname(path) == '.job' }.sort.first end |
.load(ctx, job_class, schema, table) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/bricolage/streamingload/jobparams.rb', line 11 def JobParams.load(ctx, job_class, schema, table) job = load_bricolage_job(ctx, job_class, schema, table) schema = resolve_schema(ctx, schema) job.provide_default 'dest-table', "#{schema}.#{table}" #job.provide_sql_file_by_job_id # FIXME: provide only when exist job.compile new(job) end |
.load_bricolage_job(ctx, job_class, schema, table) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/bricolage/streamingload/jobparams.rb', line 20 def JobParams.load_bricolage_job(ctx, job_class, schema, table) if job_file = find_job_file(ctx, schema, table) ctx.logger.debug "using .job file: #{job_file}" Bricolage::Job.load_file(job_file, ctx.subsystem(schema)) else ctx.logger.debug "using default job parameters (no .job file)" Bricolage::Job.instantiate(table, job_class, ctx).tap {|job| job.bind_parameters({}) } end end |
Instance Method Details
#ctl_bucket ⇒ Object
51 52 53 |
# File 'lib/bricolage/streamingload/jobparams.rb', line 51 def ctl_bucket @params['ctl-ds'] end |
#dest_table ⇒ Object
63 64 65 |
# File 'lib/bricolage/streamingload/jobparams.rb', line 63 def dest_table @params['dest-table'] end |
#ds ⇒ Object
47 48 49 |
# File 'lib/bricolage/streamingload/jobparams.rb', line 47 def ds @params['redshift-ds'] end |
#enable_work_table? ⇒ Boolean
55 56 57 |
# File 'lib/bricolage/streamingload/jobparams.rb', line 55 def enable_work_table? !!@params['work-table'] end |
#load_options_string ⇒ Object
67 68 69 |
# File 'lib/bricolage/streamingload/jobparams.rb', line 67 def @params['load-options'].to_s end |
#sql_source ⇒ Object
71 72 73 74 |
# File 'lib/bricolage/streamingload/jobparams.rb', line 71 def sql_source sql = @params['sql-file'] sql ? sql.source : "insert into #{dest_table} select * from #{work_table};" end |
#work_table ⇒ Object
59 60 61 |
# File 'lib/bricolage/streamingload/jobparams.rb', line 59 def work_table @params['work-table'] end |