Github user liancheng commented on a diff in the pull request:
https://github.com/apache/spark/pull/8509#discussion_r38760227
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/CatalystRowConverter.scala
---
@@ -179,31 +154,7 @@ private[parquet] class CatalystRowConverter(
// Converters for each field.
private val fieldConverters: Array[Converter with
HasParentContainerUpdater] = {
- // In case of schema merging, `parquetType` can be a subset of
`catalystType`. We need to pad
- // those missing fields and create converters for them, although
values of these fields are
- // always null.
- val paddedParquetFields = {
- val parquetFields = parquetType.getFields.asScala
- val parquetFieldNames = parquetFields.map(_.getName).toSet
- val missingFields = catalystType.filterNot(f =>
parquetFieldNames.contains(f.name))
-
- // We don't need to worry about feature flag arguments like
`assumeBinaryIsString` when
- // creating the schema converter here, since values of missing
fields are always null.
- val toParquet = new CatalystSchemaConverter()
-
- (parquetFields ++ missingFields.map(toParquet.convertField)).sortBy
{ f =>
- catalystType.indexWhere(_.name == f.getName)
- }
- }
-
- if (paddedParquetFields.length != catalystType.length) {
- throw new UnsupportedOperationException(
- "A Parquet file's schema has different number of fields with the
table schema. " +
- "Please enable schema merging by setting \"mergeSchema\" to true
when load " +
- "a Parquet dataset or set spark.sql.parquet.mergeSchema to true
in SQLConf.")
- }
-
- paddedParquetFields.zip(catalystType).zipWithIndex.map {
+ parquetType.getFields.asScala.zip(catalystType).zipWithIndex.map {
--- End diff --
Good point, should add an assertion. `parquetType` and `catalystType`
should guarantee to have the same number of fields here.
---
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]