class AmazonAthena::Client
Public Class Methods
new(key: nil, secret: nil, region: "us-east-1", s3_staging_dir: nil)
click to toggle source
# File lib/amazon_athena/client.rb, line 12 def initialize(key: nil, secret: nil, region: "us-east-1", s3_staging_dir: nil) @key = key || ENV["AWS_ACCESS_KEY"] @secret = secret || ENV['AWS_SECRET_KEY'] @region = region @s3_staging_dir = s3_staging_dir || ENV["ATHENA_S3_STAGING_DIR"] end
Public Instance Methods
connection()
click to toggle source
# File lib/amazon_athena/client.rb, line 97 def connection return @connection if defined?(@connection) && !@connection.closed? @connection = JDBCHelper::Athena.connect( key: @key, secret: @secret, region: @region, s3_staging_dir: @s3_staging_dir ) end
database_create(name:, location: nil, comment: nil, properties: {})
click to toggle source
# File lib/amazon_athena/client.rb, line 31 def database_create(name:, location: nil, comment: nil, properties: {}) cmd = AmazonAthena::Commands::CreateDatabase.new( name: name, location: location, comment: comment, properties: properties ) run(cmd) end
database_drop(database)
click to toggle source
# File lib/amazon_athena/client.rb, line 25 def database_drop(database) cmd = AmazonAthena::Commands::DropDatabase.new(database) run(cmd) end
databases()
click to toggle source
# File lib/amazon_athena/client.rb, line 19 def databases cmd = AmazonAthena::Commands::ShowDatabases.new run(cmd) end
partitions(table)
click to toggle source
# File lib/amazon_athena/client.rb, line 85 def partitions(table) cmd = AmazonAthena::Commands::ShowPartitions.new(database_table) run(cmd) end
partitions_drop(database_table, partitions_expression)
click to toggle source
# File lib/amazon_athena/client.rb, line 91 def partitions_drop(database_table, partitions_expression) cmd = AmazonAthena::Commands::DropPartition.new(database_table, partitions) run(cmd) end
run(cmd, preview = false)
click to toggle source
# File lib/amazon_athena/client.rb, line 108 def run(cmd, preview = false) return cmd.preview if preview cmd.run(connection) end
table_columns(database_table)
click to toggle source
# File lib/amazon_athena/client.rb, line 54 def table_columns(database_table) cmd = AmazonAthena::Commands::ShowColumns.new(database_table) run(cmd) end
table_describe(database_table)
click to toggle source
# File lib/amazon_athena/client.rb, line 66 def table_describe(database_table) cmd = AmazonAthena::Commands::DescribeTable.new(database_table) run(cmd) end
table_drop(database_table)
click to toggle source
# File lib/amazon_athena/client.rb, line 48 def table_drop(database_table) cmd = AmazonAthena::Commands::DropTable.new(database) run(cmd) end
table_properties(database_table)
click to toggle source
# File lib/amazon_athena/client.rb, line 79 def table_properties(database_table) cmd = AmazonAthena::Commands::ShowTableProperties.new(database_table) run(cmd) end
table_repair(database_table)
click to toggle source
# File lib/amazon_athena/client.rb, line 72 def table_repair(database_table) cmd = AmazonAthena::Commands::RepairTable.new(database_table) run(cmd) partitions(database_table) end
table_show_create(database_table)
click to toggle source
# File lib/amazon_athena/client.rb, line 60 def table_show_create(database_table) cmd = AmazonAthena::Commands::ShowCreateTable.new(database_table) run(cmd) end
tables(database)
click to toggle source
# File lib/amazon_athena/client.rb, line 42 def tables(database) cmd = AmazonAthena::Commands::ShowTables.new(database) run(cmd) end