Source:
<code>public List<ConnectorTableLayoutResult> getTableLayouts(ConnectorSession session, ConnectorTableHandle tableHandle, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns) { HiveTableHandle handle = (HiveTableHandle) tableHandle; HivePartitionResult hivePartitionResult; if (handle.getAnalyzePartitionValues().isPresent()) { verify(constraint.getSummary().isAll(), "There shouldn't be any constraint for ANALYZE operation"); hivePartitionResult = partitionManager.getPartitions(metastore, tableHandle, handle.getAnalyzePartitionValues().get(), session); } else { hivePartitionResult = partitionManager.getPartitions(metastore, tableHandle, constraint, session); } Map<String, HiveColumnHandle> predicateColumns = hivePartitionResult.getEffectivePredicate().getDomains().get().keySet().stream() .map(HiveColumnHandle.class::cast) .collect(toImmutableMap(HiveColumnHandle::getName, Functions.identity())); Optional<HiveBucketHandle> hiveBucketHandle = hivePartitionResult.getBucketHandle(); int virtualBucketCount = getVirtualBucketCount(session); <START> if (!hivePartitionResult.getBucketHandle().isPresent() && virtualBucketCount > 1) { <END> hiveBucketHandle = Optional.of(createVirtualBucketHandle(virtualBucketCount)); } return ImmutableList.of(new ConnectorTableLayoutResult( getTableLayout( session, new HiveTableLayoutHandle( handle.getSchemaTableName(), ImmutableList.copyOf(hivePartitionResult.getPartitionColumns()), getPartitionsAsList(hivePartitionResult), hivePartitionResult.getEffectivePredicate().transform(HiveMetadata::toSubfield), TRUE_CONSTANT, predicateColumns, hivePartitionResult.getEnforcedConstraint(), hiveBucketHandle, hivePartitionResult.getBucketFilter())), hivePartitionResult.getUnenforcedConstraint())); }</code><technical_language>nit: 1 is a valid bucket count (in theory...)</technical_language>

Target:
public List<ConnectorTableLayoutResult> getTableLayouts(ConnectorSession session, ConnectorTableHandle tableHandle, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns) { HiveTableHandle handle = (HiveTableHandle) tableHandle; HivePartitionResult hivePartitionResult; if (handle.getAnalyzePartitionValues().isPresent()) { verify(constraint.getSummary().isAll(), "There shouldn't be any constraint for ANALYZE operation"); hivePartitionResult = partitionManager.getPartitions(metastore, tableHandle, handle.getAnalyzePartitionValues().get(), session); } else { hivePartitionResult = partitionManager.getPartitions(metastore, tableHandle, constraint, session); } Map<String, HiveColumnHandle> predicateColumns = hivePartitionResult.getEffectivePredicate().getDomains().get().keySet().stream() .map(HiveColumnHandle.class::cast) .collect(toImmutableMap(HiveColumnHandle::getName, Functions.identity())); Optional<HiveBucketHandle> hiveBucketHandle = hivePartitionResult.getBucketHandle(); int virtualBucketCount = getVirtualBucketCount(session); if (!hivePartitionResult.getBucketHandle().isPresent() && virtualBucketCount > 0) { hiveBucketHandle = Optional.of(createVirtualBucketHandle(virtualBucketCount)); } return ImmutableList.of(new ConnectorTableLayoutResult( getTableLayout( session, new HiveTableLayoutHandle( handle.getSchemaTableName(), ImmutableList.copyOf(hivePartitionResult.getPartitionColumns()), getPartitionsAsList(hivePartitionResult), hivePartitionResult.getEffectivePredicate().transform(HiveMetadata::toSubfield), TRUE_CONSTANT, predicateColumns, hivePartitionResult.getEnforcedConstraint(), hiveBucketHandle, hivePartitionResult.getBucketFilter())), hivePartitionResult.getUnenforcedConstraint())); }