Skip to content

Commit 09b9c47

Browse files
authored
Add @SchemaFieldDescription annotations and description to Bigtable config (#36344)
* Add @SchemaFieldDescription annotations and description to Bigtable config fields * Fix formatting using spotless
1 parent 7586658 commit 09b9c47

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableReadSchemaTransformProvider.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.apache.beam.sdk.schemas.AutoValueSchema;
3636
import org.apache.beam.sdk.schemas.Schema;
3737
import org.apache.beam.sdk.schemas.annotations.DefaultSchema;
38+
import org.apache.beam.sdk.schemas.annotations.SchemaFieldDescription;
3839
import org.apache.beam.sdk.schemas.transforms.SchemaTransform;
3940
import org.apache.beam.sdk.schemas.transforms.SchemaTransformProvider;
4041
import org.apache.beam.sdk.schemas.transforms.TypedSchemaTransformProvider;
@@ -89,6 +90,19 @@ public String identifier() {
8990
return "beam:schematransform:org.apache.beam:bigtable_read:v1";
9091
}
9192

93+
@Override
94+
public String description() {
95+
return "Reads data from a Google Cloud Bigtable table.\n"
96+
+ "The transform requires the project ID, instance ID, and table ID parameters.\n"
97+
+ "Optionally, the output can be flattened or nested rows.\n"
98+
+ "Example usage:\n"
99+
+ " - type: ReadFromBigTable\n"
100+
+ " config:\n"
101+
+ " project: \"my-gcp-project\"\n"
102+
+ " instance: \"my-bigtable-instance\"\n"
103+
+ " table: \"my-table\"\n";
104+
}
105+
92106
@Override
93107
public List<String> outputCollectionNames() {
94108
return Collections.singletonList(OUTPUT_TAG);
@@ -113,12 +127,17 @@ public static Builder builder() {
113127
.setFlatten(true);
114128
}
115129

130+
@SchemaFieldDescription("Bigtable table ID to read from.")
116131
public abstract String getTableId();
117132

133+
@SchemaFieldDescription("Bigtable instance ID to connect to.")
118134
public abstract String getInstanceId();
119135

136+
@SchemaFieldDescription("Google Cloud project ID containing the Bigtable instance.")
120137
public abstract String getProjectId();
121138

139+
@SchemaFieldDescription(
140+
"If set to false, output rows are nested; if true or omitted, output rows are flattened.")
122141
public abstract @Nullable Boolean getFlatten();
123142

124143
/** Builder for the {@link BigtableReadSchemaTransformConfiguration}. */

sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableWriteSchemaTransformProvider.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.apache.beam.sdk.schemas.AutoValueSchema;
3838
import org.apache.beam.sdk.schemas.Schema;
3939
import org.apache.beam.sdk.schemas.annotations.DefaultSchema;
40+
import org.apache.beam.sdk.schemas.annotations.SchemaFieldDescription;
4041
import org.apache.beam.sdk.schemas.transforms.SchemaTransform;
4142
import org.apache.beam.sdk.schemas.transforms.SchemaTransformProvider;
4243
import org.apache.beam.sdk.schemas.transforms.TypedSchemaTransformProvider;
@@ -83,6 +84,20 @@ public String identifier() {
8384
return "beam:schematransform:org.apache.beam:bigtable_write:v1";
8485
}
8586

87+
@Override
88+
public String description() {
89+
return "Writes data to a Google Cloud Bigtable table.\n"
90+
+ "This transform requires the Google Cloud project ID, Bigtable instance ID, and table ID.\n"
91+
+ "The input PCollection should be schema-compliant mutations or keyed rows.\n"
92+
+ "Example usage:\n"
93+
+ " - type: WriteToBigTable\n"
94+
+ " input: input\n"
95+
+ " config:\n"
96+
+ " project: \"my-gcp-project\"\n"
97+
+ " instance: \"my-bigtable-instance\"\n"
98+
+ " table: \"my-table\"\n";
99+
}
100+
86101
@Override
87102
public List<String> inputCollectionNames() {
88103
return Collections.singletonList(INPUT_TAG);
@@ -108,10 +123,13 @@ public void validate() {
108123
checkArgument(!this.getProjectId().isEmpty(), String.format(invalidConfigMessage, "project"));
109124
}
110125

126+
@SchemaFieldDescription("Bigtable table ID to write data into.")
111127
public abstract String getTableId();
112128

129+
@SchemaFieldDescription("Bigtable instance ID where the table is located.")
113130
public abstract String getInstanceId();
114131

132+
@SchemaFieldDescription("Google Cloud project ID containing the Bigtable instance.")
115133
public abstract String getProjectId();
116134

117135
/** Builder for the {@link BigtableWriteSchemaTransformConfiguration}. */

0 commit comments

Comments
 (0)