forked from apache/spark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SPARK-1704: Add CommandStrategy and ExplainCommandPhysical.
- Loading branch information
1 parent
8d21056
commit 408f574
Showing
5 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
sql/core/src/main/scala/org/apache/spark/sql/execution/commands.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.spark.sql.execution | ||
|
||
import org.apache.spark.annotation.DeveloperApi | ||
import org.apache.spark.rdd.RDD | ||
import org.apache.spark.sql.{SQLContext, Row} | ||
import org.apache.spark.sql.catalyst.expressions.{GenericRow, Attribute} | ||
import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan | ||
|
||
/** | ||
* :: DeveloperApi :: | ||
*/ | ||
//@DeveloperApi | ||
//case class SetCommandPhysical( | ||
// key: Option[String], | ||
// value: Option[String], | ||
// context: SQLContext) | ||
// extends LeafNode { | ||
// | ||
// "hi".split("=", 2) | ||
// | ||
// def execute(): RDD[Row] = (key, value) match { | ||
// case (Some(k), Some(v)) => context.emptyResult | ||
// case (Some(k), None) => | ||
// val resultString = context.sqlConf.getOption(k) match { | ||
// case Some(v) => s"$k=$v" | ||
// case None => s"$k is undefined" | ||
// } | ||
// context.sparkContext.parallelize(Seq(new GenericRow(Array[Any](resultString))), 1) | ||
// case (None, None) => | ||
// val pairs = context.sqlConf.getAll | ||
// val rows = pairs.map { case (k, v) => | ||
// new GenericRow(Array[Any](s"$k=$v")) | ||
// }.toSeq | ||
// // Assume config parameters can fit into one split (machine) ;) | ||
// context.sparkContext.parallelize(rows, 1) | ||
// case _ => context.emptyResult | ||
// } | ||
// | ||
// def output: Seq[Attribute] = Seq.empty // TODO: right thing? | ||
//} | ||
|
||
|
||
case class ExplainCommandPhysical(child: SparkPlan) | ||
(@transient context: SQLContext) extends UnaryNode { | ||
def execute(): RDD[Row] = { | ||
val lines = child.toString.split("\n").map(s => new GenericRow(Array[Any](s))) | ||
context.sparkContext.parallelize(lines) | ||
} | ||
|
||
def output: Seq[Attribute] = child.output // right thing to do? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters