google-cloud-bigquery 1.13.0 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5749ebc4d81b2e758eea899e5e13f8d1852c51b2a7076ed5eb853920b690beb3
4
- data.tar.gz: abdade7b534e45a3522b5572b41d899c5a5c88b92d14932804e272d13740efaf
3
+ metadata.gz: 80523fe00fc3861251d25519f8ec0a69e5ac705684a29f5a8d434417cb68f16f
4
+ data.tar.gz: 361426a22a8df42fcec90b1ec8a3d001f2cc66ce9977d652b8366e2355cc9b61
5
5
  SHA512:
6
- metadata.gz: e0d63cd756ed4361f7dfcfb85f2adadad578f932c5d06cab802803d8a9a82a7e7274089716e8ad580f2cbaa2d21b6b7db898a9be833aa6f4aac161c0549df103
7
- data.tar.gz: 959b228436b7d9fc601380b5fa93254a8e317275dc04c9014535cd244694277d0334d76110e1eed48891d774cb66d2f19a41e6da89a8e9527a523ad1e32a73c4
6
+ metadata.gz: 65871c2ff827dea7a1245ed24321582a748ac4b798fa0907e7ceed9527d3b2b94fc1b85f2d7a29f8d9f4d9fd645d0494e104dc5d122e372bb0e8ced9663f3bd3
7
+ data.tar.gz: 9ba6a0fa3e555b86fca8ca2e74fc46475a4c8fa171c5e00ee3de5c55874262dbde292b16e2542fc845d5780b615ee7134d7ee5891d4651f883db02badf646dd1
@@ -1,5 +1,19 @@
1
1
  # Release History
2
2
 
3
+ ### 1.14.0 / 2019-08-23
4
+
5
+ #### Features
6
+
7
+ * Support overriding of service endpoint
8
+
9
+ #### Performance Improvements
10
+
11
+ * Use MiniMime to detect content types
12
+
13
+ #### Documentation
14
+
15
+ * Update documentation
16
+
3
17
  ### 1.13.0 / 2019-07-31
4
18
 
5
19
  * Add Table#require_partition_filter
@@ -87,7 +87,7 @@ advantages over legacy SQL, including:
87
87
  * Complex `JOIN` predicates, including arbitrary expressions
88
88
 
89
89
  For examples that demonstrate some of these features, see [Standard SQL
90
- ghlights](https://cloud.google.com/bigquery/docs/reference/standard-sql/migrating-from-legacy-l#standard_sql_highlights).
90
+ ghlights](https://cloud.google.com/bigquery/docs/reference/standard-sql/migrating-from-legacy-sql#standard_sql_highlights).
91
91
 
92
92
  As shown in this example, standard SQL is the library default:
93
93
 
@@ -135,4 +135,5 @@ Google::Cloud.configure.add_config! :bigquery do |config|
135
135
  config.add_field! :scope, nil, match: [String, Array]
136
136
  config.add_field! :retries, nil, match: Integer
137
137
  config.add_field! :timeout, nil, match: Integer
138
+ config.add_field! :endpoint, nil, match: String
138
139
  end
@@ -51,6 +51,8 @@ module Google
51
51
  # @param [Integer] retries Number of times to retry requests on server
52
52
  # error. The default value is `5`. Optional.
53
53
  # @param [Integer] timeout Default timeout to use in requests. Optional.
54
+ # @param [String] endpoint Override of the endpoint host name. Optional.
55
+ # If the param is nil, uses the default endpoint.
54
56
  # @param [String] project Alias for the `project_id` argument. Deprecated.
55
57
  # @param [String] keyfile Alias for the `credentials` argument.
56
58
  # Deprecated.
@@ -65,26 +67,24 @@ module Google
65
67
  # table = dataset.table "my_table"
66
68
  #
67
69
  def self.new project_id: nil, credentials: nil, scope: nil, retries: nil,
68
- timeout: nil, project: nil, keyfile: nil
69
- project_id ||= (project || default_project_id)
70
+ timeout: nil, endpoint: nil, project: nil, keyfile: nil
70
71
  scope ||= configure.scope
71
72
  retries ||= configure.retries
72
73
  timeout ||= configure.timeout
74
+ endpoint ||= configure.endpoint
73
75
  credentials ||= (keyfile || default_credentials(scope: scope))
74
76
 
75
77
  unless credentials.is_a? Google::Auth::Credentials
76
78
  credentials = Bigquery::Credentials.new credentials, scope: scope
77
79
  end
78
80
 
79
- if credentials.respond_to? :project_id
80
- project_id ||= credentials.project_id
81
- end
82
- project_id = project_id.to_s # Always cast to a string
81
+ project_id = resolve_project_id(project_id || project, credentials)
83
82
  raise ArgumentError, "project_id is missing" if project_id.empty?
84
83
 
85
84
  Bigquery::Project.new(
86
85
  Bigquery::Service.new(
87
- project_id, credentials, retries: retries, timeout: timeout
86
+ project_id, credentials,
87
+ retries: retries, timeout: timeout, host: endpoint
88
88
  )
89
89
  )
90
90
  end
@@ -100,6 +100,8 @@ module Google
100
100
  # the keyfile as a String, the contents of the keyfile as a Hash, or a
101
101
  # Google::Auth::Credentials object. (See {Bigquery::Credentials}) (The
102
102
  # parameter `keyfile` is considered deprecated, but may also be used.)
103
+ # * `endpoint` - (String) Override of the endpoint host name, or `nil`
104
+ # to use the default endpoint.
103
105
  # * `scope` - (String, Array<String>) The OAuth 2.0 scopes controlling
104
106
  # the set of resources and operations that the connection can access.
105
107
  # * `retries` - (Integer) Number of times to retry requests on server
@@ -115,6 +117,16 @@ module Google
115
117
  Google::Cloud.configure.bigquery
116
118
  end
117
119
 
120
+ ##
121
+ # @private Resolve project.
122
+ def self.resolve_project_id given_project, credentials
123
+ project_id = given_project || default_project_id
124
+ if credentials.respond_to? :project_id
125
+ project_id ||= credentials.project_id
126
+ end
127
+ project_id.to_s # Always cast to a string
128
+ end
129
+
118
130
  ##
119
131
  # @private Default project.
120
132
  def self.default_project_id
@@ -19,7 +19,7 @@ require "google/cloud/errors"
19
19
  require "google/apis/bigquery_v2"
20
20
  require "pathname"
21
21
  require "securerandom"
22
- require "mime/types"
22
+ require "mini_mime"
23
23
  require "date"
24
24
 
25
25
  module Google
@@ -39,15 +39,17 @@ module Google
39
39
  attr_accessor :credentials
40
40
 
41
41
  # @private
42
- attr_reader :retries, :timeout
42
+ attr_reader :retries, :timeout, :host
43
43
 
44
44
  ##
45
45
  # Creates a new Service instance.
46
- def initialize project, credentials, retries: nil, timeout: nil
46
+ def initialize project, credentials,
47
+ retries: nil, timeout: nil, host: nil
47
48
  @project = project
48
49
  @credentials = credentials
49
50
  @retries = retries
50
51
  @timeout = timeout
52
+ @host = host
51
53
  end
52
54
 
53
55
  def service
@@ -65,6 +67,7 @@ module Google
65
67
  service.request_options.header["x-goog-api-client"] = \
66
68
  "gl-ruby/#{RUBY_VERSION} gccl/#{Google::Cloud::Bigquery::VERSION}"
67
69
  service.authorization = @credentials.client
70
+ service.root_url = host if host
68
71
  service
69
72
  end
70
73
  end
@@ -480,9 +483,9 @@ module Google
480
483
  end
481
484
 
482
485
  def mime_type_for file
483
- mime_type = MIME::Types.of(Pathname(file).to_path).first.to_s
484
- return nil if mime_type.empty?
485
- mime_type
486
+ mime_type = MiniMime.lookup_by_filename Pathname(file).to_path
487
+ return nil if mime_type.nil?
488
+ mime_type.content_type
486
489
  rescue StandardError
487
490
  nil
488
491
  end
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Bigquery
19
- VERSION = "1.13.0".freeze
19
+ VERSION = "1.14.0".freeze
20
20
  end
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-bigquery
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.0
4
+ version: 1.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Moore
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-08-01 00:00:00.000000000 Z
12
+ date: 2019-08-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core
@@ -74,19 +74,19 @@ dependencies:
74
74
  - !ruby/object:Gem::Version
75
75
  version: '1.0'
76
76
  - !ruby/object:Gem::Dependency
77
- name: mime-types
77
+ name: mini_mime
78
78
  requirement: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '3.0'
82
+ version: '1.0'
83
83
  type: :runtime
84
84
  prerelease: false
85
85
  version_requirements: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '3.0'
89
+ version: '1.0'
90
90
  - !ruby/object:Gem::Dependency
91
91
  name: minitest
92
92
  requirement: !ruby/object:Gem::Requirement