viirya commented on a change in pull request #32354:
URL: https://github.com/apache/spark/pull/32354#discussion_r625530081
##########
File path:
sql/catalyst/src/test/scala/org/apache/spark/sql/connector/catalog/InMemoryTable.scala
##########
@@ -237,29 +237,29 @@ class InMemoryTable(
private var schema: StructType = tableSchema
override def build: Scan =
- new InMemoryBatchScan(data.map(_.asInstanceOf[InputPartition]), schema)
+ new InMemoryBatchScan(data.map(_.asInstanceOf[InputPartition]), schema,
tableSchema)
override def pruneColumns(requiredSchema: StructType): Unit = {
- // if metadata columns are projected, return the table schema and
metadata columns
- val hasMetadataColumns =
requiredSchema.map(_.name).exists(metadataColumnNames.contains)
- if (hasMetadataColumns) {
- schema = StructType(tableSchema ++ metadataColumnNames
- .flatMap(name => metadataColumns.find(_.name == name))
- .map(col => StructField(col.name, col.dataType, col.isNullable)))
- }
+ schema = StructType(requiredSchema.filter { f =>
+ (metadataColumnNames ++ tableSchema.map(_.name)).contains(f.name)
Review comment:
`(metadataColumnNames ++ tableSchema.map(_.name))` can be out of
`filter` loop?
--
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]