chamikaramj commented on code in PR #30460:
URL: https://github.com/apache/beam/pull/30460#discussion_r1521798958


##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIO.java:
##########
@@ -2826,8 +2826,18 @@ public Write<T> 
withJsonTimePartitioning(ValueProvider<String> partitioning) {
      * tables, the fields here will be ignored; call {@link #withClustering()} 
instead.
      */
     public Write<T> withClustering(Clustering clustering) {
+      return 
withJsonClustering(StaticValueProvider.of(BigQueryHelpers.toJsonString(clustering)));
+    }
+
+    /** Like {@link #withClustering(Clustering)} but using a deferred {@link 
ValueProvider}. */
+    public Write<T> withClustering(ValueProvider<Clustering> clustering) {
+      return withJsonClustering(NestedValueProvider.of(clustering, 
BigQueryHelpers::toJsonString));
+    }
+
+    /** The same as {@link #withClustering(Clustering)}, but takes a 
JSON-serialized object. */

Review Comment:
   Can we give an example as to how the string should be formatted and what 
fields should be there ?



##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIOTranslation.java:
##########
@@ -455,8 +454,8 @@ public Row toConfigRow(Write<?> transform) {
         fieldValues.put(
             "json_time_partitioning", 
toByteArray(transform.getJsonTimePartitioning().get()));
       }
-      if (transform.getClustering() != null) {
-        fieldValues.put("clustering", toByteArray(transform.getClustering()));
+      if (transform.getJsonClustering() != null) {

Review Comment:
   Yeah, it will since old Beam versions will not have this field.
   
   We have to fork when using this field to maintain compatibility.
   
   Please see the change to BigQueryIOTranslation below for an example.
   
   
https://github.com/apache/beam/commit/32f38b92c3652058b0191b94105e0b9441ab965e



-- 
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]

Reply via email to