Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/20085#discussion_r160347559
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
---
@@ -182,6 +182,111 @@ case class StaticInvoke(
}
}
+/**
+ * Invokes a call to reference to a static field.
+ *
+ * @param staticObject The target of the static call. This can either be
the object itself
+ * (methods defined on scala objects), or the class
object
+ * (static methods defined in java).
+ * @param dataType The expected return type of the function call.
+ * @param fieldName The field to reference.
+ */
+case class StaticField(
+ staticObject: Class[_],
+ dataType: DataType,
+ fieldName: String) extends Expression with NonSQLExpression {
+
+ val objectName = staticObject.getName.stripSuffix("$")
+
+ override def nullable: Boolean = false
+ override def children: Seq[Expression] = Nil
+
+ override def eval(input: InternalRow): Any =
+ throw new UnsupportedOperationException("Only code-generated
evaluation is supported.")
+
+ override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {
+ val javaType = ctx.javaType(dataType)
+
+ val code = s"""
+ final $javaType ${ev.value} = $objectName.$fieldName;
--- End diff --
do we need this expression for such a simple function?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]