Source:
<code>private static Optional<Set<Integer>> getHiveBuckets(Table table, Map<ColumnHandle, Set<NullableValue>> bindings) { HiveBucketProperty hiveBucketProperty = table.getStorage().getBucketProperty().get(); checkArgument(hiveBucketProperty.getBucketFunctionType().equals(HIVE_COMPATIBLE), <START> "Expect hive compatible bucket function type to calculate bucket number based on Hive TypeInfo"); <END> List<String> bucketColumns = hiveBucketProperty.getBucketedBy(); if (bucketColumns.isEmpty()) { return Optional.empty(); } Map<String, HiveType> hiveTypes = table.getDataColumns().stream() .collect(toImmutableMap(Column::getName, Column::getType)); for (String column : bucketColumns) { if (!SUPPORTED_TYPES_FOR_BUCKET_FILTER.contains(hiveTypes.get(column))) { return Optional.empty(); } } Map<String, Set<NullableValue>> nameToBindings = bindings.entrySet().stream() .collect(toImmutableMap(entry -> ((HiveColumnHandle) entry.getKey()).getName(), Entry::getValue)); ImmutableList.Builder<Set<NullableValue>> orderedBindingsBuilder = ImmutableList.builder(); for (String columnName : bucketColumns) { if (!nameToBindings.containsKey(columnName)) { return Optional.empty(); } orderedBindingsBuilder.add(nameToBindings.get(columnName)); } List<Set<NullableValue>> orderedBindings = orderedBindingsBuilder.build(); int bucketCount = table.getStorage().getBucketProperty().get().getBucketCount(); List<TypeInfo> types = bucketColumns.stream() .map(hiveTypes::get) .map(HiveType::getTypeInfo) .collect(toImmutableList()); ImmutableSet.Builder<Integer> buckets = ImmutableSet.builder(); getHiveBuckets(new Object[types.size()], 0, orderedBindings, bucketCount, types, buckets); return Optional.of(buckets.build()); }</code><technical_language>nit: Expected bucketFunctionType HIVE_COMPATIBLE, %s ..</technical_language>

Target:
private static Optional<Set<Integer>> getHiveBuckets(Table table, Map<ColumnHandle, Set<NullableValue>> bindings) { if (bindings.isEmpty()) { return Optional.empty(); } HiveBucketProperty hiveBucketProperty = table.getStorage().getBucketProperty().get(); checkArgument(hiveBucketProperty.getBucketFunctionType().equals(HIVE_COMPATIBLE), "bucketFunctionType is expected to be HIVE_COMPATIBLE, got: %s", hiveBucketProperty.getBucketFunctionType()); List<String> bucketColumns = hiveBucketProperty.getBucketedBy(); if (bucketColumns.isEmpty()) { return Optional.empty(); } Map<String, HiveType> hiveTypes = table.getDataColumns().stream() .collect(toImmutableMap(Column::getName, Column::getType)); for (String column : bucketColumns) { if (!SUPPORTED_TYPES_FOR_BUCKET_FILTER.contains(hiveTypes.get(column))) { return Optional.empty(); } } Map<String, Set<NullableValue>> nameToBindings = bindings.entrySet().stream() .collect(toImmutableMap(entry -> ((HiveColumnHandle) entry.getKey()).getName(), Entry::getValue)); ImmutableList.Builder<Set<NullableValue>> orderedBindingsBuilder = ImmutableList.builder(); for (String columnName : bucketColumns) { if (!nameToBindings.containsKey(columnName)) { return Optional.empty(); } orderedBindingsBuilder.add(nameToBindings.get(columnName)); } List<Set<NullableValue>> orderedBindings = orderedBindingsBuilder.build(); int bucketCount = table.getStorage().getBucketProperty().get().getBucketCount(); List<TypeInfo> types = bucketColumns.stream() .map(hiveTypes::get) .map(HiveType::getTypeInfo) .collect(toImmutableList()); ImmutableSet.Builder<Integer> buckets = ImmutableSet.builder(); getHiveBuckets(new Object[types.size()], 0, orderedBindings, bucketCount, types, buckets); return Optional.of(buckets.build()); }