diff options
author | Yin Huai <yhuai@databricks.com> | 2016-04-15 17:48:41 -0700 |
---|---|---|
committer | Reynold Xin <rxin@databricks.com> | 2016-04-15 17:48:41 -0700 |
commit | b2dfa849599843269a43e6e0f2ab8c539dfc32b6 (patch) | |
tree | 7ab85d25e84b91529b5ef7aa310154a645027c56 /sql/hive/src | |
parent | 4df65184b6b865a26e4d5c99bbfd3c24ab7179dc (diff) | |
download | spark-b2dfa849599843269a43e6e0f2ab8c539dfc32b6.tar.gz spark-b2dfa849599843269a43e6e0f2ab8c539dfc32b6.tar.bz2 spark-b2dfa849599843269a43e6e0f2ab8c539dfc32b6.zip |
[SPARK-14668][SQL] Move CurrentDatabase to Catalyst
## What changes were proposed in this pull request?
This PR moves `CurrentDatabase` from sql/hive package to sql/catalyst. It also adds the function description, which looks like the following.
```
scala> sqlContext.sql("describe function extended current_database").collect.foreach(println)
[Function: current_database]
[Class: org.apache.spark.sql.execution.command.CurrentDatabase]
[Usage: current_database() - Returns the current database.]
[Extended Usage:
> SELECT current_database()]
```
## How was this patch tested?
Existing tests
Author: Yin Huai <yhuai@databricks.com>
Closes #12424 from yhuai/SPARK-14668.
Diffstat (limited to 'sql/hive/src')
-rw-r--r-- | sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala | 18 |
1 files changed, 0 insertions, 18 deletions
diff --git a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala index ff93bfc4a3..7ebdad1a68 100644 --- a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala +++ b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala @@ -61,19 +61,6 @@ import org.apache.spark.unsafe.types.UTF8String import org.apache.spark.util.Utils /** - * Returns the current database of metadataHive. - */ -private[hive] case class CurrentDatabase(ctx: HiveContext) - extends LeafExpression with CodegenFallback { - override def dataType: DataType = StringType - override def foldable: Boolean = true - override def nullable: Boolean = false - override def eval(input: InternalRow): Any = { - UTF8String.fromString(ctx.sessionState.catalog.getCurrentDatabase) - } -} - -/** * An instance of the Spark SQL execution engine that integrates with data stored in Hive. * Configuration for Hive is read from hive-site.xml on the classpath. * @@ -133,11 +120,6 @@ class HiveContext private[hive]( @transient protected[sql] override lazy val sessionState = new HiveSessionState(self) - // The Hive UDF current_database() is foldable, will be evaluated by optimizer, - // but the optimizer can't access the SessionState of metadataHive. - sessionState.functionRegistry.registerFunction( - "current_database", (e: Seq[Expression]) => new CurrentDatabase(self)) - /** * When true, enables an experimental feature where metastore tables that use the parquet SerDe * are automatically converted to use the Spark SQL parquet table scan, instead of the Hive |