Github user marmbrus commented on a diff in the pull request:
https://github.com/apache/spark/pull/9726#discussion_r44998171
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/ScalaReflection.scala
---
@@ -18,34 +18,22 @@
package org.apache.spark.sql.catalyst
import org.apache.spark.sql.catalyst.analysis.{UnresolvedExtractValue,
UnresolvedAttribute}
-import org.apache.spark.sql.catalyst.util.{GenericArrayData,
ArrayBasedMapData, ArrayData, DateTimeUtils}
+import org.apache.spark.sql.catalyst.util.{GenericArrayData,
ArrayBasedMapData, DateTimeUtils}
import org.apache.spark.sql.catalyst.expressions._
-import org.apache.spark.sql.catalyst.plans.logical.LocalRelation
import org.apache.spark.sql.types._
import org.apache.spark.unsafe.types.UTF8String
import org.apache.spark.util.Utils
/**
- * A default version of ScalaReflection that uses the runtime universe.
+ * Support for generating catalyst schemas for scala objects.
*/
-object ScalaReflection extends ScalaReflection {
+object ScalaReflection {
val universe: scala.reflect.runtime.universe.type =
scala.reflect.runtime.universe
// Since we are creating a runtime mirror usign the class loader of
current thread,
// we need to use def at here. So, every time we call mirror, it is
using the
// class loader of the current thread.
- override def mirror: universe.Mirror =
+ val mirror: universe.Mirror =
universe.runtimeMirror(Thread.currentThread().getContextClassLoader)
-}
-
-/**
- * Support for generating catalyst schemas for scala objects.
- */
-trait ScalaReflection {
- /** The universe we work in (runtime or macro) */
- val universe: scala.reflect.api.Universe
-
- /** The mirror used to access types in the universe */
- def mirror: universe.Mirror
--- End diff --
This level of indirection is on purpose. It lets us use the same
reflection code both at runtime and in macros. Even if we aren't using that
right now, we shouldn't undo the work that was done to make this possible.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]