Class: Embulk::Input::Presto::ExplainParser

Inherits:
Object
  • Object
show all
Defined in:
lib/embulk/input/presto/explain_parser.rb

Class Method Summary collapse

Class Method Details

.parse(explain_result) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/embulk/input/presto/explain_parser.rb', line 5

def self.parse(explain_result)
  explain_text = explain_result.flatten.last.lines.first
  column_name_raw, column_type_raw = explain_text.split(' => ')
  names = column_name_raw.split('[').last.split(']').first.split(',').map{ |name| name.strip }
  types = column_type_raw.split('[').last.split(']').first.gsub(/\(.+?\)/, "").split(',').map{ |info| info.split(':').last }
  names.zip(types)
end