Skip to content

Commit

Permalink
Pass Java SchemaTransform descriptions to Python SDK (#29606)
Browse files Browse the repository at this point in the history
* pipe thru schematransform descriptions
  • Loading branch information
ahmedabu98 authored Dec 10, 2023
1 parent aafa3b8 commit a96fa74
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ public interface SchemaTransformProvider {
/** Returns an id that uniquely represents this transform. */
String identifier();

/** Returns a description of this transform to be used for documentation. */
/**
* Returns a description regarding the {@link SchemaTransform} represented by the {@link
* SchemaTransformProvider}. Please keep the language generic (i.e. not specific to any
* programming language). The description may be markdown formatted.
*/
default String description() {
return "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ public String identifier() {
return "fake:v1";
}

@Override
public String description() {
return "Description of fake provider";
}

@Override
protected Class<Configuration> configurationClass() {
return Configuration.class;
Expand Down Expand Up @@ -115,6 +120,7 @@ public void testFrom() {
Configuration outputConfig = ((FakeSchemaTransform) provider.from(inputConfig)).config;
assertEquals("field1", outputConfig.getField1());
assertEquals(13, outputConfig.getField2().intValue());
assertEquals("Description of fake provider", provider.description());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ public String identifier() {
return String.format("beam:schematransform:org.apache.beam:bigquery_storage_write:v2");
}

@Override
public String description() {
return String.format(
"Writes data to BigQuery using the Storage Write API (https://cloud.google.com/bigquery/docs/write-api)."
+ "\n\nThis expects a single PCollection of Beam Rows and outputs two dead-letter queues (DLQ) that "
+ "contain failed rows. The first DLQ has tag [%s] and contains the failed rows. The second DLQ has "
+ "tag [%s] and contains failed rows and along with their respective errors.",
FAILED_ROWS_TAG, FAILED_ROWS_WITH_ERRORS_TAG);
}

@Override
public List<String> inputCollectionNames() {
return Collections.singletonList(INPUT_ROWS_TAG);
Expand Down

0 comments on commit a96fa74

Please sign in to comment.