github-actions[bot] commented on code in PR #41750:
URL: https://github.com/apache/beam/pull/41750#discussion_r4732361729
##########
website/www/site/content/en/documentation/patterns/file-processing.md:
##########
@@ -104,3 +104,17 @@ To read filenames in a pipeline job:
{{< highlight py >}}
{{< code_sample "sdks/python/apache_beam/examples/snippets/snippets.py"
FileProcessPatternAccessMetadataSnip1 >}}
{{< /highlight >}}
+
+## Writing files to dynamic destinations
+
+{{< paragraph class="language-java" >}}
+Use `FileIO.writeDynamic()` to write the elements of a `PCollection` to
different files depending on the element, for example one set of Avro files for
each value of a field. Call `by()` to compute the destination of each element,
`via()` to choose how the elements of one destination are written (here
`AvroIO.sink`), `to()` for the output directory and `withNaming()` for the file
names of each destination.
+{{< /paragraph >}}
+
+{{< paragraph class="language-java" >}}
+Beam needs a coder for the destination type so it can group the elements by
destination. When you pass a lambda to `by()`, the destination type is erased
and Beam cannot infer it, so pipeline construction fails with an `Unable to
infer a coder for destination type` error. Specify the coder with
`withDestinationCoder()`, as in the last line of the following example.
+{{< /paragraph >}}
+
+{{< highlight java >}}
+{{< code_sample
"examples/java/src/main/java/org/apache/beam/examples/snippets/Snippets.java"
FileProcessPatternWriteDynamicSnip1 >}}
+{{< /highlight >}}
Review Comment:
**🟢 Low**: Since this page uses `{{< language-switcher java py >}}`,
switching to the Python tab renders the `## Writing files to dynamic
destinations` heading with no body content underneath it. Consider adding a
`language-py` paragraph (similar to the continuous-read section above, or
pointing to `apache_beam.io.fileio.WriteToFiles`) so Python users don't see an
empty section.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]