code: def attempt_resources_offsets_to_where_statement(
      start_offset, end_offset
  ):
      def start(offset):
          assert offset
          (
              start_batch_id,
              start_job_id,
              start_attempt_id,
              start_resource,
          ) = offset
          start_query = (
              "(attempt_resources.batch_id > %s OR "
              "(attempt_resources.batch_id = %s AND attempt_resources.job_id > %s) OR "
              "(attempt_resources.batch_id = %s AND attempt_resources.job_id = %s AND attempt_resources.attempt_id > %s) OR "
              "(attempt_resources.batch_id = %s AND attempt_resources.job_id = %s AND attempt_resources.attempt_id = %s AND attempt_resources.resource >= %s))"
          )
          start_query_args = (
              start_batch_id,
              start_batch_id,
              start_job_id,
              start_batch_id,
              start_job_id,
              start_attempt_id,
              start_batch_id,
              start_job_id,
              start_attempt_id,
              start_resource,
          )
          return (start_query, start_query_args)
  
      def end(offset):
          assert offset
          (
              end_batch_id,
              end_job_id,
              end_attempt_id,
              end_resource,
          ) = offset
          end_query = (
              "(attempt_resources.batch_id < %s OR "
              "(attempt_resources.batch_id = %s AND attempt_resources.job_id < %s) OR "
              "(attempt_resources.batch_id = %s AND attempt_resources.job_id = %s AND attempt_resources.attempt_id < %s) OR "
              "(attempt_resources.batch_id = %s AND attempt_resources.job_id = %s AND attempt_resources.attempt_id = %s AND attempt_resources.resource < %s))"
          )
          end_query_args = (
              end_batch_id,
              end_batch_id,
              end_job_id,
              end_batch_id,
              end_job_id,
              end_attempt_id,
              end_batch_id,
              end_job_id,
              end_attempt_id,
              end_resource,
          )
          return (end_query, end_query_args)
  
      return compile_query(start, end, start_offset, end_offset)
  
file_path: hail/batch/sql/add_resource_ids.py
imports: import asyncio
  import functools
  import os
  import random
  import time
  from typing import List, Optional, Tuple
  from gear import Database, transaction
  from hailtop.utils import bounded_gather
label_desc: Use image node_id 2 for calling a global function with example usage: attempt_resources_offsets_to_where_statement(start_offset, end_offset) and returns: compile_query, start_query,  start_query_args, end_query,  end_query_args