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

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

                Author: ASF GitHub Bot
            Created on: 28/Jan/19 23:39
            Start Date: 28/Jan/19 23:39
    Worklog Time Spent: 10m 
      Work Description: amaliujia commented on pull request #7636: [BEAM-6513] 
Fix NPE in BeamEnumerableConverter
URL: https://github.com/apache/beam/pull/7636#discussion_r251639742
 
 

 ##########
 File path: 
sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamEnumerableConverter.java
 ##########
 @@ -238,16 +238,29 @@ public void startBundle(StartBundleContext context) {
 
     @ProcessElement
     public void processElement(ProcessContext context) {
-      Object[] avaticaRow = rowToAvatica(context.element());
-      if (avaticaRow.length == 1) {
-        values.add(avaticaRow[0]);
+      values.add(rowToObjectArray(context.element()));
+    }
+  }
+
+  private static List<Object> objectArrayToAvatica(Queue<Object[]> values) {
+    List<Object> ret = new ArrayList<>();
+    Iterator<Object[]> iterator = values.iterator();
+    while (iterator.hasNext()) {
+      Object[] objects = iterator.next();
+      if (objects.length == 1) {
+        // if objects.length == 1, that means input Row contains only 1 
column/element,
+        // then an Object instead of Object[] should be returned because of 
CalciteResultSet's
+        // behaviour that tries to convert one column row to an Object.
+        ret.add(objects[0]);
       } else {
-        values.add(avaticaRow);
+        ret.add(objects);
       }
     }
+
+    return ret;
   }
 
-  private static Object[] rowToAvatica(Row row) {
+  private static Object[] rowToObjectArray(Row row) {
 
 Review comment:
   Ok, I changed the name back.
 
----------------------------------------------------------------
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: 191306)
    Time Spent: 4h 10m  (was: 4h)

> BeamEnumerableConverter doest not handle Null during collecting values
> ----------------------------------------------------------------------
>
>                 Key: BEAM-6513
>                 URL: https://issues.apache.org/jira/browse/BEAM-6513
>             Project: Beam
>          Issue Type: Bug
>          Components: dsl-sql
>            Reporter: Rui Wang
>            Assignee: Rui Wang
>            Priority: Major
>          Time Spent: 4h 10m
>  Remaining Estimate: 0h
>




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

Reply via email to