@@ -78,10 +78,12 @@ object ExtractValue {
7878 }
7979 }
8080
81- def unapply (g : ExtractValue ): Option [(Expression , Expression )] = g match {
81+ def unapply (g : Expression ): Option [(Expression , Expression )] = g match {
8282 case o : GetArrayItem => Some ((o.child, o.ordinal))
8383 case o : GetMapValue => Some ((o.child, o.key))
84- case s : ExtractValueWithStruct => Some ((s.child, null ))
84+ case o : GetStructField => Some ((o.child, null ))
85+ case o : GetArrayStructFields => Some ((o.child, null ))
86+ case _ => None
8587 }
8688
8789 /**
@@ -103,32 +105,17 @@ object ExtractValue {
103105 }
104106}
105107
106- /**
107- * A common interface of all kinds of extract value expressions.
108- * Note: concrete extract value expressions are created only by `ExtractValue.apply`,
109- * we don't need to do type check for them.
110- */
111- trait ExtractValue {
112- self : Expression =>
113- }
114-
115- abstract class ExtractValueWithStruct extends UnaryExpression with ExtractValue {
116- self : Product =>
117-
118- def field : StructField
119- override def toString : String = s " $child. ${field.name}"
120- }
121-
122108/**
123109 * Returns the value of fields in the Struct `child`.
124110 *
125111 * No need to do type checking since it is handled by [[ExtractValue ]].
126112 */
127113case class GetStructField (child : Expression , field : StructField , ordinal : Int )
128- extends ExtractValueWithStruct {
114+ extends UnaryExpression {
129115
130116 override def dataType : DataType = field.dataType
131117 override def nullable : Boolean = child.nullable || field.nullable
118+ override def toString : String = s " $child. ${field.name}"
132119
133120 protected override def nullSafeEval (input : Any ): Any =
134121 input.asInstanceOf [InternalRow ](ordinal)
@@ -155,10 +142,11 @@ case class GetArrayStructFields(
155142 child : Expression ,
156143 field : StructField ,
157144 ordinal : Int ,
158- containsNull : Boolean ) extends ExtractValueWithStruct {
145+ containsNull : Boolean ) extends UnaryExpression {
159146
160147 override def dataType : DataType = ArrayType (field.dataType, containsNull)
161148 override def nullable : Boolean = child.nullable || containsNull || field.nullable
149+ override def toString : String = s " $child. ${field.name}"
162150
163151 protected override def nullSafeEval (input : Any ): Any = {
164152 input.asInstanceOf [Seq [InternalRow ]].map { row =>
@@ -191,8 +179,7 @@ case class GetArrayStructFields(
191179 *
192180 * No need to do type checking since it is handled by [[ExtractValue ]].
193181 */
194- case class GetArrayItem (child : Expression , ordinal : Expression )
195- extends BinaryExpression with ExtractValue {
182+ case class GetArrayItem (child : Expression , ordinal : Expression ) extends BinaryExpression {
196183
197184 override def toString : String = s " $child[ $ordinal] "
198185
@@ -231,12 +218,11 @@ case class GetArrayItem(child: Expression, ordinal: Expression)
231218}
232219
233220/**
234- * Returns the value of key `ordinal ` in Map `child`.
221+ * Returns the value of key `key ` in Map `child`.
235222 *
236223 * No need to do type checking since it is handled by [[ExtractValue ]].
237224 */
238- case class GetMapValue (child : Expression , key : Expression )
239- extends BinaryExpression with ExtractValue {
225+ case class GetMapValue (child : Expression , key : Expression ) extends BinaryExpression {
240226
241227 override def toString : String = s " $child[ $key] "
242228
0 commit comments