Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fri Nov 4 15:54:23 PDT 2016
  • Loading branch information
ericl committed Nov 4, 2016
commit ddc39b8456dfd141afb7eaa036263c2696298a2c
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,11 @@ private[parquet] object ParquetReadSupport {
*/
private def clipParquetGroupFields(
parquetRecord: GroupType, structType: StructType): Seq[Type] = {
val parquetFieldMap = parquetRecord.getFields.asScala
.map(f => f.getName -> f).toMap
val caseInsensitiveParquetFieldMap = parquetRecord.getFields.asScala
.map(f => f.getName.toLowerCase -> f).toMap
val parquetFieldMap = parquetRecord.getFields.asScala.map(f => f.getName -> f).toMap
val toParquet = new ParquetSchemaConverter(writeLegacyParquetFormat = false)
structType.map { f =>
parquetFieldMap
.get(f.name)
.orElse(caseInsensitiveParquetFieldMap.get(f.name.toLowerCase))
.map(clipParquetType(_, f.dataType))
.getOrElse(toParquet.convertField(f))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,17 +305,7 @@ private[orc] object OrcRelation extends HiveInspectors {

def setRequiredColumns(
conf: Configuration, physicalSchema: StructType, requestedSchema: StructType): Unit = {
val caseInsensitiveFieldMap: Map[String, Int] = physicalSchema.fieldNames
.zipWithIndex
.map(f => (f._1.toLowerCase, f._2))
.toMap
val ids = requestedSchema.map { a =>
val exactMatch: Option[Int] = physicalSchema.getFieldIndex(a.name)
val res = exactMatch.getOrElse(
caseInsensitiveFieldMap.getOrElse(a.name,
throw new IllegalArgumentException(s"""Field "$a.name" does not exist.""")))
res: Integer
}
val ids = requestedSchema.map(a => physicalSchema.fieldIndex(a.name): Integer)
val (sortedIDs, sortedNames) = ids.zip(requestedSchema.fieldNames).sorted.unzip
HiveShim.appendReadColumns(conf, sortedIDs, sortedNames)
}
Expand Down