Business intelligence made simple
Added schema to Athena adapter
Andrew Kane0b23195eb37c
diff --git a/lib/blazer/adapters/athena_adapter.rb b/lib/blazer/adapters/athena_adapter.rbindex ca8aa512..fe9ae894 100644--- a/lib/blazer/adapters/athena_adapter.rb+++ b/lib/blazer/adapters/athena_adapter.rb@@ -15,7 +15,7 @@ module Blazer# use token so we fetch cached results after query is runclient_request_token: Digest::MD5.hexdigest(statement),query_execution_context: {- database: settings["database"] || "default",+ database: database,},result_configuration: {output_location: settings["output_location"]@@ -93,11 +93,31 @@ module Blazer[columns, rows, error]end+ def tables+ glue.get_tables(database_name: database).table_list.map(&:name).sort+ end++ def schema+ glue.get_tables(database_name: database).table_list.map { |t| {table: t.name, columns: t.storage_descriptor.columns.map { |c| {name: c.name, data_type: c.type} }} }+ end++ def preview_statement+ "SELECT * FROM {table} LIMIT 10"+ end+private+ def database+ @database ||= settings["database"] || "default"+ end+def client@client ||= Aws::Athena::Client.newend++ def glue+ @glue ||= Aws::Glue::Client.new+ endendendend