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

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

                Author: ASF GitHub Bot
            Created on: 26/Mar/19 14:38
            Start Date: 26/Mar/19 14:38
    Worklog Time Spent: 10m 
      Work Description: kanterov commented on issue #8006: [BEAM-6772] Change 
Select semantics to match what a user expects
URL: https://github.com/apache/beam/pull/8006#issuecomment-476675958
 
 
   @reuvenlax I've tried the following test:
   ```
     @Test
     public void testSelectFieldOfRecord() {
       Schema f1 = Schema.builder().addInt64Field("f0").build();
       Schema f2 = Schema.builder().addRowField("f1", f1).build();
       Schema f3 = Schema.builder().addRowField("f2", f2).build();
       
       Row r1 = Row.withSchema(f1).addValue(42L).build(); // {"f0": 42}
       Row r2 = Row.withSchema(f2).addValue(r1).build();  // {"f1": {"f0": 42}}
       Row r3 = Row.withSchema(f3).addValue(r2).build();  // {"f2": {"f1": 
{"f0": 42}}}
   
       FieldAccessDescriptor fieldAccessDescriptor = FieldAccessDescriptor
           .withFieldNames("f2.f1")
           .resolve(f3);
   
       Schema outputSchema = SelectHelpers.getOutputSchema(f3, 
fieldAccessDescriptor);
   
       Row out = SelectHelpers.selectRow(r3, fieldAccessDescriptor, 
r3.getSchema(), outputSchema);
   
       assertEquals(outputSchema, f2);
       assertEquals(out, r2);
     }
   ```
   
   And it fails with an exception:
   
   ```
   ava.lang.IllegalArgumentException: For field name f0 and type INT64 found 
incorrect class type class org.apache.beam.sdk.values.RowWithStorage
        at 
org.apache.beam.sdk.values.Row$Builder.verifyPrimitiveType(Row.java:724)
        at org.apache.beam.sdk.values.Row$Builder.verify(Row.java:587)
        at org.apache.beam.sdk.values.Row$Builder.verify(Row.java:571)
        at org.apache.beam.sdk.values.Row$Builder.build(Row.java:748)
        at 
org.apache.beam.sdk.schemas.utils.SelectHelpers.selectIntoRow(SelectHelpers.java:204)
        at 
org.apache.beam.sdk.schemas.utils.SelectHelpers.selectRow(SelectHelpers.java:167)
        
   ```
   
   I don't see anything wrong with the test itself.
 
----------------------------------------------------------------
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]


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

    Worklog Id:     (was: 218648)
    Time Spent: 9h 10m  (was: 9h)

> Select transform has non-intuitive semantics
> --------------------------------------------
>
>                 Key: BEAM-6772
>                 URL: https://issues.apache.org/jira/browse/BEAM-6772
>             Project: Beam
>          Issue Type: Sub-task
>          Components: sdk-java-core
>            Reporter: Reuven Lax
>            Assignee: Reuven Lax
>            Priority: Major
>          Time Spent: 9h 10m
>  Remaining Estimate: 0h
>
> Consider the following schema:
> User:
>     name: STRING
>     location: Location
>  
> Location:
>     latitude: DOUBLE
>     longitude: DOUBLE
>  
> If you apply Select.fieldNames("location"), most users expect to get back a 
> row matching the Location schema. Instead you get back an outer schema with a 
> single location field in it. Select should instead unnest the output up to 
> the point where multiple fields are selected.



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

Reply via email to