aboutsummaryrefslogtreecommitdiff
path: root/sql/core/src
diff options
context:
space:
mode:
authorLiang-Chi Hsieh <simonh@tw.ibm.com>2016-08-20 23:29:48 +0800
committerWenchen Fan <wenchen@databricks.com>2016-08-20 23:29:48 +0800
commit31a015572024046f4deaa6cec66bb6fab110f31d (patch)
tree3633ea15736e3b5afb9e51fe38330af42fae8b42 /sql/core/src
parent3e5fdeb3fb084cc9d25ce2f3f8cbf07a0aa2c573 (diff)
downloadspark-31a015572024046f4deaa6cec66bb6fab110f31d.tar.gz
spark-31a015572024046f4deaa6cec66bb6fab110f31d.tar.bz2
spark-31a015572024046f4deaa6cec66bb6fab110f31d.zip
[SPARK-17104][SQL] LogicalRelation.newInstance should follow the semantics of MultiInstanceRelation
## What changes were proposed in this pull request? Currently `LogicalRelation.newInstance()` simply creates another `LogicalRelation` object with the same parameters. However, the `newInstance()` method inherited from `MultiInstanceRelation` should return a copy of object with unique expression ids. Current `LogicalRelation.newInstance()` can cause failure when doing self-join. ## How was this patch tested? Jenkins tests. Author: Liang-Chi Hsieh <simonh@tw.ibm.com> Closes #14682 from viirya/fix-localrelation.
Diffstat (limited to 'sql/core/src')
-rw-r--r--sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/LogicalRelation.scala11
1 files changed, 9 insertions, 2 deletions
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/LogicalRelation.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/LogicalRelation.scala
index 90711f2b1d..2a8e147011 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/LogicalRelation.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/LogicalRelation.scala
@@ -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 returns a copy of this object with
+ * unique expression ids. We respect the `expectedOutputAttributes` and create
+ * new instances of attributes in it.
+ */
+ override def newInstance(): this.type = {
LogicalRelation(
relation,
- expectedOutputAttributes,
+ expectedOutputAttributes.map(_.map(_.newInstance())),
metastoreTableIdentifier).asInstanceOf[this.type]
+ }
override def refresh(): Unit = relation match {
case fs: HadoopFsRelation => fs.refresh()