reuvenlax commented on a change in pull request #11074: Store logical type 
values in Row instead of base values
URL: https://github.com/apache/beam/pull/11074#discussion_r390766044
 
 

 ##########
 File path: sdks/java/core/src/main/java/org/apache/beam/sdk/values/Row.java
 ##########
 @@ -362,7 +371,24 @@ public Boolean getBoolean(int idx) {
   @Nullable
   public <T> T getLogicalTypeValue(int idx, Class<T> clazz) {
     LogicalType logicalType = 
checkNotNull(getSchema().getField(idx).getType().getLogicalType());
-    return (T) logicalType.toInputType(getValue(idx));
+    return (T) getValue(idx);
+  }
+
+  /**
+   * Returns the Logical Type base type for this field. If there are multiple 
nested logical types,
+   * they are all resolved to the first non-logical type. {@link 
IllegalStateException} is thrown if
+   * schema doesn't match.
+   */
+  @Nullable
+  public <T> T getLogicalTypeBaseValue(int idx, Class<T> clazz) {
+    Object value = getValue(idx);
+    FieldType fieldType = getSchema().getField(idx).getType();
+    checkArgument(fieldType.getTypeName().isLogicalType());
+    while (fieldType.getTypeName().isLogicalType()) {
+      value = fieldType.getLogicalType().toBaseType(value);
 
 Review comment:
   good catch, we should.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to