Set context class loader inside Hive procedures
The procedures call Hadoop code which can load file systems or
perform other actions that require the context class loader.
Extracted-From:
@@ -18,6 +18,7 @@ import com.facebook.presto.hive.PartitionUpdate.UpdateMode;
import com.facebook.presto.hive.metastore.ExtendedHiveMetastore;
import com.facebook.presto.spi.ConnectorSession;
import com.facebook.presto.spi.PrestoException;
+import com.facebook.presto.spi.classloader.ThreadContextClassLoader;
import com.facebook.presto.spi.procedure.Procedure;
import com.facebook.presto.spi.procedure.Procedure.Argument;
import com.google.common.collect.ImmutableList;
@@ -83,6 +84,13 @@ public class CreateEmptyPartitionProcedure
}
public void createEmptyPartition(ConnectorSession session, String schema, String table, List<Object> partitionColumnNames, List<Object> partitionValues)
+ {
+ try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(getClass().getClassLoader())) {
+ doCreateEmptyPartition(session, schema, table, partitionColumnNames, partitionValues);
+ }
+ }
+
+ private void doCreateEmptyPartition(ConnectorSession session, String schema, String table, List<Object> partitionColumnNames, List<Object> partitionValues)
{
TransactionalMetadata hiveMetadata = hiveMetadataFactory.get();
