Skip to content

Commit 384778d

Browse files
authored
Merge pull request #95 from trocco-io/add_time_partitioning_types
Add time partitioning types
2 parents fbe4b9b + 52ccc0c commit 384778d

File tree

4 files changed

+87
-37
lines changed

4 files changed

+87
-37
lines changed

shadow-google-cloud-bigquery-helper/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ configurations {
3030
}
3131

3232
dependencies {
33-
compile("com.google.cloud:google-cloud-bigquery:1.106.0") {
33+
compile("com.google.cloud:google-cloud-bigquery:2.14.0") {
3434
exclude group: "commons-logging", module: "commons-logging"
3535
}
3636

Lines changed: 68 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,78 @@
11
# This is a Gradle generated file for dependency locking.
22
# Manual edits can break the build and are not advised.
33
# This file is expected to be part of source control.
4-
com.fasterxml.jackson.core:jackson-core:2.10.2
5-
com.google.api-client:google-api-client:1.30.7
6-
com.google.api.grpc:proto-google-common-protos:1.17.0
7-
com.google.api.grpc:proto-google-iam-v1:0.13.0
8-
com.google.api:api-common:1.8.1
9-
com.google.api:gax-httpjson:0.70.1
10-
com.google.api:gax:1.53.1
11-
com.google.apis:google-api-services-bigquery:v2-rev20191211-1.30.3
12-
com.google.auth:google-auth-library-credentials:0.20.0
13-
com.google.auth:google-auth-library-oauth2-http:0.20.0
14-
com.google.auto.value:auto-value-annotations:1.7
15-
com.google.cloud:google-cloud-bigquery:1.106.0
16-
com.google.cloud:google-cloud-core-http:1.92.4
17-
com.google.cloud:google-cloud-core:1.92.4
4+
com.fasterxml.jackson.core:jackson-annotations:2.13.3
5+
com.fasterxml.jackson.core:jackson-core:2.13.3
6+
com.fasterxml.jackson.core:jackson-databind:2.13.3
7+
com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.3
8+
com.fasterxml.jackson:jackson-bom:2.13.3
9+
com.google.android:annotations:4.1.1.4
10+
com.google.api-client:google-api-client:1.35.1
11+
com.google.api.grpc:grpc-google-cloud-bigquerystorage-v1:2.14.2
12+
com.google.api.grpc:grpc-google-cloud-bigquerystorage-v1beta1:0.138.2
13+
com.google.api.grpc:grpc-google-cloud-bigquerystorage-v1beta2:0.138.2
14+
com.google.api.grpc:proto-google-cloud-bigquerystorage-v1:2.14.2
15+
com.google.api.grpc:proto-google-cloud-bigquerystorage-v1beta1:0.138.2
16+
com.google.api.grpc:proto-google-cloud-bigquerystorage-v1beta2:0.138.2
17+
com.google.api.grpc:proto-google-common-protos:2.9.0
18+
com.google.api.grpc:proto-google-iam-v1:1.4.1
19+
com.google.api:api-common:2.2.1
20+
com.google.api:gax-grpc:2.18.2
21+
com.google.api:gax-httpjson:0.103.2
22+
com.google.api:gax:2.18.2
23+
com.google.apis:google-api-services-bigquery:v2-rev20220611-1.32.1
24+
com.google.auth:google-auth-library-credentials:1.7.0
25+
com.google.auth:google-auth-library-oauth2-http:1.7.0
26+
com.google.cloud:google-cloud-bigquery:2.14.0
27+
com.google.cloud:google-cloud-bigquerystorage:2.14.2
28+
com.google.cloud:google-cloud-core-http:2.8.0
29+
com.google.cloud:google-cloud-core:2.8.0
1830
com.google.code.findbugs:jsr305:3.0.2
19-
com.google.code.gson:gson:2.8.6
20-
com.google.errorprone:error_prone_annotations:2.3.4
31+
com.google.code.gson:gson:2.9.0
32+
com.google.errorprone:error_prone_annotations:2.14.0
33+
com.google.flatbuffers:flatbuffers-java:1.12.0
2134
com.google.guava:failureaccess:1.0.1
22-
com.google.guava:guava:28.2-android
35+
com.google.guava:guava:31.1-jre
2336
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
24-
com.google.http-client:google-http-client-appengine:1.34.1
25-
com.google.http-client:google-http-client-jackson2:1.34.1
26-
com.google.http-client:google-http-client:1.34.1
37+
com.google.http-client:google-http-client-apache-v2:1.42.0
38+
com.google.http-client:google-http-client-appengine:1.42.0
39+
com.google.http-client:google-http-client-gson:1.42.0
40+
com.google.http-client:google-http-client-jackson2:1.42.0
41+
com.google.http-client:google-http-client:1.42.0
2742
com.google.j2objc:j2objc-annotations:1.3
28-
com.google.oauth-client:google-oauth-client:1.30.5
29-
com.google.protobuf:protobuf-java-util:3.11.1
30-
com.google.protobuf:protobuf-java:3.11.1
31-
commons-codec:commons-codec:1.11
32-
io.grpc:grpc-context:1.22.1
33-
io.opencensus:opencensus-api:0.24.0
34-
io.opencensus:opencensus-contrib-http-util:0.24.0
43+
com.google.oauth-client:google-oauth-client:1.34.1
44+
com.google.protobuf:protobuf-java-util:3.21.1
45+
com.google.protobuf:protobuf-java:3.21.1
46+
commons-codec:commons-codec:1.15
47+
io.grpc:grpc-alts:1.47.0
48+
io.grpc:grpc-api:1.47.0
49+
io.grpc:grpc-auth:1.47.0
50+
io.grpc:grpc-context:1.47.0
51+
io.grpc:grpc-core:1.47.0
52+
io.grpc:grpc-googleapis:1.47.0
53+
io.grpc:grpc-grpclb:1.47.0
54+
io.grpc:grpc-netty-shaded:1.47.0
55+
io.grpc:grpc-protobuf-lite:1.47.0
56+
io.grpc:grpc-protobuf:1.47.0
57+
io.grpc:grpc-stub:1.47.0
58+
io.netty:netty-buffer:4.1.72.Final
59+
io.netty:netty-common:4.1.72.Final
60+
io.opencensus:opencensus-api:0.31.1
61+
io.opencensus:opencensus-contrib-http-util:0.31.1
62+
io.perfmark:perfmark-api:0.25.0
3563
javax.annotation:javax.annotation-api:1.3.2
36-
org.apache.httpcomponents:httpclient:4.5.11
37-
org.apache.httpcomponents:httpcore:4.4.13
64+
org.apache.arrow:arrow-format:8.0.0
65+
org.apache.arrow:arrow-memory-core:8.0.0
66+
org.apache.arrow:arrow-memory-netty:8.0.0
67+
org.apache.arrow:arrow-vector:8.0.0
68+
org.apache.httpcomponents:httpclient:4.5.13
69+
org.apache.httpcomponents:httpcore:4.4.15
3870
org.checkerframework:checker-compat-qual:2.5.5
71+
org.checkerframework:checker-qual:3.22.2
72+
org.codehaus.mojo:animal-sniffer-annotations:1.21
73+
org.conscrypt:conscrypt-openjdk-uber:2.5.1
74+
org.json:json:20200518
3975
org.slf4j:jcl-over-slf4j:1.7.12
40-
org.threeten:threetenbp:1.4.1
76+
org.slf4j:slf4j-api:1.7.25
77+
org.threeten:threeten-extra:1.7.0
78+
org.threeten:threetenbp:1.6.0

src/main/java/org/embulk/output/bigquery_java/BigqueryClient.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,21 @@ public void createTableIfNotExist(String table, String dataset) {
131131
public TimePartitioning buildTimePartitioning(BigqueryTimePartitioning bigqueryTimePartitioning) {
132132
TimePartitioning.Builder timePartitioningBuilder;
133133

134-
if (bigqueryTimePartitioning.getType().toUpperCase().equals("DAY")) {
135-
timePartitioningBuilder = TimePartitioning.newBuilder(TimePartitioning.Type.DAY);
136-
} else {
137-
throw new RuntimeException("time_partitioning.type is not DAY");
134+
switch (bigqueryTimePartitioning.getType().toUpperCase()) {
135+
case "HOUR":
136+
timePartitioningBuilder = TimePartitioning.newBuilder(TimePartitioning.Type.HOUR);
137+
break;
138+
case "DAY":
139+
timePartitioningBuilder = TimePartitioning.newBuilder(TimePartitioning.Type.DAY);
140+
break;
141+
case "MONTH":
142+
timePartitioningBuilder = TimePartitioning.newBuilder(TimePartitioning.Type.MONTH);
143+
break;
144+
case "YEAR":
145+
timePartitioningBuilder = TimePartitioning.newBuilder(TimePartitioning.Type.YEAR);
146+
break;
147+
default:
148+
throw new RuntimeException("time_partitioning.type is not HOUR, DAY, MONTH, or YEAR");
138149
}
139150

140151
if (bigqueryTimePartitioning.getExpirationMs().isPresent()) {

src/main/java/org/embulk/output/bigquery_java/config/BigqueryConfigValidator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ public static void validateModeAndAutoCreteTable(PluginTask task) throws ConfigE
2929

3030
public static void validateTimePartitioning(PluginTask task) throws ConfigException {
3131
if (task.getTimePartitioning().isPresent()) {
32-
if (!task.getTimePartitioning().get().getType().toUpperCase().equals("DAY")) {
33-
throw new ConfigException(String.format("`time_partitioning.type: %s` requires `time_partitioning.type: DAY`", task.getMode()));
32+
String[] types = {"HOUR", "DAY", "MONTH", "YEAR"};
33+
if (!Arrays.asList(types).contains(task.getTimePartitioning().get().getType().toUpperCase())) {
34+
throw new ConfigException("time_partitioning.type: HOUR, DAY, MONTH and YEAR are supported.");
3435
}
3536
}
3637
}

0 commit comments

Comments
 (0)