[ 
https://issues.apache.org/jira/browse/HIVE-18629?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16361518#comment-16361518
 ] 

Matt McCline commented on HIVE-18629:
-------------------------------------

I think the patch is still wrong.

1) Until HIVE-18622 is available to fix the problem, this focused fix could 
encounter an output column that is corrupted.

2) For the isRepeated case you need to set noNulls to false when isNull is set 
to true.

I still think this version is best.  It is conservative in that it makes sure 
the output vector isNull entries are set correctly.

{code}
  public void copySelected(
      boolean selectedInUse, int[] sel, int size, BytesColumnVector output) {

   // We do not need to do a column reset since we are carefully changing the 
output.
    output.isRepeating = false;

    // Handle repeating case
    if (isRepeating) {
      if (noNulls || !isNull[0]) {
        output.isNull[0] = false;
        output.setVal(0, vector[0], start[0], length[0]);
      } else {
        output.isNull[0] = true;
        output.noNulls = false;
      }
      output.isRepeating = true;
      return;
    }

    // Handle normal case

    if (noNulls) {

      /*
       * Make sure our output results have their isNull entry initialized to 
false.
       * NOTE: We leave outputColVector.noNulls flag alone since we don't clear 
all
       * the isNull entries.
       */

      if (selectedInUse) {
        for (int j = 0; j < size; j++) {
          int i = sel[j];
          output.isNull[i] = false;
          output.setVal(i, vector[i], start[i], length[i]);
        }
      } else {
        Arrays.fill(output.isNull, 0, size, false);
        for(int i = 0; i < size; ++i) {
          output.setVal(i, vector[i], start[i], length[i]);
        }
      }
    } else {
  
      // Carefully handle NULLs...

      if (selectedInUse) {
        for (int j = 0; j < size; j++) {
          int i = sel[j];
          if (!isNull[i]) {
            output.isNull[i] = false;
            output.setVal(i, vector[i], start[i], length[i]);
          } else {
            output.isNull[i] = true;
            output.noNulls = false;
          }
        }
      } else {
        for (int i = 0; i < size; i++) {
          if (!isNull[i]) {
            output.isNull[i] = false;
            output.setVal(i, vector[i], start[i], length[i]);
          } else {
            output.isNull[i] = true;
            output.noNulls = false;
          }
        }
      }
    }
 {code}
 

> copyValues in BytesColumnVector may be missing null checks
> ----------------------------------------------------------
>
>                 Key: HIVE-18629
>                 URL: https://issues.apache.org/jira/browse/HIVE-18629
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Sergey Shelukhin
>            Assignee: Sergey Shelukhin
>            Priority: Major
>         Attachments: HIVE-18629.01.patch, HIVE-18629.02.patch, 
> HIVE-18629.03.patch, HIVE-18629.patch
>
>
> {noformat}
> Caused by: java.lang.NullPointerException
>       at java.lang.System.arraycopy(Native Method)
>       at 
> org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector.setVal(BytesColumnVector.java:173)
>       at 
> org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector.copySelected(BytesColumnVector.java:333)
>       at 
> org.apache.hadoop.hive.ql.exec.vector.expressions..evaluate(IfExprStringGroupColumnStringGroupColumn.java:83)
>       at 
> org.apache.hadoop.hive.ql.exec.vector.VectorSelectOperator.process(VectorSelectOperator.java:133)
> {noformat}
> IfExprStringGroupColumnStringGroupColumn code below the v1.isRepeating case 
> has isNull checks for v2/v3 buffers that copySelected is missing. 



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

Reply via email to