You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Spring Batch extension which contains an `ItemWriter` implementation for https://cloud.google.com/bigquery[BigQuery] based on https://github.com/googleapis/java-bigquery[Java BigQuery].
4
-
It supports writing https://en.wikipedia.org/wiki/Comma-separated_values[CSV], https://en.wikipedia.org/wiki/JSON[JSON] using https://cloud.google.com/bigquery/docs/batch-loading-data[load jobs].
3
+
Spring Batch extension which contains an `ItemWriter` and `ItemReader` implementations for https://cloud.google.com/bigquery[BigQuery].
5
4
6
-
== Configuration of `BigQueryCsvItemWriter`
5
+
`ItemWriter` supports next formats (https://cloud.google.com/bigquery/docs/batch-loading-data[load jobs]):
7
6
8
-
Next to the https://docs.spring.io/spring-batch/reference/html/configureJob.html[configuration of Spring Batch] one needs to configure the `BigQueryCsvItemWriter`.
BigQueryCsvItemWriter<MyDto> writer = new BigQueryCsvItemWriterBuilder<MyDto>()
21
-
.bigQuery(mockedBigQuery)
24
+
return new BigQueryCsvItemWriterBuilder<MyDto>()
25
+
.bigQuery(bigQueryService)
22
26
.writeChannelConfig(writeConfiguration)
23
27
.build();
24
28
}
25
29
----
26
30
27
-
Additional examples could be found in https://github.com/spring-projects/spring-batch-extensions/blob/main/spring-batch-bigquery/src/test/java/org/springframework/batch/extensions/bigquery/writer/builder/[here].
31
+
== Example of `BigQueryItemReader`
28
32
29
-
== Configuration properties
30
-
[cols="1,1,4"]
31
-
.Properties for an item writer
32
-
|===
33
-
| Property | Required | Description
33
+
[source,java]
34
+
----
35
+
@Bean
36
+
BigQueryItemReader<PersonDto> bigQueryReader() {
37
+
return new BigQueryQueryItemReaderBuilder<PersonDto>()
38
+
.bigQuery(bigQueryService)
39
+
.rowMapper(res -> new PersonDto(res.get("name").getStringValue()))
40
+
.query("SELECT p.name FROM persons p")
41
+
.build();
42
+
}
43
+
----
34
44
35
-
| `bigQuery` | yes | BigQuery object that provided by BigQuery Java Library. Responsible for connection with BigQuery.
36
-
| `writeChannelConfig` | yes | BigQuery write channel config provided by BigQuery Java Library. Responsible for configuring data type, data channel, jobs that will be sent to BigQuery.
37
-
| `rowMapper` | no | Your own converter that specifies how to convert input CSV / JSON to a byte array.
38
-
| `datasetInfo` | no | Your way to customize how to create BigQuery dataset.
39
-
| `jobConsumer` | no | Your custom handler for BigQuery Job provided by BigQuery Java Library.
40
-
|===
45
+
Additional examples could be found in the https://github.com/spring-projects/spring-batch-extensions/tree/main/spring-batch-bigquery/src/test/java/org/springframework/batch/extensions/bigquery[test folder].
Copy file name to clipboardExpand all lines: spring-batch-bigquery/src/main/java/org/springframework/batch/extensions/bigquery/reader/BigQueryQueryItemReader.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* Copyright 2002-2024 the original author or authors.
2
+
* Copyright 2002-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -64,7 +64,7 @@ public void setBigQuery(BigQuery bigQuery) {
64
64
}
65
65
66
66
/**
67
-
* Row mapper which transforms single BigQuery row into desired type.
67
+
* Row mapper which transforms single BigQuery row into a desired type.
Copy file name to clipboardExpand all lines: spring-batch-bigquery/src/main/java/org/springframework/batch/extensions/bigquery/reader/builder/BigQueryQueryItemReaderBuilder.java
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* Copyright 2002-2024 the original author or authors.
2
+
* Copyright 2002-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
Copy file name to clipboardExpand all lines: spring-batch-bigquery/src/main/java/org/springframework/batch/extensions/bigquery/writer/BigQueryBaseItemWriter.java
+41-35Lines changed: 41 additions & 35 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* Copyright 2002-2024 the original author or authors.
2
+
* Copyright 2002-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
0 commit comments