Skip to content

Commit 3595ce7

Browse files
committed
reverted instance cache as commented
1 parent e2e9835 commit 3595ce7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveShim.scala

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import com.esotericsoftware.kryo.io.{Input, Output}
3131

3232
import org.apache.hadoop.conf.Configuration
3333
import org.apache.hadoop.fs.Path
34-
import org.apache.hadoop.hive.ql.exec.Utilities
34+
import org.apache.hadoop.hive.ql.exec.{UDF, Utilities}
3535
import org.apache.hadoop.hive.ql.plan.{FileSinkDesc, TableDesc}
3636
import org.apache.hadoop.hive.serde2.ColumnProjectionUtils
3737
import 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
}

0 commit comments

Comments
 (0)