Module: JDBCHelper::Athena

Extended by:
Connector
Defined in:
lib/jdbc_helper/athena.rb

Constant Summary collapse

DRIVER_NAME =
"com.amazonaws.athena.jdbc.AthenaDriver".freeze

Class Method Summary collapse

Class Method Details

.configure_driver_path(class_path) ⇒ Object



22
23
24
25
26
27
# File 'lib/jdbc_helper/athena.rb', line 22

def self.configure_driver_path(class_path)
  paths = ENV["CLASSPATH"].to_s.split(":")
  paths << class_path

  ENV["CLASSPATH"] = paths.uniq.join(":")
end

.connect(key: nil, secret: nil, region: "us-east-1", s3_staging_dir: nil, extra_params: {}, &block) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/jdbc_helper/athena.rb', line 13

def self.connect(key: nil, secret: nil, region: "us-east-1", s3_staging_dir: nil, extra_params: {}, &block)
  connect_impl :athena, {
    url: "jdbc:awsathena://athena.#{region}.amazonaws.com:443",
    user: key || ENV["AWS_ACCESS_KEY"],
    password: secret || ENV['AWS_SECRET_KEY'],
    s3_staging_dir: s3_uri(s3_staging_dir || ENV["ATHENA_S3_STAGING_DIR"])
  }, {}, &block
end

.s3_uri(path) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/jdbc_helper/athena.rb', line 29

def self.s3_uri(path)
  return path if path.to_s.start_with?("s3://")

  path = "s3://#{path}"
  path = path + "/" unless path.end_with?("/")

  path
end