Module: Impala

Defined in:
lib/impala.rb,
lib/impala/cursor.rb,
lib/impala/version.rb,
lib/impala/protocol.rb,
lib/impala/connection.rb,
lib/impala/sasl_transport.rb,
lib/impala/protocol/fb303_types.rb,
lib/impala/protocol/status_types.rb,
lib/impala/protocol/beeswax_types.rb,
lib/impala/protocol/impala_service.rb,
lib/impala/protocol/beeswax_service.rb,
lib/impala/protocol/fb303_constants.rb,
lib/impala/protocol/t_c_l_i_service.rb,
lib/impala/protocol/facebook_service.rb,
lib/impala/protocol/status_constants.rb,
lib/impala/protocol/beeswax_constants.rb,
lib/impala/protocol/cli_service_types.rb,
lib/impala/protocol/hive_metastore_types.rb,
lib/impala/protocol/impala_service_types.rb,
lib/impala/protocol/cli_service_constants.rb,
lib/impala/protocol/thrift_hive_metastore.rb,
lib/impala/protocol/hive_metastore_constants.rb,
lib/impala/protocol/impala_service_constants.rb,
lib/impala/protocol/impala_hive_server2_service.rb

Defined Under Namespace

Modules: Protocol Classes: Connection, ConnectionError, Cursor, CursorError, InvalidQueryError, ParsingError, SASLTransport, SASLTransportFactory

Constant Summary collapse

DEFAULT_HOST =
'localhost'
DEFAULT_PORT =
21000
VERSION =
"0.5.1"

Class Method Summary collapse

Class Method Details

.connect(host = DEFAULT_HOST, port = DEFAULT_PORT, options = {}) {|conn| ... } ⇒ Connection

Connect to an Impala server. If a block is given, it will close the

connection after yielding the connection to the block.

Parameters:

  • host (String) (defaults to: DEFAULT_HOST)

    the hostname or IP address of the Impala server

  • port (int) (defaults to: DEFAULT_PORT)

    the port that the Impala server is listening on

  • options (Hash) (defaults to: {})

    connection options

Options Hash (options):

  • :timeout (int)

    the timeout in seconds to use when connecting

  • :sasl (Hash)

    if present, used to connect with SASL PLAIN authentication. Should have two properties:

    • :username (String)

    • :password (String)

  • :kerberos (Hash)

    if present, used to connect with SASL GSSAPI authentication using whatever context is available. Should have two properties:

    • :host (String)

    • :provider (String)

Yield Parameters:

  • conn (Connection)

    the open connection. Will be closed once the block finishes

Returns:

  • (Connection)

    the open connection, or, if a block is passed, the return value of the block



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/impala.rb', line 44

def self.connect(host=DEFAULT_HOST, port=DEFAULT_PORT, options={})
  connection = Connection.new(host, port, options)

  if block_given?
    begin
      ret = yield connection
    ensure
      connection.close
    end
  else
    ret = connection
  end

  ret
end