code: def compile_query(start_f, end_f, start_offset, end_offset):
      # start inclusive, end exclusive
      if start_offset is None and end_offset is None:
          return ("", None)
  
      assert start_offset != end_offset, str((start_offset, end_offset))
  
      if start_offset is None:
          assert end_offset
          where_cond, query_args = end_f(end_offset)
          where_cond = f"WHERE {where_cond}"
      elif end_offset is None:
          assert start_offset
          where_cond, query_args = start_f(start_offset)
          where_cond = f"WHERE {where_cond}"
      else:
          start_where_cond, start_query_args = start_f(start_offset)
          end_where_cond, end_query_args = end_f(end_offset)
  
          where_cond = f"WHERE {start_where_cond} AND {end_where_cond}"
          query_args = (*start_query_args, *end_query_args)
  
      return (where_cond, query_args)
  
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 1 for calling a global function with example usage: compile_query(start_f, end_f, start_offset, end_offset) and returns: where_cond,  query_args, str,  None