Skip to content

Commit eac7bc7

Browse files
committed
[bq] update BigQuery module to Spring boot 4
1 parent 2db69f0 commit eac7bc7

File tree

30 files changed

+272
-124
lines changed

30 files changed

+272
-124
lines changed

spring-batch-bigquery/pom.xml

100644100755
Lines changed: 65 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<parent>
2323
<groupId>org.springframework.boot</groupId>
2424
<artifactId>spring-boot-starter-parent</artifactId>
25-
<version>3.5.6</version>
25+
<version>4.0.0</version>
2626
<relativePath/>
2727
</parent>
2828

@@ -49,6 +49,10 @@
4949
</developer>
5050
</developers>
5151

52+
<properties>
53+
<avro.version>1.12.1</avro.version>
54+
</properties>
55+
5256
<scm>
5357
<url>https://github.com/spring-projects/spring-batch-extensions</url>
5458
<connection>git://github.com/spring-projects/spring-batch-extensions.git</connection>
@@ -60,7 +64,7 @@
6064
<dependency>
6165
<groupId>com.google.cloud</groupId>
6266
<artifactId>google-cloud-bigquery</artifactId>
63-
<version>2.51.0</version>
67+
<version>2.56.0</version>
6468
<exclusions>
6569
<!-- Avoid version conflicts -->
6670
<exclusion>
@@ -76,26 +80,47 @@
7680

7781
<!-- Optional -->
7882
<dependency>
79-
<groupId>com.fasterxml.jackson.dataformat</groupId>
83+
<groupId>tools.jackson.dataformat</groupId>
8084
<artifactId>jackson-dataformat-csv</artifactId>
8185
<optional>true</optional>
8286
</dependency>
87+
<dependency>
88+
<groupId>tools.jackson.core</groupId>
89+
<artifactId>jackson-databind</artifactId>
90+
<optional>true</optional>
91+
</dependency>
92+
<dependency>
93+
<groupId>tools.jackson.core</groupId>
94+
<artifactId>jackson-core</artifactId>
95+
<optional>true</optional>
96+
</dependency>
97+
8398
<dependency>
8499
<groupId>org.apache.parquet</groupId>
85100
<artifactId>parquet-avro</artifactId>
86-
<version>1.15.2</version>
101+
<version>1.16.0</version>
87102
<optional>true</optional>
88103
<exclusions>
89104
<exclusion>
90105
<groupId>org.slf4j</groupId>
91106
<artifactId>*</artifactId>
92107
</exclusion>
108+
<exclusion>
109+
<groupId>org.apache.avro</groupId>
110+
<artifactId>avro</artifactId>
111+
</exclusion>
93112
</exclusions>
94113
</dependency>
114+
<dependency>
115+
<groupId>org.apache.avro</groupId>
116+
<artifactId>avro</artifactId>
117+
<version>${avro.version}</version>
118+
</dependency>
119+
95120
<dependency>
96121
<groupId>org.apache.hadoop</groupId>
97122
<artifactId>hadoop-common</artifactId>
98-
<version>3.4.1</version>
123+
<version>3.4.2</version>
99124
<optional>true</optional>
100125
<exclusions>
101126
<!-- End implementation should not be forced by library -->
@@ -125,6 +150,10 @@
125150
<groupId>org.xerial.snappy</groupId>
126151
<artifactId>snappy-java</artifactId>
127152
</exclusion>
153+
<exclusion>
154+
<groupId>commons-io</groupId>
155+
<artifactId>commons-io</artifactId>
156+
</exclusion>
128157
</exclusions>
129158
</dependency>
130159

@@ -152,6 +181,7 @@
152181
<dependency>
153182
<groupId>org.testcontainers</groupId>
154183
<artifactId>junit-jupiter</artifactId>
184+
<version>1.21.3</version>
155185
<scope>test</scope>
156186
<exclusions>
157187
<!-- Avoid version conflicts -->
@@ -164,7 +194,7 @@
164194
<dependency>
165195
<groupId>org.wiremock</groupId>
166196
<artifactId>wiremock-standalone</artifactId>
167-
<version>3.13.1</version>
197+
<version>3.13.2</version>
168198
<scope>test</scope>
169199
</dependency>
170200
<dependency>
@@ -201,6 +231,11 @@
201231
<goals>
202232
<goal>jar</goal>
203233
</goals>
234+
<configuration>
235+
<excludes>
236+
<exclude>org.springframework.batch.extensions.bigquery.common.generated.*</exclude>
237+
</excludes>
238+
</configuration>
204239
</execution>
205240
</executions>
206241
</plugin>
@@ -222,7 +257,7 @@
222257
<plugin>
223258
<groupId>org.codehaus.mojo</groupId>
224259
<artifactId>flatten-maven-plugin</artifactId>
225-
<version>1.7.1</version>
260+
<version>1.7.3</version>
226261
<executions>
227262
<execution>
228263
<id>flatten</id>
@@ -267,17 +302,35 @@
267302
<plugin>
268303
<groupId>org.apache.avro</groupId>
269304
<artifactId>avro-maven-plugin</artifactId>
270-
<version>1.12.0</version>
305+
<version>${avro.version}</version>
271306
<executions>
272307
<execution>
273-
<id>schemas</id>
274-
<phase>generate-sources</phase>
308+
<phase>generate-test-sources</phase>
275309
<goals>
276310
<goal>schema</goal>
277311
</goals>
278312
<configuration>
279-
<sourceDirectory>${project.basedir}/src/test/resources/</sourceDirectory>
280-
<outputDirectory>${project.basedir}/target/generated-test-sources/avro/</outputDirectory>
313+
<sourceDirectory>${project.basedir}/src/test/resources</sourceDirectory>
314+
<outputDirectory>${project.build.directory}/generated-test-sources/avro</outputDirectory>
315+
</configuration>
316+
</execution>
317+
</executions>
318+
</plugin>
319+
<!-- Copies classes from generated-test-sources to test-classes -->
320+
<plugin>
321+
<groupId>org.codehaus.mojo</groupId>
322+
<artifactId>build-helper-maven-plugin</artifactId>
323+
<version>3.6.1</version>
324+
<executions>
325+
<execution>
326+
<phase>generate-test-sources</phase>
327+
<goals>
328+
<goal>add-test-source</goal>
329+
</goals>
330+
<configuration>
331+
<sources>
332+
<source>${project.build.directory}/generated-test-sources/avro</source>
333+
</sources>
281334
</configuration>
282335
</execution>
283336
</executions>

spring-batch-bigquery/src/main/java/org/springframework/batch/extensions/bigquery/reader/BigQueryQueryItemReader.java

100644100755
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import com.google.cloud.bigquery.QueryJobConfiguration;
2222
import org.apache.commons.logging.Log;
2323
import org.apache.commons.logging.LogFactory;
24-
import org.springframework.batch.item.ItemReader;
24+
import org.springframework.batch.infrastructure.item.ItemReader;
2525
import org.springframework.beans.factory.InitializingBean;
2626
import org.springframework.core.convert.converter.Converter;
2727
import org.springframework.util.Assert;
@@ -64,6 +64,12 @@ public class BigQueryQueryItemReader<T> implements ItemReader<T>, InitializingBe
6464

6565
private Iterator<FieldValueList> iterator;
6666

67+
/**
68+
* Default constructor
69+
*/
70+
public BigQueryQueryItemReader() {
71+
}
72+
6773
/**
6874
* BigQuery service, responsible for API calls.
6975
* @param bigQuery BigQuery service

spring-batch-bigquery/src/main/java/org/springframework/batch/extensions/bigquery/reader/builder/BigQueryQueryItemReaderBuilder.java

100644100755
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ public class BigQueryQueryItemReaderBuilder<T> {
4848

4949
private Class<T> targetType;
5050

51+
/**
52+
* Default constructor
53+
*/
54+
public BigQueryQueryItemReaderBuilder() {
55+
}
56+
5157
/**
5258
* BigQuery service, responsible for API calls.
5359
* @param bigQuery BigQuery service

spring-batch-bigquery/src/main/java/org/springframework/batch/extensions/bigquery/reader/builder/RecordMapper.java

100644100755
Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,25 @@ public final class RecordMapper<T> {
3535

3636
private final SimpleTypeConverter simpleConverter = new SimpleTypeConverter();
3737

38+
/**
39+
* Default constructor
40+
*/
41+
public RecordMapper() {
42+
}
43+
3844
/**
3945
* Generates a conversion from BigQuery response to a Java record.
40-
* @param targetType a Java record {@link Class}
46+
* @param targetType a {@link Record}
4147
* @return {@link Converter}
42-
* @see org.springframework.batch.item.file.mapping.RecordFieldSetMapper
48+
* @see org.springframework.batch.infrastructure.item.file.mapping.RecordFieldSetMapper
4349
*/
44-
public Converter<FieldValueList, T> generateMapper(Class<T> targetType) {
45-
Constructor<T> constructor = BeanUtils.getResolvableConstructor(targetType);
50+
public Converter<FieldValueList, T> generateMapper(final Class<T> targetType) {
51+
final Constructor<T> constructor = BeanUtils.getResolvableConstructor(targetType);
4652
Assert.isTrue(constructor.getParameterCount() > 0, "Record without fields is redundant");
4753

48-
String[] parameterNames = BeanUtils.getParameterNames(constructor);
49-
Class<?>[] parameterTypes = constructor.getParameterTypes();
50-
51-
Object[] args = new Object[parameterNames.length];
54+
final String[] parameterNames = BeanUtils.getParameterNames(constructor);
55+
final Class<?>[] parameterTypes = constructor.getParameterTypes();
56+
final Object[] args = new Object[parameterNames.length];
5257

5358
return source -> {
5459
if (args[0] == null) {

spring-batch-bigquery/src/main/java/org/springframework/batch/extensions/bigquery/writer/BigQueryItemWriterException.java

100644100755
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
package org.springframework.batch.extensions.bigquery.writer;
1818

19-
import org.springframework.batch.item.Chunk;
20-
import org.springframework.batch.item.ItemWriter;
21-
import org.springframework.batch.item.ItemWriterException;
19+
import org.springframework.batch.infrastructure.item.Chunk;
20+
import org.springframework.batch.infrastructure.item.ItemWriter;
21+
import org.springframework.batch.infrastructure.item.ItemWriterException;
2222

2323
/**
2424
* Unchecked {@link Exception} indicating that an error has occurred on during
@@ -35,15 +35,15 @@ public class BigQueryItemWriterException extends ItemWriterException {
3535
* @param message the message for this {@link Exception}
3636
* @param cause the other {@link Exception}
3737
*/
38-
public BigQueryItemWriterException(String message, Throwable cause) {
38+
public BigQueryItemWriterException(final String message, final Throwable cause) {
3939
super(message, cause);
4040
}
4141

4242
/**
4343
* Create a new {@link BigQueryItemWriterException} based on a message.
4444
* @param message the message for this {@link Exception}
4545
*/
46-
public BigQueryItemWriterException(String message) {
46+
public BigQueryItemWriterException(final String message) {
4747
super(message);
4848
}
4949

spring-batch-bigquery/src/main/java/org/springframework/batch/extensions/bigquery/writer/loadjob/BigQueryLoadJobBaseItemWriter.java

100644100755
Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,20 @@
1616

1717
package org.springframework.batch.extensions.bigquery.writer.loadjob;
1818

19-
import com.google.cloud.bigquery.*;
19+
import com.google.cloud.bigquery.BigQuery;
20+
import com.google.cloud.bigquery.DatasetInfo;
21+
import com.google.cloud.bigquery.FormatOptions;
22+
import com.google.cloud.bigquery.Job;
23+
import com.google.cloud.bigquery.Table;
24+
import com.google.cloud.bigquery.TableDataWriteChannel;
25+
import com.google.cloud.bigquery.TableDefinition;
26+
import com.google.cloud.bigquery.TableId;
27+
import com.google.cloud.bigquery.WriteChannelConfiguration;
2028
import org.apache.commons.logging.Log;
2129
import org.apache.commons.logging.LogFactory;
2230
import org.springframework.batch.extensions.bigquery.writer.BigQueryItemWriterException;
23-
import org.springframework.batch.item.Chunk;
24-
import org.springframework.batch.item.ItemWriter;
31+
import org.springframework.batch.infrastructure.item.Chunk;
32+
import org.springframework.batch.infrastructure.item.ItemWriter;
2533
import org.springframework.beans.factory.InitializingBean;
2634
import org.springframework.util.Assert;
2735

@@ -43,6 +51,12 @@
4351
*/
4452
public abstract class BigQueryLoadJobBaseItemWriter<T> implements ItemWriter<T>, InitializingBean {
4553

54+
/**
55+
* Default constructor
56+
*/
57+
protected BigQueryLoadJobBaseItemWriter() {
58+
}
59+
4660
/** Logger that can be reused */
4761
protected final Log logger = LogFactory.getLog(getClass());
4862

0 commit comments

Comments
 (0)