Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19230#discussion_r138799219
  
    --- Diff: 
sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/ColumnVector.java
 ---
    @@ -99,73 +100,18 @@ public ArrayData copy() {
         @Override
         public Object[] array() {
           DataType dt = data.dataType();
    +      Function<Integer, Object> getAtMethod = (Function<Integer, Object>) 
i -> get(i, dt);
           Object[] list = new Object[length];
    -
    -      if (dt instanceof BooleanType) {
    -        for (int i = 0; i < length; i++) {
    -          if (!data.isNullAt(offset + i)) {
    -            list[i] = data.getBoolean(offset + i);
    -          }
    -        }
    -      } else if (dt instanceof ByteType) {
    -        for (int i = 0; i < length; i++) {
    -          if (!data.isNullAt(offset + i)) {
    -            list[i] = data.getByte(offset + i);
    -          }
    -        }
    -      } else if (dt instanceof ShortType) {
    -        for (int i = 0; i < length; i++) {
    -          if (!data.isNullAt(offset + i)) {
    -            list[i] = data.getShort(offset + i);
    -          }
    -        }
    -      } else if (dt instanceof IntegerType) {
    -        for (int i = 0; i < length; i++) {
    -          if (!data.isNullAt(offset + i)) {
    -            list[i] = data.getInt(offset + i);
    -          }
    -        }
    -      } else if (dt instanceof FloatType) {
    -        for (int i = 0; i < length; i++) {
    -          if (!data.isNullAt(offset + i)) {
    -            list[i] = data.getFloat(offset + i);
    -          }
    -        }
    -      } else if (dt instanceof DoubleType) {
    +      try {
             for (int i = 0; i < length; i++) {
               if (!data.isNullAt(offset + i)) {
    -            list[i] = data.getDouble(offset + i);
    +            list[i] = getAtMethod.call(i);
               }
             }
    -      } else if (dt instanceof LongType) {
    -        for (int i = 0; i < length; i++) {
    -          if (!data.isNullAt(offset + i)) {
    -            list[i] = data.getLong(offset + i);
    -          }
    -        }
    -      } else if (dt instanceof DecimalType) {
    -        DecimalType decType = (DecimalType)dt;
    -        for (int i = 0; i < length; i++) {
    -          if (!data.isNullAt(offset + i)) {
    -            list[i] = getDecimal(i, decType.precision(), decType.scale());
    -          }
    -        }
    -      } else if (dt instanceof StringType) {
    -        for (int i = 0; i < length; i++) {
    -          if (!data.isNullAt(offset + i)) {
    -            list[i] = getUTF8String(i).toString();
    --- End diff --
    
    This looks suspicious. Why we get `String` before? Seems we should get 
`UTF8String`.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to