class Sequel::Rbhive::Database
Constants
- CONVERSION_PROCS
- DatasetClass
- DisconnectExceptions
- NullLogger
- RbhiveExceptions
Exception classes used by
Impala
.
Attributes
conversion_procs[R]
Public Instance Methods
connect(server)
click to toggle source
Connect to the Impala
server. Currently, only the :host and :port options are respected, and they default to 'localhost' and 21000, respectively.
# File lib/sequel/adapters/rbhive.rb 55 def connect(server) 56 opts = server_opts(server) 57 opts[:hive_version] ||= 12 58 conn = RBHive::TCLIConnection.new(opts[:host]||'localhost', opts[:port]||21050, opts, opts[:hive_logger] || NullLogger) 59 conn.open 60 conn.open_session 61 conn 62 end
database_error_classes()
click to toggle source
# File lib/sequel/adapters/rbhive.rb 64 def database_error_classes 65 RbhiveExceptions 66 end
disconnect_connection(connection)
click to toggle source
# File lib/sequel/adapters/rbhive.rb 68 def disconnect_connection(connection) 69 connection.close_session if connection.session 70 connection.close 71 rescue *DisconnectExceptions 72 end
execute(sql, opts=OPTS) { |c, r| ... }
click to toggle source
# File lib/sequel/adapters/rbhive.rb 74 def execute(sql, opts=OPTS) 75 synchronize(opts[:server]) do |c| 76 begin 77 puts sql 78 r = log_yield(sql){c.execute(sql)} 79 yield(c, r) if block_given? 80 nil 81 rescue *RbhiveExceptions => e 82 raise_error(e) 83 end 84 end 85 end
Private Instance Methods
adapter_initialize()
click to toggle source
# File lib/sequel/adapters/rbhive.rb 89 def adapter_initialize 90 @conversion_procs = CONVERSION_PROCS.dup 91 @conversion_procs[8] = method(:to_application_timestamp) 92 end
connection_execute_method()
click to toggle source
# File lib/sequel/adapters/rbhive.rb 94 def connection_execute_method 95 :execute 96 end
disconnect_error?(exception, opts)
click to toggle source
Impala
raises IOError if it detects a problem on the connection, and in most cases that results in an unusable connection, so treat it as a disconnect error so Sequel
will reconnect.
Calls superclass method
# File lib/sequel/adapters/rbhive.rb 101 def disconnect_error?(exception, opts) 102 case exception 103 when *DisconnectExceptions 104 true 105 else 106 super 107 end 108 end
schema_parse_table(table_name, opts)
click to toggle source
Use DESCRIBE to get the column names and types for the table.
# File lib/sequel/adapters/rbhive.rb 111 def schema_parse_table(table_name, opts) 112 m = output_identifier_meth(opts[:dataset]) 113 114 table = if opts[:schema] 115 Sequel.qualify(opts[:schema], table_name) 116 else 117 Sequel.identifier(table_name) 118 end 119 120 describe(table, opts).map do |row| 121 row[:db_type] = row[:type] 122 row[:type] = schema_column_type(row[:db_type]) 123 row[:default] = nil 124 row[:primary_key] = false 125 [m.call(row.delete(:name)), row] 126 end 127 end