File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
sql/hive/src/main/scala/org/apache/spark/sql/hive Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ import com.esotericsoftware.kryo.io.{Input, Output}
3131
3232import org .apache .hadoop .conf .Configuration
3333import org .apache .hadoop .fs .Path
34- import org .apache .hadoop .hive .ql .exec .Utilities
34+ import org .apache .hadoop .hive .ql .exec .{ UDF , Utilities }
3535import org .apache .hadoop .hive .ql .plan .{FileSinkDesc , TableDesc }
3636import org .apache .hadoop .hive .serde2 .ColumnProjectionUtils
3737import org .apache .hadoop .hive .serde2 .avro .{AvroGenericRecordWritable , AvroSerdeUtils }
@@ -195,8 +195,14 @@ private[hive] object HiveShim {
195195 if (instance != null ) {
196196 instance.asInstanceOf [UDFType ]
197197 } else {
198- Utils .getContextOrSparkClassLoader
198+ val func = Utils .getContextOrSparkClassLoader
199199 .loadClass(functionClassName).newInstance.asInstanceOf [UDFType ]
200+ if (! func.isInstanceOf [UDF ]) {
201+ // We cache the function if it's no the Simple UDF,
202+ // as we always have to create new instance for Simple UDF
203+ instance = func
204+ }
205+ func
200206 }
201207 }
202208 }
You can’t perform that action at this time.
0 commit comments