diff --git a/kyuubi-common/src/main/scala/org/apache/kyuubi/engine/result/TColumnGenerator.scala b/kyuubi-common/src/main/scala/org/apache/kyuubi/engine/result/TColumnGenerator.scala index 7326e5a3d17..5a2acd0bdd7 100644 --- a/kyuubi-common/src/main/scala/org/apache/kyuubi/engine/result/TColumnGenerator.scala +++ b/kyuubi-common/src/main/scala/org/apache/kyuubi/engine/result/TColumnGenerator.scala @@ -34,18 +34,17 @@ trait TColumnGenerator[RowT] extends TRowSetColumnGetter[RowT] { val ret = new JArrayList[T](rowSize) val nulls = new JBitSet() var idx = 0 + val isConvertFuncNull = convertFunc == null rows.foreach { row => - val isNull = isColumnNullAt(row, ordinal) - if (isNull) { + val value = if (isColumnNullAt(row, ordinal)) { nulls.set(idx, true) - ret.add(defaultVal) + defaultVal + } else if (isConvertFuncNull) { + getColumnAs[T](row, ordinal) } else { - val value = Option(convertFunc) match { - case Some(f) => f(row, ordinal) - case _ => getColumnAs[T](row, ordinal) - } - ret.add(value) + convertFunc(row, ordinal) } + ret.add(value) idx += 1 } (ret, ByteBuffer.wrap(nulls.toByteArray))