From dd88eff8209141e0c5221081de8e69767a49b5ea Mon Sep 17 00:00:00 2001 From: Angerszhuuuu Date: Tue, 26 Jan 2021 15:14:10 +0000 Subject: [PATCH] [SPARK-34241][SQL] For DDL command plan, we should define producedAttributes as it's outputSet ### What changes were proposed in this pull request? When write test about command, when `checkAnswer`, Always got error as below ``` [info] AttributeSet(partition#607) was not empty The analyzed logical plan has missing inputs: [info] ShowPartitionsCommand `ns`.`tbl`, [partition#607] (QueryTest.scala:224) [info] org.scalatest.exceptions.TestFailedException: [info] at org.scalatest.Assertions.newAssertionFailedException(Assertions.scala:472) [info] at org.scalatest.Assertions.newAssertionFailedException$(Assertions.scala:471) ``` For Command DDL plan, we can define `producedAttributes` as it's `outputSet` and it's reasonable ### Why are the changes needed? Add default `producedAttributes` for Command LogicalPlan ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Not need Closes #31342 from AngersZhuuuu/SPARK-34241. Authored-by: Angerszhuuuu Signed-off-by: Wenchen Fan --- .../org/apache/spark/sql/catalyst/plans/logical/Command.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/Command.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/Command.scala index 732c8ce2b5..89bd865391 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/Command.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/Command.scala @@ -17,7 +17,7 @@ package org.apache.spark.sql.catalyst.plans.logical -import org.apache.spark.sql.catalyst.expressions.Attribute +import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeSet} /** * A logical node that represents a non-query command to be executed by the system. For example, @@ -26,6 +26,7 @@ import org.apache.spark.sql.catalyst.expressions.Attribute */ trait Command extends LogicalPlan { override def output: Seq[Attribute] = Seq.empty + override def producedAttributes: AttributeSet = outputSet override def children: Seq[LogicalPlan] = Seq.empty // Commands are eagerly executed. They will be converted to LocalRelation after the DataFrame // is created. That said, the statistics of a command is useless. Here we just return a dummy