private static int getNumBuckets(ObjectInspector arg) throws UDFArgumentException {
    UDFArgumentException udfArgumentException = new UDFArgumentException("ICEBERG_BUCKET() second argument can only " +
        "take an int type, but got " + arg.getTypeName());
    if (arg.getCategory() != ObjectInspector.Category.PRIMITIVE) {
      throw udfArgumentException;
    }
    PrimitiveObjectInspector.PrimitiveCategory inputType = ((PrimitiveObjectInspector) arg).getPrimitiveCategory();
    if (inputType != PrimitiveObjectInspector.PrimitiveCategory.INT) {
      throw udfArgumentException;
    }
    return ((WritableConstantIntObjectInspector) arg).getWritableConstantValue().get();
  }
GenericUDFIcebergBucket - UDF that wraps around Iceberg's bucket transform function
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/udf/GenericUDFIcebergBucket.java