获取org.apache.hadoop.hive.ql.exec.vector.decimalcolumnvector不能强制转换为org.apache.hadoop.hive.ql.exec.vector.longcolumnvector

vmdwslir  于 2021-05-31  发布在  Hadoop
关注(0)|答案(0)|浏览(1409)
// column: bigint
          if (getTypes(column, struct).equalsIgnoreCase("bigint")) {
            if (!lineArray[column].isEmpty()) {
                try {
                    ((LongColumnVector) batch.cols[column]).vector[row] = Long.parseLong(lineArray[column]);
                } catch (NumberFormatException e) {
                    HiveDecimal hiveDecimal = HiveDecimal.create(lineArray[column]);
                    batch.cols[column]=new DecimalColumnVector(lineArray[column].length(), 0);
                    ((DecimalColumnVector) batch.cols[column]).vector[row] = (new HiveDecimalWritable(hiveDecimal));
                } catch (Exception e) {
                    e.printStackTrace();
                }
                } else {
                       ((LongColumnVector) batch.cols[column]).noNulls = false;
                       ((LongColumnVector) batch.cols[column]).isNull[row] = true;
                       ((LongColumnVector) batch.cols[column]).vector[row] = LongColumnVector.NULL_VALUE;
                       // ((CustomLongColumnVector) batch.cols[column]).fillWithNulls();
                }

          }

我正在尝试执行上面的代码片段。 lineArray 是字符串数组。但它正在失败 java.lang.ClassCastException: org.apache.hadoop.hive.ql.exec.vector.DecimalColumnVector cannot be cast to org.apache.hadoop.hive.ql.exec.vector.LongColumnVector . 请帮忙。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题