presto-hive/src/main/java/io/prestosql/plugin/hive/HiveLocationService.java/HiveLocationService/shouldUseTemporaryDirectory
class HiveLocationService:    private boolean shouldUseTemporaryDirectory(ConnectorSession session, HdfsContext context, Path path)
    {
        return isTemporaryStagingDirectoryEnabled(session)
                // skip using temporary directory for S3
                && !isS3FileSystem(context, hdfsEnvironment, path)
                // skip using temporary directory if destination is encrypted; it's not possible to move a file between encryption zones
                && !isHdfsEncrypted(context, hdfsEnvironment, path);
    }