embulk-input-bigquery_extract_files 0.0.5 → 0.0.6

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
  SHA1:
3
- metadata.gz: 85c5df6d2dabf2727e267cabd33a2fd163e22942
4
- data.tar.gz: 7b24ecc581b1b5c789ad4f33ab73303bc7c6ca8d
3
+ metadata.gz: e709d68054ae241b205a52159c85d2eaec65406a
4
+ data.tar.gz: 88d85008b319fd53613d347dfaa101ad1a106f36
5
5
  SHA512:
6
- metadata.gz: 7b868edc052a4eec8cdd57fc5ae5899d25bb7fa65ab1289785e6c8e6f05e7d280a79e43ea608e31d9c883fc72776ea91b1a7cc1b381a0f4d898c651ebc203fae
7
- data.tar.gz: 61c5c9616ca9b96ab7587144b25a16b7bdc59e34ebf9b6f38def677e080c8b7f5df26b75b725009df18cd35a96434d224a8644bba88510af7d307d429f1e0a54
6
+ metadata.gz: 951cf84517c6ffa2785c4a164354f2e3ca96faf0ce3ded183946726a54d6d780bd96245e78befc60ec9c14793bb922a6a526b4574dc6dda67a7bb93ee201b200
7
+ data.tar.gz: 7321c8a02fdfe9fc9973f539806eca76c37c4548a12cd55475a36e1421f9b0d82e38941a64f61358f4ac420dab92f5fcbc3d4388be41360c16955b1cff0b2301
data/build.gradle CHANGED
@@ -13,7 +13,7 @@ configurations {
13
13
  provided
14
14
  }
15
15
 
16
- version = "0.0.5"
16
+ version = "0.0.6"
17
17
 
18
18
  sourceCompatibility = 1.7
19
19
  targetCompatibility = 1.7
@@ -212,7 +212,7 @@ public class BigqueryExportGcsFileInputPlugin
212
212
  }
213
213
 
214
214
  PHASE phase = BigqueryExportUtils.initTask(task);
215
- log.info("Configuration : {}",task.toString());
215
+ log.info("[0] Settings : {}", BigqueryExportUtils.toPrettyString(task.dump().deepCopy().getObjectNode()) );
216
216
 
217
217
  Bigquery bigquery = BigqueryExportUtils.newBigqueryClient(task);
218
218
 
@@ -215,6 +215,10 @@ public class BigqueryExportUtils
215
215
 
216
216
  do {
217
217
  objects = listRequest.execute();
218
+ if(objects.getItems() == null){
219
+ log.error("file not found in gs://{}/{}",bucket,blobName);
220
+ return builder.build();
221
+ }
218
222
  for(StorageObject obj : objects.getItems()){
219
223
  builder.add(obj.getName());
220
224
  }
@@ -430,9 +434,18 @@ public class BigqueryExportUtils
430
434
  log.error("error when create schema json",e);
431
435
  return null;
432
436
  }
433
-
434
437
  //for(Column col : schema.getColumns()) {
435
-
438
+ }
439
+
440
+ public static String toPrettyString(Object obj){
441
+ try {
442
+ ObjectMapper mapper = new ObjectMapper();
443
+ String str = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(obj);
444
+ return str;
445
+ } catch (Exception e) {
446
+ log.error("JSON format error",e);
447
+ return java.util.Objects.toString(obj);
448
+ }
436
449
  }
437
450
 
438
451
  /**
@@ -452,8 +465,13 @@ public class BigqueryExportUtils
452
465
 
453
466
  public static void removeGcsFilesBeforeExecuting(PluginTask task){
454
467
  try {
468
+ log.info("start cleanup gs://{}/{} ... ",task.getGcsBucket(), task.getGcsBlobNamePrefix());
455
469
  Storage gcs = BigqueryExportUtils.newGcsClient(task);
456
- gcs.objects().delete(task.getGcsBucket(), task.getGcsBlobNamePrefix()).execute();
470
+ List<String> fileList = getFileListFromGcs(gcs, task.getGcsBucket(), task.getGcsBlobNamePrefix());
471
+ for(String f : fileList){
472
+ log.info("cleanup gs://{}/{} ... ",task.getGcsBucket(), f);
473
+ gcs.objects().delete(task.getGcsBucket(), f).execute();
474
+ }
457
475
  } catch (GoogleJsonResponseException e) {
458
476
  if(e.getStatusCode() == 404){
459
477
  log.info("file not found in gs://{}/{} :: it's ok ",task.getGcsBucket(), task.getGcsBlobNamePrefix());
@@ -8,17 +8,19 @@ import java.io.IOException;
8
8
  import org.embulk.EmbulkTestRuntime;
9
9
  import org.embulk.config.ConfigLoader;
10
10
  import org.embulk.config.ConfigSource;
11
- import org.embulk.config.DataSourceImpl;
12
- import org.embulk.input.bigquery_export_gcs.BigqueryExportGcsFileInputPlugin.PluginTask;
13
11
  import org.embulk.spi.Exec;
14
12
  import org.embulk.spi.FileInputRunner;
13
+ import org.embulk.spi.SchemaConfig;
15
14
  import org.embulk.spi.TestPageBuilderReader.MockPageOutput;
16
15
  import org.junit.Before;
17
16
  import org.junit.BeforeClass;
18
17
  import org.junit.Rule;
18
+ import org.junit.Test;
19
19
  import org.slf4j.Logger;
20
20
  import org.slf4j.LoggerFactory;
21
21
 
22
+ import com.fasterxml.jackson.databind.JsonNode;
23
+
22
24
  public class UnitTestInitializer
23
25
  {
24
26
  private static final Logger log = LoggerFactory.getLogger(UnitTestInitializer.class);
@@ -81,6 +83,14 @@ public class UnitTestInitializer
81
83
  config.get(String.class, "temp_local_path")
82
84
  );
83
85
  }
86
+
87
+ @Test
88
+ public void testInitTask(){
89
+ BigqueryExportGcsFileInputPlugin.PluginTask task = config.loadConfig(BigqueryExportGcsFileInputPlugin.PluginTask.class );
90
+
91
+ log.info("{}", BigqueryExportUtils.toPrettyString(task.dump().deepCopy().getObjectNode()) );
92
+ }
93
+
84
94
 
85
95
 
86
96
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-input-bigquery_extract_files
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - jo8937
@@ -65,7 +65,7 @@ files:
65
65
  - src/test/java/org/embulk/input/bigquery_export_gcs/UnitTestInitializer.java
66
66
  - classpath/commons-codec-1.3.jar
67
67
  - classpath/commons-logging-1.1.1.jar
68
- - classpath/embulk-input-bigquery_extract_files-0.0.5.jar
68
+ - classpath/embulk-input-bigquery_extract_files-0.0.6.jar
69
69
  - classpath/google-api-client-1.23.0.jar
70
70
  - classpath/google-api-services-bigquery-v2-rev363-1.23.0.jar
71
71
  - classpath/google-api-services-storage-v1-rev59-1.21.0.jar