|
| 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