Source:
public HiveInsertTableHandle beginInsert(ConnectorSession session, ConnectorTableHandle tableHandle) { verifyJvmTimeZone(); SchemaTableName tableName = schemaTableName(tableHandle); Optional<Table> table = metastore.getTable(tableName.getSchemaName(), tableName.getTableName()); if (!table.isPresent()) { throw new TableNotFoundException(tableName); } checkTableIsWritable(table.get(), writesToNonManagedTablesEnabled); for (Column column : table.get().getDataColumns()) { if (!isWritableType(column.getType())) { throw new PrestoException( NOT_SUPPORTED, format("Inserting into Hive table %s.%s with column type %s not supported", table.get().getDatabaseName(), table.get().getTableName(), column.getType())); } } List<HiveColumnHandle> handles = hiveColumnHandles(table.get()).stream() .filter(columnHandle -> !columnHandle.isHidden()) .collect(toList()); HiveStorageFormat tableStorageFormat = extractHiveStorageFormat(table.get()); LocationHandle locationHandle; if (table.get().getTableType().equals(TEMPORARY_TABLE)) { locationHandle = locationService.forTemporaryTable(metastore, session, tableName.getSchemaName(), tableName.getTableName()); } else { locationHandle = locationService.forExistingTable(metastore, session, table.get()); } HiveInsertTableHandle result = new HiveInsertTableHandle( tableName.getSchemaName(), tableName.getTableName(), handles, session.getQueryId(), metastore.generatePageSinkMetadata(tableName), locationHandle, table.get().getStorage().getBucketProperty(), tableStorageFormat, isRespectTableFormat(session) ? tableStorageFormat : HiveSessionProperties.getHiveStorageFormat(session)); WriteInfo writeInfo = locationService.getQueryWriteInfo(locationHandle); metastore.declareIntentionToWrite(session, writeInfo.getWriteMode(), writeInfo.getWritePath(), result.getFilePrefix(), tableName); return result; }

Target:
public HiveInsertTableHandle beginInsert(ConnectorSession session, ConnectorTableHandle tableHandle) { verifyJvmTimeZone(); SchemaTableName tableName = schemaTableName(tableHandle); Optional<Table> table = metastore.getTable(tableName.getSchemaName(), tableName.getTableName()); if (!table.isPresent()) { throw new TableNotFoundException(tableName); } checkTableIsWritable(table.get(), writesToNonManagedTablesEnabled); for (Column column : table.get().getDataColumns()) { if (!isWritableType(column.getType())) { throw new PrestoException( NOT_SUPPORTED, format("Inserting into Hive table %s.%s with column type %s not supported", table.get().getDatabaseName(), table.get().getTableName(), column.getType())); } } List<HiveColumnHandle> handles = hiveColumnHandles(table.get()).stream() .filter(columnHandle -> !columnHandle.isHidden()) .collect(toList()); HiveStorageFormat tableStorageFormat = extractHiveStorageFormat(table.get()); LocationHandle locationHandle; if (table.get().getTableType().equals(TEMPORARY_TABLE)) { locationHandle = locationService.forTemporaryTable(metastore, session, table.get()); } else { locationHandle = locationService.forExistingTable(metastore, session, table.get()); } HiveInsertTableHandle result = new HiveInsertTableHandle( tableName.getSchemaName(), tableName.getTableName(), handles, session.getQueryId(), metastore.generatePageSinkMetadata(tableName), locationHandle, table.get().getStorage().getBucketProperty(), tableStorageFormat, isRespectTableFormat(session) ? tableStorageFormat : HiveSessionProperties.getHiveStorageFormat(session)); WriteInfo writeInfo = locationService.getQueryWriteInfo(locationHandle); metastore.declareIntentionToWrite(session, writeInfo.getWriteMode(), writeInfo.getWritePath(), result.getFilePrefix(), tableName); return result; }