@@ -128,37 +128,40 @@ protected abstract Map<String, Object> readRecord(RecordReader<?, T> recordReade
128
128
* intended for BigQueryFactory and adding them as GCS-equivalent credential settings.
129
129
*/
130
130
public static Configuration getConfigForGcsFromBigquerySettings (
131
- String projectIdvalue , String testBucket ) {
131
+ String projectIdValue , String testBucket ) {
132
132
TestConfiguration configuration = TestConfiguration .getInstance ();
133
133
134
- String bigqueryServiceAccount = configuration .getServiceAccount ();
135
- if (Strings .isNullOrEmpty (bigqueryServiceAccount )) {
136
- bigqueryServiceAccount = System .getenv (BigQueryFactory .BIGQUERY_SERVICE_ACCOUNT );
134
+ String serviceAccount = configuration .getServiceAccount ();
135
+ if (Strings .isNullOrEmpty (serviceAccount )) {
136
+ serviceAccount = System .getenv (BigQueryFactory .BIGQUERY_SERVICE_ACCOUNT );
137
137
}
138
138
139
- String bigqueryPrivateKeyFile = configuration .getPrivateKeyFile ();
140
- if (Strings .isNullOrEmpty (bigqueryPrivateKeyFile )) {
141
- bigqueryPrivateKeyFile = System .getenv (BigQueryFactory .BIGQUERY_PRIVATE_KEY_FILE );
139
+ String privateKeyFile = configuration .getPrivateKeyFile ();
140
+ if (Strings .isNullOrEmpty (privateKeyFile )) {
141
+ privateKeyFile = System .getenv (BigQueryFactory .BIGQUERY_PRIVATE_KEY_FILE );
142
142
}
143
- Configuration config = new Configuration ();
144
- config .set (
145
- BIGQUERY_CONFIG_PREFIX + HadoopCredentialConfiguration .ENABLE_SERVICE_ACCOUNTS_SUFFIX ,
146
- "true" );
147
- config .set (
148
- BIGQUERY_CONFIG_PREFIX + HadoopCredentialConfiguration .SERVICE_ACCOUNT_EMAIL_SUFFIX ,
149
- bigqueryServiceAccount );
150
- config .set (
151
- BIGQUERY_CONFIG_PREFIX + HadoopCredentialConfiguration .SERVICE_ACCOUNT_KEYFILE_SUFFIX ,
152
- bigqueryPrivateKeyFile );
153
- config .set (
154
- GoogleHadoopFileSystemConfiguration .AUTH_SERVICE_ACCOUNT_KEY_FILE .getKey (),
155
- bigqueryPrivateKeyFile );
156
- config .set (
157
- GoogleHadoopFileSystemConfiguration .AUTH_SERVICE_ACCOUNT_EMAIL .getKey (),
158
- bigqueryServiceAccount );
159
- config .set (GoogleHadoopFileSystemConfiguration .GCS_PROJECT_ID .getKey (), projectIdvalue );
160
143
144
+ Configuration config = new Configuration ();
161
145
config .set ("fs.gs.impl" , "com.google.cloud.hadoop.fs.gcs.GoogleHadoopFileSystem" );
146
+ config .set (GoogleHadoopFileSystemConfiguration .GCS_PROJECT_ID .getKey (), projectIdValue );
147
+
148
+ if (serviceAccount != null && privateKeyFile != null ) {
149
+ config .setBoolean (
150
+ BIGQUERY_CONFIG_PREFIX + HadoopCredentialConfiguration .ENABLE_SERVICE_ACCOUNTS_SUFFIX ,
151
+ true );
152
+ config .set (
153
+ BIGQUERY_CONFIG_PREFIX + HadoopCredentialConfiguration .SERVICE_ACCOUNT_EMAIL_SUFFIX ,
154
+ serviceAccount );
155
+ config .set (
156
+ BIGQUERY_CONFIG_PREFIX + HadoopCredentialConfiguration .SERVICE_ACCOUNT_KEYFILE_SUFFIX ,
157
+ privateKeyFile );
158
+ config .set (
159
+ GoogleHadoopFileSystemConfiguration .AUTH_SERVICE_ACCOUNT_EMAIL .getKey (), serviceAccount );
160
+ config .set (
161
+ GoogleHadoopFileSystemConfiguration .AUTH_SERVICE_ACCOUNT_KEY_FILE .getKey (),
162
+ privateKeyFile );
163
+ }
164
+
162
165
return config ;
163
166
}
164
167
0 commit comments