reuvenlax commented on a change in pull request #16988:
URL: https://github.com/apache/beam/pull/16988#discussion_r819932131



##########
File path: sdks/java/core/src/main/java/org/apache/beam/sdk/values/Row.java
##########
@@ -108,11 +109,32 @@
   /** Return the list of data values. */
   public abstract List<Object> getValues();
 
+  /** This is recursive call to get all the values of the nested rows.
+  The recusion is bounded by the amount of nesting with in the data
+   This mirrors the unnest behavior of calcite towards schema **/
+  public List<Object> getNestedRowBaseValues() {
+    return IntStream.range(0, getFieldCount())
+            .mapToObj(i -> {
+              List<Object> values = new ArrayList<>();
+              FieldType fieldType = this.getSchema().getField(i).getType();
+              if(fieldType.getTypeName().equals(TypeName.ROW)) {
+                Row row = this.getBaseValue(i, Row.class);
+                List<Object> rowValues = row.getNestedRowBaseValues();
+                if(null != rowValues) {
+                  values.addAll(rowValues);
+                }
+              } else {
+                values.add(this.getBaseValue(i));
+              }
+              return values.stream();
+            }).flatMap(Function.identity()).collect(Collectors.toList());
+  }

Review comment:
       Agree - Row is used by Beam users who don't use SQL. We should not be 
adding SQL-specific code inside Row.




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