Returns a Sequence of attributes for the given case class type.
Any codes calling scala.reflect.api.Types.TypeApi.<:<
should be wrapped by this method to
clean up the Scala reflection garbage automatically.
Any codes calling scala.reflect.api.Types.TypeApi.<:<
should be wrapped by this method to
clean up the Scala reflection garbage automatically. Otherwise, it will leak some objects to
scala.reflect.runtime.JavaUniverse.undoLog
.
This method will also wrap func
with ScalaReflectionLock.synchronized
so the caller doesn't
need to call it again.
https://github.com/scala/bug/issues/8302
Returns the Spark SQL DataType for a given scala type.
Returns the Spark SQL DataType for a given scala type. Where this is not an exact mapping to a native type, an ObjectType is returned. Special handling is also used for Arrays including those that hold primitive types.
Unlike schemaFor
, this function doesn't do any massaging of types into the Spark SQL type
system. As a result, ObjectType will be returned for things like boxed Integers
Whether the fields of the given type is defined entirely by its constructor parameters.
Returns an expression that can be used to deserialize an input row to an object of type T
with a compatible schema.
Returns an expression that can be used to deserialize an input row to an object of type T
with a compatible schema. Fields of the row will be extracted using UnresolvedAttributes
of the same name as the constructor arguments. Nested classes will have their fields accessed
using UnresolvedExtractValue.
When used on a primitive type, the constructor will instead default to extracting the value from ordinal 0 (since there are no names to map to). The actual location can be moved by calling resolve/bind with a new schema.
Returns the full class name for a type.
Returns the full class name for a type. The returned name is the canonical Scala name, where each component is separated by a period. It is NOT the Java-equivalent runtime name (no dollar signs).
In simple cases, both the Scala and Java names are the same, however when Scala generates constructs that do not map to a Java equivalent, such as singleton objects or nested classes in package objects, it uses the dollar sign ($) to create synthetic classes, emulating behaviour in Java bytecode.
Returns the parameter names for the primary constructor of this class.
Returns the parameter names for the primary constructor of this class.
Logically we should call getConstructorParameters
and throw away the parameter types to get
parameter names, however there are some weird scala reflection problems and this method is a
workaround to avoid getting parameter types.
Returns the parameter values for the primary constructor of this class.
Returns the parameter names and types for the primary constructor of this class.
Returns the parameter names and types for the primary constructor of this class.
Note that it only works for scala classes with primary constructor, and currently doesn't support inner class.
Returns the parameter names and types for the primary constructor of this type.
Returns the parameter names and types for the primary constructor of this type.
Note that it only works for scala classes with primary constructor, and currently doesn't support inner class.
Returns classes of input parameters of scala function object.
Returns classes of input parameters of scala function object.
Returns true if the value of this data type is same between internal and external.
Return the Scala Type for T
in the current classloader mirror.
Return the Scala Type for T
in the current classloader mirror.
Use this method instead of the convenience method universe.typeOf
, which
assumes that all types can be found in the classloader that loaded scala-reflect classes.
That's not necessarily the case when running using Eclipse launchers or even
Sbt console or test (without fork := true
).
SPARK-5281
The mirror used to access types in the universe
The mirror used to access types in the universe
Returns true if the given type is option of product type, e.
Returns true if the given type is option of product type, e.g. Option[Tuple2]
. Note that,
we also treat DefinedByConstructorParams as product type.
Returns a catalyst DataType and its nullability for the given Scala Type using reflection.
Returns a catalyst DataType and its nullability for the given Scala Type using reflection.
Returns an expression for serializing an object of type T to an internal row.
Returns an expression for serializing an object of type T to an internal row.
If the given type is not supported, i.e. there is no encoder can be built for this type,
an UnsupportedOperationException will be thrown with detailed error message to explain
the type path walked so far and which class we are not supporting.
There are 4 kinds of type path:
* the root type: root class: "abc.xyz.MyClass"
* the value type of Option: option value class: "abc.xyz.MyClass"
* the element type of Array or Seq: array element class: "abc.xyz.MyClass"
* the field of Product: field (class: "abc.xyz.MyClass", name: "myField")
The universe we work in (runtime or macro)
The universe we work in (runtime or macro)
A default version of ScalaReflection that uses the runtime universe.