embulk-input-bigquery_extract_files 0.0.3
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 +7 -0
- data/.gitignore +16 -0
- data/LICENSE.txt +21 -0
- data/README.md +92 -0
- data/build.gradle +102 -0
- data/config.yml +30 -0
- data/config/checkstyle/checkstyle.xml +128 -0
- data/config/checkstyle/default.xml +108 -0
- data/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/gradle/wrapper/gradle-wrapper.properties +5 -0
- data/gradlew +172 -0
- data/gradlew.bat +84 -0
- data/lib/embulk/input/bigquery_extract_files.rb +3 -0
- data/src/main/java/org/embulk/input/bigquery_export_gcs/BigqueryExportGcsFileInputPlugin.java +340 -0
- data/src/main/java/org/embulk/input/bigquery_export_gcs/BigqueryExportUtils.java +444 -0
- data/src/test/java/org/embulk/input/bigquery_export_gcs/TestGoogleCloudAccessData.java +33 -0
- data/src/test/java/org/embulk/input/bigquery_export_gcs/TestPluginFunctions.java +56 -0
- data/src/test/java/org/embulk/input/bigquery_export_gcs/UnitTestInitializer.java +86 -0
- metadata +101 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
package org.embulk.input.bigquery_export_gcs;
|
2
|
+
|
3
|
+
import static org.junit.Assert.assertEquals;
|
4
|
+
import static org.junit.Assert.assertNotNull;
|
5
|
+
import static org.junit.Assume.assumeNotNull;
|
6
|
+
|
7
|
+
import java.io.FileNotFoundException;
|
8
|
+
import java.io.IOException;
|
9
|
+
import java.io.InputStream;
|
10
|
+
import java.util.List;
|
11
|
+
|
12
|
+
import org.embulk.EmbulkTestRuntime;
|
13
|
+
import org.embulk.config.ConfigSource;
|
14
|
+
import org.embulk.spi.Exec;
|
15
|
+
import org.embulk.spi.FileInputRunner;
|
16
|
+
import org.embulk.spi.TestPageBuilderReader.MockPageOutput;
|
17
|
+
import org.junit.Before;
|
18
|
+
import org.junit.BeforeClass;
|
19
|
+
import org.junit.Rule;
|
20
|
+
import org.junit.Test;
|
21
|
+
import org.slf4j.Logger;
|
22
|
+
import org.slf4j.LoggerFactory;
|
23
|
+
|
24
|
+
public class TestPluginFunctions extends UnitTestInitializer
|
25
|
+
{
|
26
|
+
private static final Logger log = LoggerFactory.getLogger(TestPluginFunctions.class);
|
27
|
+
|
28
|
+
@Test
|
29
|
+
public void regexTest(){
|
30
|
+
testTableName("select * from aaa.bbb","bbb");
|
31
|
+
testTableName("select * from aaa.bbb.ccc","ccc");
|
32
|
+
testTableName("select * from [aaa.bbb]","bbb");
|
33
|
+
testTableName("select * from aaa.bbb$20171123","bbb");
|
34
|
+
testTableName("select * from aaa.t_b_b_b","t_b_b_b");
|
35
|
+
}
|
36
|
+
|
37
|
+
public void testTableName(String query, String expect){
|
38
|
+
String word = BigqueryExportUtils.parseQueryToBaseTableName(query);
|
39
|
+
log.info("{}", word );
|
40
|
+
assertEquals(word, expect);
|
41
|
+
}
|
42
|
+
|
43
|
+
@Test
|
44
|
+
public void testParseGcsUrl(){
|
45
|
+
ConfigSource c = config.deepCopy();
|
46
|
+
c.set("gcs_uri", "gs://aaa/bbb/ccc_*");
|
47
|
+
|
48
|
+
BigqueryExportGcsFileInputPlugin.PluginTask task = c.loadConfig(BigqueryExportGcsFileInputPlugin.PluginTask.class );
|
49
|
+
|
50
|
+
BigqueryExportUtils.parseGcsUri(task);
|
51
|
+
|
52
|
+
assertEquals("", "aaa", task.getGcsBucket());
|
53
|
+
assertEquals("", "bbb/ccc_", task.getGcsBlobNamePrefix());
|
54
|
+
}
|
55
|
+
|
56
|
+
}
|
@@ -0,0 +1,86 @@
|
|
1
|
+
package org.embulk.input.bigquery_export_gcs;
|
2
|
+
|
3
|
+
import static org.junit.Assume.assumeNotNull;
|
4
|
+
|
5
|
+
import java.io.File;
|
6
|
+
import java.io.IOException;
|
7
|
+
|
8
|
+
import org.embulk.EmbulkTestRuntime;
|
9
|
+
import org.embulk.config.ConfigLoader;
|
10
|
+
import org.embulk.config.ConfigSource;
|
11
|
+
import org.embulk.config.DataSourceImpl;
|
12
|
+
import org.embulk.input.bigquery_export_gcs.BigqueryExportGcsFileInputPlugin.PluginTask;
|
13
|
+
import org.embulk.spi.Exec;
|
14
|
+
import org.embulk.spi.FileInputRunner;
|
15
|
+
import org.embulk.spi.TestPageBuilderReader.MockPageOutput;
|
16
|
+
import org.junit.Before;
|
17
|
+
import org.junit.BeforeClass;
|
18
|
+
import org.junit.Rule;
|
19
|
+
import org.slf4j.Logger;
|
20
|
+
import org.slf4j.LoggerFactory;
|
21
|
+
|
22
|
+
public class UnitTestInitializer
|
23
|
+
{
|
24
|
+
private static final Logger log = LoggerFactory.getLogger(UnitTestInitializer.class);
|
25
|
+
|
26
|
+
private static String TEST_EMBULK_CUSTOM_CONFIG_PATH;
|
27
|
+
|
28
|
+
/*
|
29
|
+
* This test case requires environment variables
|
30
|
+
* GCP_EMAIL
|
31
|
+
* GCP_P12_KEYFILE
|
32
|
+
* GCP_JSON_KEYFILE
|
33
|
+
* GCP_BUCKET
|
34
|
+
*/
|
35
|
+
@BeforeClass
|
36
|
+
public static void initializeConstantVariables()
|
37
|
+
{
|
38
|
+
TEST_EMBULK_CUSTOM_CONFIG_PATH = "local_config.yml"; //System.getenv("TEST_EMBULK_CUSTOM_CONFIG_PATH");
|
39
|
+
}
|
40
|
+
|
41
|
+
@Rule
|
42
|
+
public EmbulkTestRuntime runtime = new EmbulkTestRuntime();
|
43
|
+
protected ConfigSource config;
|
44
|
+
protected BigqueryExportGcsFileInputPlugin plugin;
|
45
|
+
protected FileInputRunner runner;
|
46
|
+
protected MockPageOutput output;
|
47
|
+
|
48
|
+
/**
|
49
|
+
* @throws IOException
|
50
|
+
*
|
51
|
+
*/
|
52
|
+
@Before
|
53
|
+
public void createResources() throws IOException
|
54
|
+
{
|
55
|
+
File f =new File(TEST_EMBULK_CUSTOM_CONFIG_PATH);
|
56
|
+
if(f.exists()){
|
57
|
+
log.info("Test env load from file : {}",f);
|
58
|
+
config = new ConfigLoader(Exec.session().getModelManager()).fromYamlFile(f).getNested("in");
|
59
|
+
log.info("values : {}",config.toString());
|
60
|
+
}else{
|
61
|
+
log.error("test config file NOT FOUND ! :: {}",f);
|
62
|
+
log.info("load test env from system env ... ");
|
63
|
+
config = Exec.newConfigSource();
|
64
|
+
config.set("project", System.getenv("embulk_config_project"));
|
65
|
+
config.set("json_keyfile", System.getenv("embulk_config_json_keyfile"));
|
66
|
+
config.set("dataset", System.getenv("embulk_config_dataset"));
|
67
|
+
config.set("query", System.getenv("embulk_config_query"));
|
68
|
+
config.set("gcs_uri", System.getenv("embulk_config_gcs_uri"));
|
69
|
+
config.set("temp_dataset", System.getenv("embulk_config_temp_dataset"));
|
70
|
+
config.set("temp_local_path", System.getenv("embulk_config_temp_local_path"));
|
71
|
+
}
|
72
|
+
|
73
|
+
plugin = new BigqueryExportGcsFileInputPlugin();
|
74
|
+
runner = new FileInputRunner(runtime.getInstance(BigqueryExportGcsFileInputPlugin.class));
|
75
|
+
output = new MockPageOutput();
|
76
|
+
|
77
|
+
assumeNotNull(
|
78
|
+
config.get(String.class, "project"),
|
79
|
+
config.get(String.class, "json_keyfile"),
|
80
|
+
config.get(String.class, "gcs_uri"),
|
81
|
+
config.get(String.class, "temp_local_path")
|
82
|
+
);
|
83
|
+
}
|
84
|
+
|
85
|
+
|
86
|
+
}
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: embulk-input-bigquery_extract_files
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- jo8937
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-11-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ~>
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '1.0'
|
19
|
+
name: bundler
|
20
|
+
prerelease: false
|
21
|
+
type: :development
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '10.0'
|
33
|
+
name: rake
|
34
|
+
prerelease: false
|
35
|
+
type: :development
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Reads files stored on Google Cloud Storage, that exportes from Bigquery query result or table
|
42
|
+
email:
|
43
|
+
- jo8937@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- LICENSE.txt
|
50
|
+
- README.md
|
51
|
+
- build.gradle
|
52
|
+
- config.yml
|
53
|
+
- config/checkstyle/checkstyle.xml
|
54
|
+
- config/checkstyle/default.xml
|
55
|
+
- gradle/wrapper/gradle-wrapper.jar
|
56
|
+
- gradle/wrapper/gradle-wrapper.properties
|
57
|
+
- gradlew
|
58
|
+
- gradlew.bat
|
59
|
+
- lib/embulk/input/bigquery_extract_files.rb
|
60
|
+
- src/main/java/org/embulk/input/bigquery_export_gcs/BigqueryExportGcsFileInputPlugin.java
|
61
|
+
- src/main/java/org/embulk/input/bigquery_export_gcs/BigqueryExportUtils.java
|
62
|
+
- src/test/java/org/embulk/input/bigquery_export_gcs/TestGoogleCloudAccessData.java
|
63
|
+
- src/test/java/org/embulk/input/bigquery_export_gcs/TestPluginFunctions.java
|
64
|
+
- src/test/java/org/embulk/input/bigquery_export_gcs/UnitTestInitializer.java
|
65
|
+
- classpath/commons-codec-1.3.jar
|
66
|
+
- classpath/commons-logging-1.1.1.jar
|
67
|
+
- classpath/embulk-input-bigquery_extract_files-0.0.3.jar
|
68
|
+
- classpath/google-api-client-1.23.0.jar
|
69
|
+
- classpath/google-api-services-bigquery-v2-rev363-1.23.0.jar
|
70
|
+
- classpath/google-api-services-storage-v1-rev59-1.21.0.jar
|
71
|
+
- classpath/google-http-client-1.23.0.jar
|
72
|
+
- classpath/google-http-client-jackson2-1.23.0.jar
|
73
|
+
- classpath/google-oauth-client-1.23.0.jar
|
74
|
+
- classpath/httpclient-4.0.1.jar
|
75
|
+
- classpath/httpcore-4.0.1.jar
|
76
|
+
- classpath/jsr305-1.3.9.jar
|
77
|
+
homepage: https://github.com/jo8937/embulk-input-bigquery_extract_files
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.1.9
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: Bigquery Exports GCS file input plugin for Embulk
|
101
|
+
test_files: []
|