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

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

                Author: ASF GitHub Bot
            Created on: 20/Mar/19 09:19
            Start Date: 20/Mar/19 09:19
    Worklog Time Spent: 10m 
      Work Description: iemejia commented on pull request #8090: [BEAM-6861] 
Select fields and computed fields in CassandraIO.Read
URL: https://github.com/apache/beam/pull/8090#discussion_r267239572
 
 

 ##########
 File path: 
sdks/java/io/cassandra/src/test/java/org/apache/beam/sdk/io/cassandra/CassandraIOTest.java
 ##########
 @@ -270,6 +273,68 @@ public void testReadWithWhere() throws Exception {
     pipeline.run();
   }
 
+  @Test
+  public void testSelectFields() throws Exception {
+    insertRecords();
+
+    PCollection<Scientist> output =
+        pipeline.apply(
+            CassandraIO.<Scientist>read()
+                .withHosts(pipeline.newProvider(Arrays.asList(CASSANDRA_HOST)))
+                .withPort(pipeline.newProvider(CASSANDRA_PORT))
+                .withKeyspace(pipeline.newProvider(CASSANDRA_KEYSPACE))
+                .withTable(pipeline.newProvider(CASSANDRA_TABLE))
+                
.withSelectFields(pipeline.newProvider(Arrays.asList("person_id")))
+                .withCoder(SerializableCoder.of(Scientist.class))
+                .withEntity(Scientist.class)
+                .withWhere(pipeline.newProvider("person_id=10")));
+
+    PAssert.thatSingleton(output.apply("Count", 
Count.globally())).isEqualTo(1L);
+    PAssert.that(output)
+        .satisfies(
+            input -> {
+              for (Scientist sci : input) {
+                assertNotNull(sci.id);
+                assertNull(sci.name);
+              }
 
 Review comment:
   What happens if you read `nameTs` here? Since objects are mapped I was 
wondering if it will be zero, probably worth asserting that to validate that 
the values were not 'filled' (given that they were not projected).
 
----------------------------------------------------------------
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: 216059)
    Time Spent: 40m  (was: 0.5h)

> Select fields and computed fields in CassandraIO.Read 
> ------------------------------------------------------
>
>                 Key: BEAM-6861
>                 URL: https://issues.apache.org/jira/browse/BEAM-6861
>             Project: Beam
>          Issue Type: Improvement
>          Components: io-java-cassandra
>            Reporter: Radosław Stankiewicz
>            Assignee: Radosław Stankiewicz
>            Priority: Minor
>              Labels: features
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> CassandraIO.Read currently selects all fields and maps them to POJO.
> To make this component more flexible, it should be possible to select only 
> subset of fields or computed fields to allow reading things like write 
> Timestamp or using other functions.



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

Reply via email to