@@ -154,7 +154,7 @@ case class Lower(child: Expression) extends UnaryExpression with CaseConversionE
154
154
}
155
155
156
156
/** A base trait for functions that compare two strings, returning a boolean. */
157
- trait StringComparison {
157
+ trait StringComparison extends ExpectsInputTypes {
158
158
self : BinaryExpression =>
159
159
160
160
def compare (l : UTF8String , r : UTF8String ): Boolean
@@ -163,6 +163,8 @@ trait StringComparison {
163
163
164
164
override def nullable : Boolean = left.nullable || right.nullable
165
165
166
+ override def expectedChildTypes : Seq [DataType ] = Seq (StringType , StringType )
167
+
166
168
override def eval (input : Row ): Any = {
167
169
val leftEval = left.eval(input)
168
170
if (leftEval == null ) {
@@ -183,27 +185,24 @@ trait StringComparison {
183
185
* A function that returns true if the string `left` contains the string `right`.
184
186
*/
185
187
case class Contains (left : Expression , right : Expression )
186
- extends BinaryExpression with Predicate with StringComparison with ExpectsInputTypes {
188
+ extends BinaryExpression with Predicate with StringComparison {
187
189
override def compare (l : UTF8String , r : UTF8String ): Boolean = l.contains(r)
188
- override def expectedChildTypes : Seq [DataType ] = Seq (StringType , StringType )
189
190
}
190
191
191
192
/**
192
193
* A function that returns true if the string `left` starts with the string `right`.
193
194
*/
194
195
case class StartsWith (left : Expression , right : Expression )
195
- extends BinaryExpression with Predicate with StringComparison with ExpectsInputTypes {
196
+ extends BinaryExpression with Predicate with StringComparison {
196
197
override def compare (l : UTF8String , r : UTF8String ): Boolean = l.startsWith(r)
197
- override def expectedChildTypes : Seq [DataType ] = Seq (StringType , StringType )
198
198
}
199
199
200
200
/**
201
201
* A function that returns true if the string `left` ends with the string `right`.
202
202
*/
203
203
case class EndsWith (left : Expression , right : Expression )
204
- extends BinaryExpression with Predicate with StringComparison with ExpectsInputTypes {
204
+ extends BinaryExpression with Predicate with StringComparison {
205
205
override def compare (l : UTF8String , r : UTF8String ): Boolean = l.endsWith(r)
206
- override def expectedChildTypes : Seq [DataType ] = Seq (StringType , StringType )
207
206
}
208
207
209
208
/**
0 commit comments