From a7383de811ea01f60aeb642b6c192aecef14ff6a Mon Sep 17 00:00:00 2001 From: Robert Kruszewski Date: Fri, 30 Mar 2018 03:30:51 +0100 Subject: [PATCH 1/2] mapexpressions preserving origin --- .../scala/org/apache/spark/sql/catalyst/plans/QueryPlan.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/QueryPlan.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/QueryPlan.scala index ddf2cbf2ab911..92f96489562e7 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/QueryPlan.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/QueryPlan.scala @@ -18,7 +18,7 @@ package org.apache.spark.sql.catalyst.plans import org.apache.spark.sql.catalyst.expressions._ -import org.apache.spark.sql.catalyst.trees.TreeNode +import org.apache.spark.sql.catalyst.trees.{CurrentOrigin, TreeNode} import org.apache.spark.sql.internal.SQLConf import org.apache.spark.sql.types.{DataType, StructType} @@ -122,7 +122,7 @@ abstract class QueryPlan[PlanType <: QueryPlan[PlanType]] extends TreeNode[PlanT case null => null } - val newArgs = mapProductIterator(recursiveTransform) + val newArgs = CurrentOrigin.withOrigin(origin) { mapProductIterator(recursiveTransform) } if (changed) makeCopy(newArgs).asInstanceOf[this.type] else this } From 479cf4633bc415b33fd80fc969be885b0decc5cb Mon Sep 17 00:00:00 2001 From: Robert Kruszewski Date: Fri, 30 Mar 2018 03:34:47 +0100 Subject: [PATCH 2/2] correct place --- .../scala/org/apache/spark/sql/catalyst/plans/QueryPlan.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/QueryPlan.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/QueryPlan.scala index 92f96489562e7..5fd26e18f9f28 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/QueryPlan.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/QueryPlan.scala @@ -103,7 +103,7 @@ abstract class QueryPlan[PlanType <: QueryPlan[PlanType]] extends TreeNode[PlanT var changed = false @inline def transformExpression(e: Expression): Expression = { - val newE = f(e) + val newE = CurrentOrigin.withOrigin(e.origin) { f(e) } if (newE.fastEquals(e)) { e } else { @@ -122,7 +122,7 @@ abstract class QueryPlan[PlanType <: QueryPlan[PlanType]] extends TreeNode[PlanT case null => null } - val newArgs = CurrentOrigin.withOrigin(origin) { mapProductIterator(recursiveTransform) } + val newArgs = mapProductIterator(recursiveTransform) if (changed) makeCopy(newArgs).asInstanceOf[this.type] else this }