[SPARK-27782][SQL] Use '#' to mark expression id embedded in the name field of SubqueryExec operator

## What changes were proposed in this pull request?
This is a minor pr to use `#` as a marker for expression id that is embedded in the name field of SubqueryExec operator.

## How was this patch tested?
Added a small test in SubquerySuite.

Closes #24652 from dilipbiswal/subquery-name.

Authored-by: Dilip Biswal <dbiswal@us.ibm.com>
Signed-off-by: Dongjoon Hyun <dhyun@apple.com>
This commit is contained in:
Dilip Biswal 2019-05-26 20:47:25 -07:00 committed by Dongjoon Hyun
parent 447bfdec83
commit 5060647bb1
2 changed files with 13 additions and 1 deletions

View file

@ -116,7 +116,7 @@ case class PlanSubqueries(sparkSession: SparkSession) extends Rule[SparkPlan] {
case subquery: expressions.ScalarSubquery =>
val executedPlan = new QueryExecution(sparkSession, subquery.plan).executedPlan
ScalarSubquery(
SubqueryExec(s"subquery${subquery.exprId.id}", executedPlan),
SubqueryExec(s"scalar-subquery#${subquery.exprId.id}", executedPlan),
subquery.exprId)
}
}

View file

@ -1371,4 +1371,16 @@ class SubquerySuite extends QueryTest with SharedSQLContext {
}
}
}
test("Scalar subquery name should start with scalar-subquery#") {
val df = sql("SELECT a FROM l WHERE a = (SELECT max(c) FROM r WHERE c = 1)".stripMargin)
var subqueryExecs: ArrayBuffer[SubqueryExec] = ArrayBuffer.empty
df.queryExecution.executedPlan.transformAllExpressions {
case s @ ScalarSubquery(p: SubqueryExec, _) =>
subqueryExecs += p
s
}
assert(subqueryExecs.forall(_.name.startsWith("scalar-subquery#")),
"SubqueryExec name should start with scalar-subquery#")
}
}