Skip to content

Commit

Permalink
Fix LogicalRelation.newInstance.
Browse files Browse the repository at this point in the history
  • Loading branch information
viirya committed Aug 17, 2016
1 parent 2a3d286 commit f9a8c76
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,18 @@ case class LogicalRelation(
/** Used to lookup original attribute capitalization */
val attributeMap: AttributeMap[AttributeReference] = AttributeMap(output.map(o => (o, o)))

def newInstance(): this.type =
/**
* Returns a new instance of this LogicalRelation. According to the semantics of
* MultiInstanceRelation, this method should returns a copy of this object with
* unique expression ids. Thus we don't respect the `expectedOutputAttributes` and
* create new instances of original output attributes.
*/
override def newInstance(): this.type = {
LogicalRelation(
relation,
expectedOutputAttributes,
Some(output.map(_.newInstance())),
metastoreTableIdentifier).asInstanceOf[this.type]
}

override def refresh(): Unit = relation match {
case fs: HadoopFsRelation => fs.refresh()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,13 @@ class ParquetMetastoreSuite extends ParquetPartitioningTest {
}
}
}

test("self-join") {
val table = spark.table("normal_parquet")
val selfJoin = table.as("t1").join(table.as("t2"))
checkAnswer(selfJoin,
sql("SELECT * FROM normal_parquet x JOIN normal_parquet y"))
}
}

/**
Expand Down

0 comments on commit f9a8c76

Please sign in to comment.