viirya commented on a change in pull request #32354:
URL: https://github.com/apache/spark/pull/32354#discussion_r625532589
##########
File path:
sql/catalyst/src/test/scala/org/apache/spark/sql/connector/catalog/InMemoryTable.scala
##########
@@ -504,9 +509,39 @@ private class BufferedRowsReader(
index < partition.rows.length
}
- override def get(): InternalRow = addMetadata(partition.rows(index))
+ override def get(): InternalRow = {
+ val originalRow = partition.rows(index)
+ val values = new Array[Any](nonMetadataColumns.length)
+ nonMetadataColumns.zipWithIndex.foreach { case (col, idx) =>
+ values(idx) = extractFieldValue(col, tableSchema, originalRow)
+ }
+ addMetadata(new GenericInternalRow(values))
+ }
override def close(): Unit = {}
+
+ private def extractFieldValue(
+ field: StructField,
+ schema: StructType,
+ row: InternalRow): Any = {
+ val index = schema.fieldIndex(field.name)
+ field.dataType match {
+ case StructType(fields) =>
+ val childRow = row.toSeq(schema)(index).asInstanceOf[InternalRow]
+ if (childRow == null) {
+ return null
+ }
+ val childSchema = schema(index).dataType.asInstanceOf[StructType]
+ val resultValue = new Array[Any](fields.length)
+ fields.zipWithIndex.foreach { case (childField, idx) =>
+ val childValue = extractFieldValue(childField, childSchema, childRow)
+ resultValue(idx) = childValue
+ }
+ new GenericInternalRow(resultValue)
+ case dt =>
+ row.get(index, CharVarcharUtils.replaceCharVarcharWithString(dt))
+ }
Review comment:
looks like we don't do char/varchar to string conversion before?
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]