Skip to content

Commit 6f4ce42

Browse files
committed
Moved logical command classes to a separate file
1 parent 3458a24 commit 6f4ce42

File tree

2 files changed

+61
-39
lines changed

2 files changed

+61
-39
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/LogicalPlan.scala

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ package org.apache.spark.sql.catalyst.plans.logical
2020
import org.apache.spark.sql.catalyst.errors.TreeNodeException
2121
import org.apache.spark.sql.catalyst.expressions._
2222
import org.apache.spark.sql.catalyst.plans.QueryPlan
23-
import org.apache.spark.sql.catalyst.types.{StringType, StructType}
23+
import org.apache.spark.sql.catalyst.types.StructType
2424
import org.apache.spark.sql.catalyst.trees
2525

2626
abstract class LogicalPlan extends QueryPlan[LogicalPlan] {
@@ -96,44 +96,6 @@ abstract class LeafNode extends LogicalPlan with trees.LeafNode[LogicalPlan] {
9696
def references = Set.empty
9797
}
9898

99-
/**
100-
* A logical node that represents a non-query command to be executed by the system. For example,
101-
* commands can be used by parsers to represent DDL operations.
102-
*/
103-
abstract class Command extends LeafNode {
104-
self: Product =>
105-
def output: Seq[Attribute] = Seq.empty // TODO: SPARK-2081 should fix this
106-
}
107-
108-
/**
109-
* Returned for commands supported by a given parser, but not catalyst. In general these are DDL
110-
* commands that are passed directly to another system.
111-
*/
112-
case class NativeCommand(cmd: String) extends Command
113-
114-
/**
115-
* Commands of the form "SET (key) (= value)".
116-
*/
117-
case class SetCommand(key: Option[String], value: Option[String]) extends Command {
118-
override def output = Seq(
119-
AttributeReference("key", StringType, nullable = false)(),
120-
AttributeReference("value", StringType, nullable = false)()
121-
)
122-
}
123-
124-
/**
125-
* Returned by a parser when the users only wants to see what query plan would be executed, without
126-
* actually performing the execution.
127-
*/
128-
case class ExplainCommand(plan: LogicalPlan) extends Command {
129-
override def output = Seq(AttributeReference("plan", StringType, nullable = false)())
130-
}
131-
132-
/**
133-
* Returned for the "CACHE TABLE tableName" and "UNCACHE TABLE tableName" command.
134-
*/
135-
case class CacheCommand(tableName: String, doCache: Boolean) extends Command
136-
13799
/**
138100
* A logical plan node with single child.
139101
*/
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.spark.sql.catalyst.plans.logical
19+
20+
import org.apache.spark.sql.catalyst.expressions.{AttributeReference, Attribute}
21+
import org.apache.spark.sql.catalyst.types.StringType
22+
23+
/**
24+
* A logical node that represents a non-query command to be executed by the system. For example,
25+
* commands can be used by parsers to represent DDL operations.
26+
*/
27+
abstract class Command extends LeafNode {
28+
self: Product =>
29+
def output: Seq[Attribute] = Seq.empty // TODO: SPARK-2081 should fix this
30+
}
31+
32+
/**
33+
* Returned for commands supported by a given parser, but not catalyst. In general these are DDL
34+
* commands that are passed directly to another system.
35+
*/
36+
case class NativeCommand(cmd: String) extends Command
37+
38+
/**
39+
* Commands of the form "SET (key) (= value)".
40+
*/
41+
case class SetCommand(key: Option[String], value: Option[String]) extends Command {
42+
override def output = Seq(
43+
AttributeReference("key", StringType, nullable = false)(),
44+
AttributeReference("value", StringType, nullable = false)()
45+
)
46+
}
47+
48+
/**
49+
* Returned by a parser when the users only wants to see what query plan would be executed, without
50+
* actually performing the execution.
51+
*/
52+
case class ExplainCommand(plan: LogicalPlan) extends Command {
53+
override def output = Seq(AttributeReference("plan", StringType, nullable = false)())
54+
}
55+
56+
/**
57+
* Returned for the "CACHE TABLE tableName" and "UNCACHE TABLE tableName" command.
58+
*/
59+
case class CacheCommand(tableName: String, doCache: Boolean) extends Command
60+

0 commit comments

Comments
 (0)