[SPARK-1819] [SQL] Fix GetField.nullable.
`GetField.nullable` should be `true` not only when `field.nullable` is `true` but also when `child.nullable` is `true`. Author: Takuya UESHIN <ueshin@happy-camper.st> Closes #757 from ueshin/issues/SPARK-1819 and squashes the following commits: 8781a11 [Takuya UESHIN] Modify a test to use named parameters. 5bfc77d [Takuya UESHIN] Fix GetField.nullable.
This commit is contained in:
parent
db8cc6f28a
commit
94c9d6f598
|
@ -74,7 +74,7 @@ case class GetField(child: Expression, fieldName: String) extends UnaryExpressio
|
|||
type EvaluatedType = Any
|
||||
|
||||
def dataType = field.dataType
|
||||
override def nullable = field.nullable
|
||||
override def nullable = child.nullable || field.nullable
|
||||
override def foldable = child.foldable
|
||||
|
||||
protected def structType = child.dataType match {
|
||||
|
|
|
@ -364,6 +364,19 @@ class ExpressionEvaluationSuite extends FunSuite {
|
|||
|
||||
checkEvaluation(GetField(BoundReference(2, AttributeReference("c", typeS)()), "a"), "aa", row)
|
||||
checkEvaluation(GetField(Literal(null, typeS), "a"), null, row)
|
||||
|
||||
val typeS_notNullable = StructType(
|
||||
StructField("a", StringType, nullable = false)
|
||||
:: StructField("b", StringType, nullable = false) :: Nil
|
||||
)
|
||||
|
||||
assert(GetField(BoundReference(2,
|
||||
AttributeReference("c", typeS)()), "a").nullable === true)
|
||||
assert(GetField(BoundReference(2,
|
||||
AttributeReference("c", typeS_notNullable, nullable = false)()), "a").nullable === false)
|
||||
|
||||
assert(GetField(Literal(null, typeS), "a").nullable === true)
|
||||
assert(GetField(Literal(null, typeS_notNullable), "a").nullable === true)
|
||||
}
|
||||
|
||||
test("arithmetic") {
|
||||
|
|
Loading…
Reference in a new issue