Skip to content

Commit cc64f32

Browse files
committed
Renamed physical plan classes for DDL/commands
1 parent 74789c1 commit cc64f32

File tree

6 files changed

+23
-25
lines changed

6 files changed

+23
-25
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/SparkStrategies.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
package org.apache.spark.sql.execution
1919

20-
import org.apache.spark.sql.{SQLConf, SQLContext, execution}
20+
import org.apache.spark.sql.{SQLContext, execution}
2121
import org.apache.spark.sql.catalyst.expressions._
2222
import org.apache.spark.sql.catalyst.planning._
2323
import org.apache.spark.sql.catalyst.plans._
@@ -156,7 +156,7 @@ private[sql] abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
156156
InsertIntoParquetTable(relation, planLater(child), overwrite=true)(sparkContext) :: Nil
157157
case logical.InsertIntoTable(table: ParquetRelation, partition, child, overwrite) =>
158158
InsertIntoParquetTable(table, planLater(child), overwrite)(sparkContext) :: Nil
159-
case PhysicalOperation(projectList, filters: Seq[Expression], relation: ParquetRelation) => {
159+
case PhysicalOperation(projectList, filters: Seq[Expression], relation: ParquetRelation) =>
160160
val prunePushedDownFilters =
161161
if (sparkContext.conf.getBoolean(ParquetFilters.PARQUET_FILTER_PUSHDOWN_ENABLED, true)) {
162162
(filters: Seq[Expression]) => {
@@ -185,7 +185,6 @@ private[sql] abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
185185
filters,
186186
prunePushedDownFilters,
187187
ParquetTableScan(_, relation, filters)(sparkContext)) :: Nil
188-
}
189188

190189
case _ => Nil
191190
}
@@ -237,12 +236,12 @@ private[sql] abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
237236
case class CommandStrategy(context: SQLContext) extends Strategy {
238237
def apply(plan: LogicalPlan): Seq[SparkPlan] = plan match {
239238
case logical.SetCommand(key, value) =>
240-
Seq(execution.SetCommandPhysical(key, value, plan.output)(context))
239+
Seq(execution.SetCommand(key, value, plan.output)(context))
241240
case logical.ExplainCommand(child) =>
242241
val executedPlan = context.executePlan(child).executedPlan
243-
Seq(execution.ExplainCommandPhysical(executedPlan, plan.output)(context))
242+
Seq(execution.ExplainCommand(executedPlan, plan.output)(context))
244243
case logical.CacheCommand(tableName, cache) =>
245-
Seq(execution.CacheCommandPhysical(tableName, cache)(context))
244+
Seq(execution.CacheCommand(tableName, cache)(context))
246245
case _ => Nil
247246
}
248247
}

sql/core/src/main/scala/org/apache/spark/sql/execution/commands.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ import org.apache.spark.rdd.RDD
2222
import org.apache.spark.sql.{SQLContext, Row}
2323
import org.apache.spark.sql.catalyst.expressions.{GenericRow, Attribute}
2424

25-
trait PhysicalCommand {
25+
trait Command {
2626
/**
2727
* A concrete command should override this lazy field to wrap up any side effects caused by the
2828
* command or any other computation that should be evaluated exactly once. The value of this field
2929
* can be used as the contents of the corresponding RDD generated from the physical plan of this
3030
* command.
3131
*
32-
* The `execute()` method of all the physical command classes should reference `sideEffect` so
33-
* that the command can be executed eagerly right after the command query is created.
32+
* The `execute()` method of all the physical command classes should reference `sideEffectResult`
33+
* so that the command can be executed eagerly right after the command query is created.
3434
*/
3535
protected[sql] lazy val sideEffectResult: Seq[Any] = Seq.empty[Any]
3636
}
@@ -39,10 +39,10 @@ trait PhysicalCommand {
3939
* :: DeveloperApi ::
4040
*/
4141
@DeveloperApi
42-
case class SetCommandPhysical(
42+
case class SetCommand(
4343
key: Option[String], value: Option[String], output: Seq[Attribute])(
4444
@transient context: SQLContext)
45-
extends LeafNode with PhysicalCommand {
45+
extends LeafNode with Command {
4646

4747
override protected[sql] lazy val sideEffectResult: Seq[(String, String)] = (key, value) match {
4848
// Set value for key k.
@@ -74,10 +74,10 @@ case class SetCommandPhysical(
7474
* :: DeveloperApi ::
7575
*/
7676
@DeveloperApi
77-
case class ExplainCommandPhysical(
77+
case class ExplainCommand(
7878
child: SparkPlan, output: Seq[Attribute])(
7979
@transient context: SQLContext)
80-
extends UnaryNode with PhysicalCommand {
80+
extends UnaryNode with Command {
8181

8282
// Actually "EXPLAIN" command doesn't cause any side effect.
8383
override protected[sql] lazy val sideEffectResult: Seq[String] = this.toString.split("\n")
@@ -94,8 +94,8 @@ case class ExplainCommandPhysical(
9494
* :: DeveloperApi ::
9595
*/
9696
@DeveloperApi
97-
case class CacheCommandPhysical(tableName: String, doCache: Boolean)(@transient context: SQLContext)
98-
extends LeafNode with PhysicalCommand {
97+
case class CacheCommand(tableName: String, doCache: Boolean)(@transient context: SQLContext)
98+
extends LeafNode with Command {
9999

100100
override protected[sql] lazy val sideEffectResult = {
101101
if (doCache) {

sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
package org.apache.spark.sql
19-
package hive
18+
package org.apache.spark.sql.hive
2019

2120
import java.io.{BufferedReader, File, InputStreamReader, PrintStream}
2221
import java.util.{ArrayList => JArrayList}
@@ -32,11 +31,13 @@ import org.apache.hadoop.hive.ql.session.SessionState
3231

3332
import org.apache.spark.SparkContext
3433
import org.apache.spark.rdd.RDD
34+
import org.apache.spark.sql._
3535
import org.apache.spark.sql.catalyst.ScalaReflection
3636
import org.apache.spark.sql.catalyst.analysis.{Analyzer, OverrideCatalog}
3737
import org.apache.spark.sql.catalyst.plans.logical._
3838
import org.apache.spark.sql.catalyst.types._
39-
import org.apache.spark.sql.execution._
39+
import org.apache.spark.sql.execution.QueryExecutionException
40+
import org.apache.spark.sql.execution.{Command => PhysicalCommand}
4041

4142
/**
4243
* Starts up an instance of hive where metadata is stored locally. An in-process metadata data is

sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveStrategies.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private[hive] trait HiveStrategies {
7979
case class HiveCommandStrategy(context: HiveContext) extends Strategy {
8080
def apply(plan: LogicalPlan): Seq[SparkPlan] = plan match {
8181
case logical.NativeCommand(sql) =>
82-
NativeCommandPhysical(sql, plan.output)(context) :: Nil
82+
NativeCommand(sql, plan.output)(context) :: Nil
8383
case _ => Nil
8484
}
8585
}

sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/hiveOperators.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,10 +434,10 @@ case class InsertIntoHiveTable(
434434
* :: DeveloperApi ::
435435
*/
436436
@DeveloperApi
437-
case class NativeCommandPhysical(
437+
case class NativeCommand(
438438
sql: String, output: Seq[Attribute])(
439439
@transient context: HiveContext)
440-
extends LeafNode with PhysicalCommand {
440+
extends LeafNode with Command {
441441

442442
override protected[sql] lazy val sideEffectResult: Seq[String] = context.runSqlHive(sql)
443443

sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
1717

1818
package org.apache.spark.sql.hive.execution
1919

20-
import org.apache.spark.sql.Row
21-
import org.apache.spark.sql.catalyst.plans.logical.ExplainCommand
2220
import org.apache.spark.sql.hive.test.TestHive
2321
import org.apache.spark.sql.hive.test.TestHive._
24-
import org.apache.spark.sql.execution.ExplainCommandPhysical
22+
import org.apache.spark.sql.{execution, Row}
2523

2624
/**
2725
* A set of test cases expressed in Hive QL that are not covered by the tests included in the hive distribution.
@@ -173,7 +171,7 @@ class HiveQuerySuite extends HiveComparisonTest {
173171
}
174172
assert(explanation.size == 1)
175173

176-
val explainCommandClassName = classOf[ExplainCommandPhysical].getSimpleName.stripSuffix("$")
174+
val explainCommandClassName = classOf[execution.ExplainCommand].getSimpleName.stripSuffix("$")
177175
assert(explanation.head.contains(explainCommandClassName))
178176

179177
TestHive.reset()

0 commit comments

Comments
 (0)