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
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
Copy link
Contributor

@cloud-fan cloud-fan Aug 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't expectedOutputAttributes.map(_.map(_.newInstance())) work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once expectedOutputAttributes is None, we still need to have new instances of relation's output. output already covers both relation's output and expectedOutputAttributes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if expectedOutputAttributes is None, output is defined as relation.schema.toAttributes, we will get different expr ids.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, yeah, you are right. It should work. Both are ok for me. I will update it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update the doc?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

* 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