@@ -25,6 +25,7 @@ import org.apache.spark.sql.catalyst.InternalRow
25
25
import org .apache .spark .sql .catalyst .expressions ._
26
26
import org .apache .spark .sql .errors .QueryExecutionErrors
27
27
import org .apache .spark .sql .execution .metric .SQLMetric
28
+ import org .apache .spark .sql .internal .SQLConf
28
29
import org .apache .spark .sql .types .{DataType , StructField , StructType }
29
30
import org .apache .spark .sql .vectorized .{ArrowColumnVector , ColumnarBatch }
30
31
@@ -77,17 +78,14 @@ class MapInBatchEvaluatorFactory(
77
78
val unsafeProj = UnsafeProjection .create(output, output)
78
79
79
80
columnarBatchIter.flatMap { batch =>
80
- // Ensure the schema matches the expected schema
81
- val actualSchema = batch.column(0 ).dataType()
82
- val strictCheck = true
83
- val isCompatible = if (strictCheck) {
84
- DataType .equalsIgnoreNullability(actualSchema, outputSchema)
85
- } else {
86
- outputSchema.sameType(actualSchema)
87
- }
88
- if (! isCompatible) {
89
- throw QueryExecutionErrors .arrowDataTypeMismatchError(
90
- PythonEvalType .toString(pythonEvalType), Seq (outputSchema), Seq (actualSchema))
81
+ if (SQLConf .get.pysparkArrowValidateSchema) {
82
+ // Ensure the schema matches the expected schema
83
+ val actualSchema = batch.column(0 ).dataType()
84
+ val isCompatible = DataType .equalsIgnoreCompatibleNullability(actualSchema, outputSchema)
85
+ if (! isCompatible) {
86
+ throw QueryExecutionErrors .arrowDataTypeMismatchError(
87
+ PythonEvalType .toString(pythonEvalType), Seq (outputSchema), Seq (actualSchema))
88
+ }
91
89
}
92
90
93
91
// Scalar Iterator UDF returns a StructType column in ColumnarBatch, select
0 commit comments