Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/2543#discussion_r18127069
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypes.scala
---
@@ -73,31 +75,35 @@ case class GetItem(child: Expression, ordinal:
Expression) extends Expression {
/**
* Returns the value of fields in the Struct `child`.
*/
-case class GetField(child: Expression, fieldName: String) extends
UnaryExpression {
+case class GetField(child: Expression, field: StructField, ordinal: Int)
extends UnaryExpression {
type EvaluatedType = Any
def dataType = field.dataType
override def nullable = child.nullable || field.nullable
override def foldable = child.foldable
- protected def structType = child.dataType match {
- case s: StructType => s
- case otherType => sys.error(s"GetField is not valid on fields of type
$otherType")
- }
-
- lazy val field =
- structType.fields
- .find(_.name == fieldName)
- .getOrElse(sys.error(s"No such field $fieldName in
${child.dataType}"))
-
- lazy val ordinal = structType.fields.indexOf(field)
-
- override lazy val resolved = childrenResolved &&
child.dataType.isInstanceOf[StructType]
--- End diff --
Currently all `GetField`s are resolved as I try to resolve them in the
`ResolveGetField` rule. If it can't be resolved(field not exists in Strct
etc.), the rule will throw Exception. That's why I removed the `resolved` field.
---
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]