Class: Outhad::Integrations::Source::AwsAthena::Client
- Inherits:
-
SourceConnector
- Object
- SourceConnector
- Outhad::Integrations::Source::AwsAthena::Client
- Defined in:
- lib/outhad/integrations/source/aws_athena/client.rb
Instance Method Summary collapse
- #check_connection(connection_config) ⇒ Object
- #discover(connection_config) ⇒ Object
- #read(sync_config) ⇒ Object
Instance Method Details
#check_connection(connection_config) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/outhad/integrations/source/aws_athena/client.rb', line 7 def check_connection(connection_config) connection_config = connection_config.with_indifferent_access athena_client = create_connection(connection_config) athena_client.list_work_groups ConnectionStatus.new(status: ConnectionStatusType["succeeded"]). rescue StandardError => e ConnectionStatus.new(status: ConnectionStatusType["failed"], message: e.). end |
#discover(connection_config) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/outhad/integrations/source/aws_athena/client.rb', line 16 def discover(connection_config) connection_config = connection_config.with_indifferent_access query = "SELECT table_name, column_name, data_type, is_nullable FROM information_schema.columns WHERE table_schema = '#{connection_config[:schema]}' ORDER BY table_name, ordinal_position;" db = create_connection(connection_config) results = query_execution(db, query) catalog = Catalog.new(streams: create_streams(results)) catalog. rescue StandardError => e handle_exception(e, { context: "AWS:ATHENA:DISCOVER:EXCEPTION", type: "error" }) end |
#read(sync_config) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/outhad/integrations/source/aws_athena/client.rb', line 30 def read(sync_config) connection_config = sync_config.source.connection_specification connection_config = connection_config.with_indifferent_access query = sync_config.model.query query = batched_query(query, sync_config.limit, sync_config.offset) unless sync_config.limit.nil? && sync_config.offset.nil? db = create_connection(connection_config) query(db, query) rescue StandardError => e handle_exception(e, { context: "AWS:ATHENA:READ:EXCEPTION", type: "error", sync_id: sync_config.sync_id, sync_run_id: sync_config.sync_run_id }) end |