Skip to content
This repository was archived by the owner on Feb 24, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions samples/install-without-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</parent>

<properties>
<project.protobuf-java.version>3.25.4</project.protobuf-java.version>
Comment thread
PhongChuong marked this conversation as resolved.
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -64,6 +65,11 @@
<artifactId>exporter-metrics</artifactId>
<version>0.34.0</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java-util</artifactId>
<version>${project.protobuf-java.version}</version>
</dependency>

<dependency>
<groupId>junit</groupId>
Expand All @@ -81,6 +87,13 @@

<!-- compile and run all snippet tests -->
<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.7.1</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
Expand All @@ -95,6 +108,7 @@
<configuration>
<sources>
<source>../snippets/src/main/java</source>
<source>../snippets/src/main/proto</source>
</sources>
</configuration>
</execution>
Expand All @@ -111,6 +125,22 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:${project.protobuf-java.version}:exe:${os.detected.classifier}</protocArtifact>
<protoSourceRoot>../snippets/src/main/proto</protoSourceRoot>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
31 changes: 31 additions & 0 deletions samples/snapshot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</parent>

<properties>
<project.protobuf-java.version>3.25.4</project.protobuf-java.version>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -66,6 +67,12 @@
<version>0.34.0</version>
</dependency>

<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java-util</artifactId>
<version>${project.protobuf-java.version}</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -82,6 +89,13 @@

<!-- compile and run all snippet tests -->
<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.7.1</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
Expand All @@ -96,6 +110,7 @@
<configuration>
<sources>
<source>../snippets/src/main/java</source>
<source>../snippets/src/main/proto</source>
</sources>
</configuration>
</execution>
Expand All @@ -112,6 +127,22 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:${project.protobuf-java.version}:exe:${os.detected.classifier}</protocArtifact>
<protoSourceRoot>../snippets/src/main/proto</protoSourceRoot>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
33 changes: 33 additions & 0 deletions samples/snippets/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</parent>

<properties>
<project.protobuf-java.version>3.25.4</project.protobuf-java.version>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -81,6 +82,11 @@
<artifactId>exporter-metrics</artifactId>
<version>0.34.0</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java-util</artifactId>
<version>${project.protobuf-java.version}</version>
</dependency>


<!-- Test Dependencies -->
Expand All @@ -97,4 +103,31 @@
<scope>test</scope>
</dependency>
</dependencies>

<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.7.1</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:${project.protobuf-java.version}:exe:${os.detected.classifier}</protocArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.example.bigquerystorage;

// [START bigquerystorage_writenestedproto]
import com.google.api.core.ApiFuture;
import com.google.cloud.bigquery.storage.v1.AppendRowsResponse;
import com.google.cloud.bigquery.storage.v1.ProtoRows;
import com.google.cloud.bigquery.storage.v1.ProtoSchemaConverter;
import com.google.cloud.bigquery.storage.v1.StreamWriter;
import com.google.protobuf.Descriptors.DescriptorValidationException;
import java.io.IOException;
import java.util.concurrent.ExecutionException;

public class WriteNestedProto {

public static void runWriteNestedProto(String projectId, String datasetName, String tableName)
throws DescriptorValidationException, InterruptedException, IOException {
StreamWriter streamWriter =
StreamWriter.newBuilder(
"projects/"
+ projectId
+ "/datasets/"
+ datasetName
+ "/tables/"
+ tableName
+ "/_default")
.setWriterSchema(ProtoSchemaConverter.convert(HasNestedMessage.getDescriptor()))
.build();
ProtoRows protoRows =
ProtoRows.newBuilder()
.addSerializedRows(
HasNestedMessage.newBuilder()
.setFoo("foo")
.setBar(
HasNestedMessage.InnerMessage.newBuilder()
.setMyInt(12345)
.setMyString("bar")
.build())
.build()
.toByteString())
.addSerializedRows(
HasSeparateNestedMessage.newBuilder()
.setFoo("foo2")
.setBar(
SeparateMessage.newBuilder().setMyInt(123456).setMyString("bar2").build())
.build()
.toByteString())
.build();
ApiFuture<AppendRowsResponse> future = streamWriter.append(protoRows);
try {
AppendRowsResponse response = future.get();
System.out.println("Appended records successfully.");
} catch (ExecutionException e) {
System.out.println(e);
}
}
}
// [END bigquerystorage_writenestedproto]
40 changes: 40 additions & 0 deletions samples/snippets/src/main/proto/nested.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

syntax = "proto3";
package nestedprotos;

import "separate.proto";

option java_multiple_files = true;
option java_package = "com.example.bigquerystorage";
option java_outer_classname = "NestedProtos";

message HasNestedMessage {
optional string foo = 1;

message InnerMessage {
optional int64 my_int = 1;
optional string my_string = 2;
}

optional InnerMessage bar = 2;
}

message HasSeparateNestedMessage {
optional string foo = 1;
optional SeparateMessage bar = 2;
}
27 changes: 27 additions & 0 deletions samples/snippets/src/main/proto/separate.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

syntax = "proto3";
package nestedprotos;

option java_multiple_files = true;
option java_package = "com.example.bigquerystorage";
option java_outer_classname = "SeparateProtos";

message SeparateMessage {
optional int64 my_int = 1;
optional string my_string = 2;
}
Loading
Loading