diff options
author | Michael Armbrust <michael@databricks.com> | 2014-11-07 11:51:20 -0800 |
---|---|---|
committer | Michael Armbrust <michael@databricks.com> | 2014-11-07 11:51:33 -0800 |
commit | f1f1ae418031957256e7dac896e29d64c81bf1a4 (patch) | |
tree | a30013135931f73b49e43542910a23257cabec51 /sql/catalyst | |
parent | 2cd8e3e2b00c6191bccfb70743df7a4c9ffd98b2 (diff) | |
download | spark-f1f1ae418031957256e7dac896e29d64c81bf1a4.tar.gz spark-f1f1ae418031957256e7dac896e29d64c81bf1a4.tar.bz2 spark-f1f1ae418031957256e7dac896e29d64c81bf1a4.zip |
[SQL] Support ScalaReflection of schema in different universes
Author: Michael Armbrust <michael@databricks.com>
Closes #3096 from marmbrus/reflectionContext and squashes the following commits:
adc221f [Michael Armbrust] Support ScalaReflection of schema in different universes
(cherry picked from commit 8154ed7df6c5407e638f465d3bd86b43f36216ef)
Signed-off-by: Michael Armbrust <michael@databricks.com>
Diffstat (limited to 'sql/catalyst')
-rw-r--r-- | sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/ScalaReflection.scala | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/ScalaReflection.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/ScalaReflection.scala index 9cda373623..71034c2c43 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/ScalaReflection.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/ScalaReflection.scala @@ -26,14 +26,26 @@ import org.apache.spark.sql.catalyst.plans.logical.LocalRelation import org.apache.spark.sql.catalyst.types._ import org.apache.spark.sql.catalyst.types.decimal.Decimal + /** - * Provides experimental support for generating catalyst schemas for scala objects. + * A default version of ScalaReflection that uses the runtime universe. */ -object ScalaReflection { +object ScalaReflection extends ScalaReflection { + val universe: scala.reflect.runtime.universe.type = scala.reflect.runtime.universe +} + +/** + * Support for generating catalyst schemas for scala objects. + */ +trait ScalaReflection { + /** The universe we work in (runtime or macro) */ + val universe: scala.reflect.api.Universe + + import universe._ + // The Predef.Map is scala.collection.immutable.Map. // Since the map values can be mutable, we explicitly import scala.collection.Map at here. import scala.collection.Map - import scala.reflect.runtime.universe._ case class Schema(dataType: DataType, nullable: Boolean) |