@@ -72,17 +72,12 @@ case class HiveTableScan(
7272 }
7373
7474 private def addColumnMetadataToConf (hiveConf : HiveConf ) {
75- // Specifies IDs and internal names of columns to be scanned.
76- val neededColumnIDs = attributes.map(a => relation.output.indexWhere(_.name == a.name): Integer )
77- val columnInternalNames = neededColumnIDs.map(HiveConf .getColumnInternalName(_)).mkString(" ," )
78-
79- if (attributes.size == relation.output.size) {
80- // SQLContext#pruneFilterProject guarantees no duplicated value in `attributes`
81- ColumnProjectionUtils .setFullyReadColumns(hiveConf)
82- } else {
83- ColumnProjectionUtils .appendReadColumnIDs(hiveConf, neededColumnIDs)
84- }
75+ // Specifies needed column IDs for those non-partitioning columns.
76+ val neededColumnIDs =
77+ attributes.map(a =>
78+ relation.attributes.indexWhere(_.name == a.name): Integer ).filter(index => index >= 0 )
8579
80+ ColumnProjectionUtils .appendReadColumnIDs(hiveConf, neededColumnIDs)
8681 ColumnProjectionUtils .appendReadColumnNames(hiveConf, attributes.map(_.name))
8782
8883 // Specifies types and object inspectors of columns to be scanned.
@@ -99,7 +94,7 @@ case class HiveTableScan(
9994 .mkString(" ," )
10095
10196 hiveConf.set(serdeConstants.LIST_COLUMN_TYPES , columnTypeNames)
102- hiveConf.set(serdeConstants.LIST_COLUMNS , columnInternalNames )
97+ hiveConf.set(serdeConstants.LIST_COLUMNS , relation.attributes.map(_.name).mkString( " , " ) )
10398 }
10499
105100 addColumnMetadataToConf(context.hiveconf)
0 commit comments