File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed
catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions
core/src/test/scala/org/apache/spark/sql Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -729,8 +729,8 @@ case class GetExternalRowField(
729729 val row = child.gen(ctx)
730730
731731 val getField = dataType match {
732- case ObjectType (x) if x == classOf [Row ] => s """ $row.getStruct( $index) """
733- case _ => s """ ( ${ctx.boxedType(dataType)}) $row.get( $index) """
732+ case ObjectType (x) if x == classOf [Row ] => s """ ${ row.value} .getStruct( $index) """
733+ case _ => s """ ( ${ctx.boxedType(dataType)}) ${ row.value} .get( $index) """
734734 }
735735
736736 ev.isNull = " false"
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ import java.sql.{Date, Timestamp}
2222
2323import scala .language .postfixOps
2424
25- import org .apache .spark .sql .catalyst .encoders .OuterScopes
25+ import org .apache .spark .sql .catalyst .encoders .{ OuterScopes , RowEncoder }
2626import org .apache .spark .sql .execution .streaming .MemoryStream
2727import org .apache .spark .sql .functions ._
2828import org .apache .spark .sql .test .SharedSQLContext
@@ -626,6 +626,22 @@ class DatasetSuite extends QueryTest with SharedSQLContext {
626626 // Make sure the generated code for this plan can compile and execute.
627627 checkDataset(wideDF.map(_.getLong(0 )), 0L until 10 : _* )
628628 }
629+
630+ test(" runtime null check for RowEncoder" ) {
631+ val schema = new StructType ().add(" i" , IntegerType , nullable = false )
632+ val df = sqlContext.range(10 ).map(l => {
633+ if (l % 5 == 0 ) {
634+ Row (null )
635+ } else {
636+ Row (l)
637+ }
638+ })(RowEncoder (schema))
639+
640+ val message = intercept[Exception ] {
641+ df.collect()
642+ }.getMessage
643+ assert(message.contains(" Runtime null check failed" ))
644+ }
629645}
630646
631647case class OtherTuple (_1 : String , _2 : Int )
You can’t perform that action at this time.
0 commit comments