Github user liancheng commented on a diff in the pull request:
https://github.com/apache/spark/pull/12866#discussion_r61866481
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/fileSourceInterfaces.scala
---
@@ -223,6 +224,45 @@ trait FileFormat {
// Until then we guard in [[FileSourceStrategy]] to only call this
method on supported formats.
throw new UnsupportedOperationException(s"buildReader is not supported
for $this")
}
+
+ /**
+ * Exactly the same as [[buildReader]] except that the reader function
returned by this method
+ * appends partition values to [[InternalRow]]s produced by the reader
function [[buildReader]]
+ * returns.
+ */
+ private[sql] def buildReaderWithPartitionValues(
+ sparkSession: SparkSession,
+ dataSchema: StructType,
+ partitionSchema: StructType,
+ requiredSchema: StructType,
+ filters: Seq[Filter],
+ options: Map[String, String],
+ hadoopConf: Configuration): PartitionedFile => Iterator[InternalRow]
= {
+ val dataReader = buildReader(
+ sparkSession, dataSchema, partitionSchema, requiredSchema, filters,
options, hadoopConf)
+
+ new (PartitionedFile => Iterator[InternalRow]) with Serializable {
--- End diff --
@cloud-fan Instead of adding a new `ReaderFunction` trait with an
`initialize()` method as [you suggested][1], I used an anonymous `Function1`
class here. Not quite sure how useful the `initialize()` method can be in more
general cases...
[1]: https://github.com/apache/spark/pull/12033#discussion_r57845348
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]