blazer 2.4.5 → 2.4.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of blazer might be problematic. Click here for more details.

@@ -8,19 +8,25 @@ module Blazer
8
8
  rows = []
9
9
  error = nil
10
10
 
11
+ query_options = {
12
+ query_string: statement,
13
+ # use token so we fetch cached results after query is run
14
+ client_request_token: Digest::MD5.hexdigest([statement, data_source.id, settings["workgroup"]].compact.join("/")),
15
+ query_execution_context: {
16
+ database: database,
17
+ }
18
+ }
19
+
20
+ if settings["output_location"]
21
+ query_options[:result_configuration] = {output_location: settings["output_location"]}
22
+ end
23
+
24
+ if settings["workgroup"]
25
+ query_options[:work_group] = settings["workgroup"]
26
+ end
27
+
11
28
  begin
12
- resp =
13
- client.start_query_execution(
14
- query_string: statement,
15
- # use token so we fetch cached results after query is run
16
- client_request_token: Digest::MD5.hexdigest([statement,data_source.id].join("/")),
17
- query_execution_context: {
18
- database: database,
19
- },
20
- result_configuration: {
21
- output_location: settings["output_location"]
22
- }
23
- )
29
+ resp = client.start_query_execution(**query_options)
24
30
  query_execution_id = resp.query_execution_id
25
31
 
26
32
  timeout = data_source.timeout || 300
@@ -60,21 +66,21 @@ module Blazer
60
66
  column_types.each_with_index do |ct, i|
61
67
  # TODO more column_types
62
68
  case ct
63
- when "timestamp"
69
+ when "timestamp", "timestamp with time zone"
64
70
  rows.each do |row|
65
- row[i] = utc.parse(row[i])
71
+ row[i] &&= utc.parse(row[i])
66
72
  end
67
73
  when "date"
68
74
  rows.each do |row|
69
- row[i] = Date.parse(row[i])
75
+ row[i] &&= Date.parse(row[i])
70
76
  end
71
77
  when "bigint"
72
78
  rows.each do |row|
73
- row[i] = row[i].to_i
79
+ row[i] &&= row[i].to_i
74
80
  end
75
81
  when "double"
76
82
  rows.each do |row|
77
- row[i] = row[i].to_f
83
+ row[i] &&= row[i].to_f
78
84
  end
79
85
  end
80
86
  end
@@ -118,11 +124,21 @@ module Blazer
118
124
  end
119
125
 
120
126
  def client
121
- @client ||= Aws::Athena::Client.new
127
+ @client ||= Aws::Athena::Client.new(**client_options)
122
128
  end
123
129
 
124
130
  def glue
125
- @glue ||= Aws::Glue::Client.new
131
+ @glue ||= Aws::Glue::Client.new(**client_options)
132
+ end
133
+
134
+ def client_options
135
+ @client_options ||= begin
136
+ if settings["access_key_id"] || settings["secret_access_key"]
137
+ {credentials: Aws::Credentials.new(settings["access_key_id"], settings["secret_access_key"])}
138
+ else
139
+ {}
140
+ end
141
+ end
126
142
  end
127
143
  end
128
144
  end
@@ -13,7 +13,7 @@ module Blazer
13
13
  # code is for backward compatibility
14
14
  if !results.respond_to?(:complete?) || results.complete?
15
15
  columns = results.first.keys.map(&:to_s) if results.size > 0
16
- rows = results.map(&:values)
16
+ rows = results.all.map(&:values)
17
17
  else
18
18
  error = Blazer::TIMEOUT_MESSAGE
19
19
  end
@@ -1,3 +1,3 @@
1
1
  module Blazer
2
- VERSION = "2.4.5"
2
+ VERSION = "2.4.6"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2011-2016 Twitter, Inc.
3
+ Copyright (c) 2011-2019 Twitter, Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blazer
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.5
4
+ version: 2.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-16 00:00:00.000000000 Z
11
+ date: 2021-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties