prodriguezdefino commented on code in PR #24274:
URL: https://github.com/apache/beam/pull/24274#discussion_r1040387642
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIO.java:
##########
@@ -540,7 +540,15 @@ public class BigQueryIO {
* A formatting function that maps a TableRow to itself. This allows sending
a {@code
* PCollection<TableRow>} directly to BigQueryIO.Write.
*/
- static final SerializableFunction<TableRow, TableRow> IDENTITY_FORMATTER =
input -> input;
+ static final SerializableFunction<TableRow, TableRow>
TABLE_ROW_IDENTITY_FORMATTER =
+ input -> input;
+
+ /**
+ * A formatting function that maps a GenericRecord to itself. This allows
sending a {@code
+ * PCollection<GenericRecord>} directly to BigQueryIO.Write.
+ */
+ static final SerializableFunction<AvroWriteRequest<GenericRecord>,
GenericRecord>
+ GENERIC_RECORD_IDENTITY_FORMATTER = input -> input.getElement();
Review Comment:
Done.
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIO.java:
##########
@@ -540,7 +540,15 @@ public class BigQueryIO {
* A formatting function that maps a TableRow to itself. This allows sending
a {@code
* PCollection<TableRow>} directly to BigQueryIO.Write.
*/
- static final SerializableFunction<TableRow, TableRow> IDENTITY_FORMATTER =
input -> input;
+ static final SerializableFunction<TableRow, TableRow>
TABLE_ROW_IDENTITY_FORMATTER =
+ input -> input;
Review Comment:
Done.
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIO.java:
##########
@@ -1925,7 +1933,19 @@ public static <T> Write<T> write() {
* Write#withFormatFunction(SerializableFunction)}.
*/
public static Write<TableRow> writeTableRows() {
- return BigQueryIO.<TableRow>write().withFormatFunction(IDENTITY_FORMATTER);
+ return
BigQueryIO.<TableRow>write().withFormatFunction(TABLE_ROW_IDENTITY_FORMATTER);
+ }
+
+ /**
+ * A {@link PTransform} that writes a {@link PCollection} containing {@link
GenericRecord
+ * GenericRecords} to a BigQuery table.
+ *
+ * <p>It is recommended to instead use {@link #write} with {@link
+ * Write#withFormatFunction(SerializableFunction)}.
Review Comment:
Removed, it was copied from the `writeTableRows` method.
--
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]