[ 
https://issues.apache.org/jira/browse/BEAM-5918?focusedWorklogId=162653&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-162653
 ]

ASF GitHub Bot logged work on BEAM-5918:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 05/Nov/18 18:23
            Start Date: 05/Nov/18 18:23
    Worklog Time Spent: 10m 
      Work Description: kennknowles commented on a change in pull request 
#6888: [BEAM-5918] Add Cast transform for Rows
URL: https://github.com/apache/beam/pull/6888#discussion_r230854619
 
 

 ##########
 File path: sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/Schema.java
 ##########
 @@ -338,6 +338,47 @@ public boolean isMapType() {
     public boolean isCompositeType() {
       return COMPOSITE_TYPES.contains(this);
     }
+
+    public boolean isSubtypeOf(TypeName other) {
+      return other.isSupertypeOf(this);
+    }
+
+    public boolean isSupertypeOf(TypeName other) {
 
 Review comment:
   In #6861 nullability is added for array elements and map values. It isn't 
expressed in the most natural "type system" way, but we should move towards 
treating a nullable `T` as `OPTIONAL<T>` with automatic coercion to `T` rather 
than treating it as just a `T` with nullability as a side condition. It 
requires a fairly significant refactor to do so. Just something to keep in 
mind. It would affect this sub/supertype check.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 162653)
    Time Spent: 4h 20m  (was: 4h 10m)

> Add Cast transform for Rows
> ---------------------------
>
>                 Key: BEAM-5918
>                 URL: https://issues.apache.org/jira/browse/BEAM-5918
>             Project: Beam
>          Issue Type: Improvement
>          Components: sdk-java-core
>            Reporter: Gleb Kanterov
>            Assignee: Gleb Kanterov
>            Priority: Major
>          Time Spent: 4h 20m
>  Remaining Estimate: 0h
>
> There is a need for a generic transform that given two Row schemas will 
> convert rows between them. There must be a possibility to opt-out from 
> certain kind of conversions, for instance, converting ints to shorts can 
> cause overflow. Another example, a schema could have a nullable field, but 
> never have NULL value in practice, because it was filtered out.
> What is needed:
> - widening values (e.g., int -> long)
> - narrowwing (e.g., int -> short)
> - runtime check for overflow while narrowing
> - ignoring nullability (nullable=true -> nullable=false)
> - weakening nullability (nullable=false -> nullable=true)
> - projection (Schema(a: Int32, b: Int32) -> Schema(a: Int32))



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to