pan3793 commented on code in PR #5870:
URL: https://github.com/apache/kyuubi/pull/5870#discussion_r1432970736
##########
externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/schema/SparkTRowSetGenerator.scala:
##########
@@ -42,51 +39,44 @@ class SparkTRowSetGenerator
override def getColumnAs[T](row: Row, ordinal: Int): T =
row.getAs[T](ordinal)
override def toTColumn(rows: Seq[Row], ordinal: Int, typ: DataType): TColumn
= {
- val timeFormatters: TimeFormatters = tf
- val nulls = new java.util.BitSet()
typ match {
- case BooleanType => toTTypeColumn(BOOLEAN_TYPE, rows, ordinal)
- case ByteType => toTTypeColumn(BINARY_TYPE, rows, ordinal)
- case ShortType => toTTypeColumn(TINYINT_TYPE, rows, ordinal)
- case IntegerType => toTTypeColumn(INT_TYPE, rows, ordinal)
- case LongType => toTTypeColumn(BIGINT_TYPE, rows, ordinal)
- case FloatType => toTTypeColumn(FLOAT_TYPE, rows, ordinal)
- case DoubleType => toTTypeColumn(DOUBLE_TYPE, rows, ordinal)
- case StringType => toTTypeColumn(STRING_TYPE, rows, ordinal)
- case BinaryType => toTTypeColumn(ARRAY_TYPE, rows, ordinal)
+ case BooleanType => asBooleanColumn(rows, ordinal)
+ case ByteType => asByteColumn(rows, ordinal)
+ case ShortType => asShortColumn(rows, ordinal)
+ case IntegerType => asIntegerColumn(rows, ordinal)
+ case LongType => asLongColumn(rows, ordinal)
+ case FloatType => asFloatColumn(rows, ordinal)
+ case DoubleType => asDoubleColumn(rows, ordinal)
+ case StringType => asStringColumn(rows, ordinal)
+ case BinaryType => asByteArrayColumn(rows, ordinal)
case _ =>
- var i = 0
- val rowSize = rows.length
- val values = new java.util.ArrayList[String](rowSize)
- while (i < rowSize) {
- val row = rows(i)
- nulls.set(i, row.isNullAt(ordinal))
- values.add(RowSet.toHiveString(row.get(ordinal) -> typ,
timeFormatters = timeFormatters))
- i += 1
- }
- TColumn.stringVal(new TStringColumn(values, nulls))
+ asStringColumn(
+ rows,
+ ordinal,
+ "NULL",
+ (row, ordinal) =>
+ RowSet.toHiveString(
+ getColumnAs[Any](row, ordinal) -> typ,
+ timeFormatters = tf))
Review Comment:
extract as a variable could improve the code readability
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]