Skip to content

Commit

Permalink
Fix bug with tree splicing.
Browse files Browse the repository at this point in the history
  • Loading branch information
marmbrus committed Aug 8, 2014
1 parent ebb267e commit 4c4dc19
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ private[hive] trait HiveStrategies {
*
* TODO: Much of this logic is duplicated in HiveTableScan. Ideally we would do some refactoring
* but since this is after the code freeze for 1.1 all logic is here to minimize disruption.
*
* Other issues:
* - Much of this logic assumes case insensitive resolution.
*/
@Experimental
object ParquetConversion extends Strategy {
Expand All @@ -60,8 +63,14 @@ private[hive] trait HiveStrategies {
})
}

implicit class PhysicalPlanHacks(s: SparkPlan) {
def fakeOutput(newOutput: Seq[Attribute]) = OutputFaker(newOutput, s)
implicit class PhysicalPlanHacks(originalPlan: SparkPlan) {
def fakeOutput(newOutput: Seq[Attribute]) =
OutputFaker(
originalPlan.output.map(a =>
newOutput.find(a.name.toLowerCase == _.name.toLowerCase)
.getOrElse(
sys.error(s"Can't find attribute $a to fake in set ${newOutput.mkString(",")}"))),
originalPlan)
}

def apply(plan: LogicalPlan): Seq[SparkPlan] = plan match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,23 @@ class ParquetMetastoreSuite extends QueryTest with BeforeAndAfterAll {
)
}

test("project partitioning and non-partitioning columns") {
checkAnswer(
sql("SELECT stringField, p, count(intField) " +
"FROM partitioned_parquet GROUP BY p, stringField"),
("part-1", 1, 10) ::
("part-2", 2, 10) ::
("part-3", 3, 10) ::
("part-4", 4, 10) ::
("part-5", 5, 10) ::
("part-6", 6, 10) ::
("part-7", 7, 10) ::
("part-8", 8, 10) ::
("part-9", 9, 10) ::
("part-10", 10, 10) :: Nil
)
}

test("simple count") {
checkAnswer(
sql("SELECT COUNT(*) FROM partitioned_parquet"),
Expand Down

0 comments on commit 4c4dc19

Please sign in to comment.